diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 3afdca53b..be4262668 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -1,5 +1,5 @@ sTitle = ''; $this->sLayoutClass = 'DashboardLayoutOneCol'; + $this->bAutoReload = false; + $this->iAutoReloadSec = MetaModel::GetConfig()->GetStandardReloadInterval(); $this->aCells = array(); $this->oDOMNode = null; $this->sId = $sId; @@ -76,6 +81,20 @@ abstract class Dashboard $this->sTitle = ''; } + $this->bAutoReload = false; + $this->iAutoReloadSec = MetaModel::GetConfig()->GetStandardReloadInterval(); + if ($oAutoReloadNode = $this->oDOMNode->getElementsByTagName('auto_reload')->item(0)) + { + if ($oAutoReloadEnabled = $oAutoReloadNode->getElementsByTagName('enabled')->item(0)) + { + $this->bAutoReload = ($oAutoReloadEnabled->textContent == 'true'); + } + if ($oAutoReloadInterval = $oAutoReloadNode->getElementsByTagName('interval')->item(0)) + { + $this->iAutoReloadSec = max(5, (int)$oAutoReloadInterval->textContent); + } + } + if ($oCellsNode = $this->oDOMNode->getElementsByTagName('cells')->item(0)) { $oCellsList = $oCellsNode->getElementsByTagName('cell'); @@ -173,6 +192,13 @@ abstract class Dashboard $oNode = $oDoc->createElement('title', $this->sTitle); $oDefinition->appendChild($oNode); + $oAutoReloadNode = $oDoc->createElement('auto_reload'); + $oDefinition->appendChild($oAutoReloadNode); + $oNode = $oDoc->createElement('enabled', $this->bAutoReload ? 'true' : 'false'); + $oAutoReloadNode->appendChild($oNode); + $oNode = $oDoc->createElement('interval', $this->iAutoReloadSec); + $oAutoReloadNode->appendChild($oNode); + $oCellsNode = $oDoc->createElement('cells'); $oDefinition->appendChild($oCellsNode); @@ -208,6 +234,8 @@ abstract class Dashboard { $this->sLayoutClass = $aParams['layout_class']; $this->sTitle = $aParams['title']; + $this->bAutoReload = $aParams['auto_reload'] == 'true'; + $this->iAutoReloadSec = max(5, (int) $aParams['auto_reload_sec']); foreach($aParams['cells'] as $aCell) { @@ -249,12 +277,32 @@ abstract class Dashboard { return $this->sTitle; } - + public function SetTitle($sTitle) { $this->sTitle = $sTitle; } - + + public function GetAutoReload() + { + return $this->bAutoReload; + } + + public function SetAutoReload($bAutoReload) + { + $this->bAutoReload = $bAutoReload; + } + + public function GetAutoReloadInterval() + { + return $this->iAutoReloadSec; + } + + public function SetAutoReloadInterval($iAutoReloadSec) + { + $this->iAutoReloadSec = max(5, (int)$iAutoReloadSec); + } + public function AddDashlet($oDashlet) { $sId = $this->GetNewDashletId(); @@ -305,12 +353,30 @@ abstract class Dashboard $oField = new DesignerLongTextField('dashboard_title', Dict::S('UI:DashboardEdit:DashboardTitle'), $this->sTitle); $oForm->AddField($oField); + + $oField = new DesignerBooleanField('auto_reload', Dict::S('UI:DashboardEdit:AutoReload'), $this->bAutoReload); + $oForm->AddField($oField); + + $oField = new DesignerTextField('auto_reload_sec', Dict::S('UI:DashboardEdit:AutoReloadSec'), $this->iAutoReloadSec); + $oField->SetValidationPattern('^$|^0*([5-9]|[1-9][0-9]+)$'); // Can be empty, or a number > 4 + $oForm->AddField($oField); + $this->SetFormParams($oForm); $oForm->RenderAsPropertySheet($oPage, false, '.itop-dashboard'); - + $oPage->add(''); + + $sRateTitle = addslashes(Dict::S('UI:DashboardEdit:AutoReloadSec+')); $oPage->add_ready_script( <<