diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 4149be0f0..6f6016a68 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -398,15 +398,13 @@ EOF $this->aFieldsMap[$sAttCode] = $sInputId; } - /** * @param \iTopWebPage $oPage * @param $bEditMode * * @throws \CoreException - * @throws \Exception */ - public function DisplayDashboards($oPage, $bEditMode) + protected function DisplayDashboardTabs($oPage, $bEditMode) { if ($bEditMode || $this->IsNew()) { @@ -429,24 +427,41 @@ EOF continue; } // Process only dashboards attributes... - $oPage->SetCurrentTab($oAttDef->GetLabel()); - - // Load the dashboard - $oDashboard = $oAttDef->GetDashboard(); - if (is_null($oDashboard)) - { - continue; - } - - $bCanEdit = UserRights::IsAdministrator() || $oAttDef->IsUserEditable(); - $sDivId = $oDashboard->GetId(); - $oPage->add('
'); - $aExtraParams = array('query_params' => $this->ToArgsForQuery()); - $oDashboard->Render($oPage, false, $aExtraParams, $bCanEdit); - $oPage->add('
'); + $oPage->AddAjaxTab($oAttDef->GetLabel(), utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=dashboard&class='.get_class($this).'&id='.$this->GetKey().'&attcode='.$oAttDef->GetCode()); } } + /** + * @param \iTopWebPage $oPage + * @param $sAttCode + * + * @throws \Exception + */ + public function DisplayDashboard($oPage, $sAttCode) + { + $sClass = get_class($this); + $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); + + if (!$oAttDef instanceof AttributeDashboard) + { + throw new CoreException(Dict::S('UI:Error:InvalidDashboard')); + } + + // Load the dashboard + $oDashboard = $oAttDef->GetDashboard(); + if (is_null($oDashboard)) + { + throw new CoreException(Dict::S('UI:Error:InvalidDashboard')); + } + + $bCanEdit = UserRights::IsAdministrator() || $oAttDef->IsUserEditable(); + $sDivId = $oDashboard->GetId(); + $oPage->add('
'); + $aExtraParams = array('query_params' => $this->ToArgsForQuery()); + $oDashboard->Render($oPage, false, $aExtraParams, $bCanEdit); + $oPage->add('
'); + } + /** * @param \WebPage $oPage * @param bool $bEditMode @@ -945,7 +960,7 @@ EOF $oPage->SetCurrentTab(Dict::S('UI:PropertiesTab')); $this->DisplayBareProperties($oPage, $bEditMode); $this->DisplayBareRelations($oPage, $bEditMode); - $this->DisplayDashboards($oPage, $bEditMode); + $this->DisplayDashboardTabs($oPage, $bEditMode); //$oPage->SetCurrentTab(Dict::S('UI:HistoryTab')); //$this->DisplayBareHistory($oPage, $bEditMode); $oPage->AddAjaxTab(Dict::S('UI:HistoryTab'), diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index dc307b69b..48022abf3 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -442,6 +442,7 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:Error:ObjectAlreadyCreated' => 'Error: the object has already been created!', 'UI:Error:Invalid_Stimulus_On_Object_In_State' => 'Error: invalid stimulus "%1$s" on object %2$s in state "%3$s".', 'UI:Error:InvalidDashboardFile' => 'Error: invalid dashboard file', + 'UI:Error:InvalidDashboard' => 'Error: invalid dashboard', 'UI:GroupBy:Count' => 'Count', 'UI:GroupBy:Count+' => 'Number of elements', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 29c11833f..ebbb52533 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -309,6 +309,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:Error:ObjectAlreadyCreated' => 'Erreur: l\'objet a déjà été créé !', 'UI:Error:Invalid_Stimulus_On_Object_In_State' => 'Erreur: le stimulus "%1$s" n\'est pas valide pour l\'objet %2$s dans l\'état "%3$s".', 'UI:Error:InvalidDashboardFile' => 'Erreur: Le fichier tableau de bord est invalide', + 'UI:Error:InvalidDashboard' => 'Erreur: Le tableau de bord est invalide', 'UI:GroupBy:Count' => 'Nombre', 'UI:GroupBy:Count+' => 'Nombre d\'éléments', 'UI:CountOfObjects' => '%1$d objets correspondants aux critères.', diff --git a/pages/ajax.render.php b/pages/ajax.render.php index c64700b5d..c08dc54ce 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -910,6 +910,15 @@ try } break; + case 'dashboard': + $oPage->SetContentType('text/html'); + $id = (int)utils::ReadParam('id', 0); + $sAttCode = utils::ReadParam('attcode', ''); + /** @var \cmdbAbstractObject $oObj */ + $oObj = MetaModel::GetObject($sClass, $id); + $oObj->DisplayDashboard($oPage, $sAttCode); + break; + case 'export_dashboard': $sDashboardId = utils::ReadParam('id', '', false, 'raw_data'); $sDashboardFile = utils::ReadParam('file', '', false, 'raw_data');