-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabledashlet.class.inc.php
87 lines (72 loc) · 2.58 KB
/
tabledashlet.class.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
class DashletTable extends Dashlet
{
public function __construct($oModelReflection, $sId)
{
parent::__construct($oModelReflection, $sId);
$this->aProperties['oql'] = 'SELECT Server';
$this->aProperties['class'] = 'Server';
$this->aProperties['axisx'] = 'brand_name';
$this->aProperties['axisy'] = 'location_name';
$this->aCSSClasses[] = 'dashlet-block';
}
public function Render($oPage, $bEditMode = false, $aExtraParams = array())
{
$sId = utils::GetSafeId('dashlet_table_'.($bEditMode? 'edit_' : '').$this->sId);
$sHtml = "";
$aParams = array(
'class' => $this->aProperties['class'],
'oql' => $this->aProperties['oql'],
'axisx' => $this->aProperties['axisx'],
'axisy' => $this->aProperties['axisy'],
'id' => "table-" . $sId,
);
$sParam = http_build_query($aParams);
$sEnv = utils::GetCurrentEnvironment();
$sRender = "env-" . $sEnv . "/custom-dashlets/ajax.render.php";
$sUrl = rtrim(MetaModel::GetConfig()->Get('app_root_url'), "/") . "/" . $sRender;
$sHtml .= "<div id=\"$sId\" class=\"dashlet-content loading\">\n";
$sHtml .= $oPage->GetP("<img src=\"../images/indicator_arrows.gif\"> ".Dict::S('UI:Loading'));
$oPage->add($sHtml);
if($bEditMode) {
$oPage->add('<div class="dashlet-blocker"></div>');
}
$oPage->add('</div>');
$oPage->add_script('
$.post("' . $sUrl . '?' . $sParam . '",
{ operation: "ajax" },
function(data){
$("#'.$sId.'")
.empty()
.append(data)
.removeClass("loading")
;
$("#table-' . $sId . '").tablesorter({ widgets:["zebra"] });
}
);
');
}
public function GetPropertiesFields(DesignerForm $oForm)
{
$oField = new DesignerLongTextField('oql', Dict::S('UI:DashletTable:Prop-OQL'), $this->aProperties['oql']);
$oField->SetMandatory();
$oForm->AddField($oField);
$oField = new DesignerTextField('class', Dict::S('UI:DashletTable:Prop-Class'), $this->aProperties['class']);
$oField->SetMandatory();
$oForm->AddField($oField);
$oField = new DesignerTextField('axisx', Dict::S('UI:DashletTable:Prop-Axis-X'), $this->aProperties['axisx']);
$oField->SetMandatory();
$oForm->AddField($oField);
$oField = new DesignerTextField('axisy', Dict::S('UI:DashletTable:Prop-Axis-Y'), $this->aProperties['axisy']);
$oField->SetMandatory();
$oForm->AddField($oField);
}
static public function GetInfo()
{
return array(
'label' => Dict::S('UI:DashletTable:Label'),
'icon' => 'env-'.utils::GetCurrentEnvironment().'/custom-dashlets/images/table.png',
'description' => Dict::S('UI:DashletTable:Description'),
);
}
}