From 07d88199b41f201a460c96b29709e6fb0989e9ec Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 4 Dec 2012 14:50:59 +0000 Subject: [PATCH] New parameter to tweak the display of Impact anaysis: which tab to display first? list or graphics? SVN:trunk[2500] --- core/config.class.inc.php | 9 ++ pages/UI.php | 284 +++++++++++++++++++++----------------- 2 files changed, 167 insertions(+), 126 deletions(-) diff --git a/core/config.class.inc.php b/core/config.class.inc.php index d8135eadc..059b4c360 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -597,6 +597,15 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ), + 'impact_analysis_first_tab' => array( + 'type' => 'string', + 'description' => 'Which tab to display first in the impact analysis view: list or graphics. Graphics are nicer but slower to display when there are many objects', + // examples... not used + 'default' => 'graphics', + 'value' => '', + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ), ); public function IsProperty($sPropCode) diff --git a/pages/UI.php b/pages/UI.php index f4b67c675..461424da1 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -500,6 +500,148 @@ function DisplayMultipleSelectionForm($oP, $oFilter, $sNextOperation, $oChecker, $oP->add_ready_script("$('#1 table.listResults').trigger('check_all');"); } +function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj) +{ + $oP->SetCurrentTab(Dict::S('UI:RelationshipList')); + $oP->add("
"); + $iBlock = 1; // Zero is not a valid blockid + foreach($aResults as $sListClass => $aObjects) + { + $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); + $oP->add("

".MetaModel::GetRelationDescription($sRelation).' '.$oObj->GetName()."

\n"); + $oP->add("
\n"); + $oP->add("

".MetaModel::GetClassIcon($sListClass)." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass))."

\n"); + $oP->add("
\n"); + $oBlock = DisplayBlock::FromObjectSet($oSet, 'list'); + $oBlock->Display($oP, $iBlock++); + $oP->P(' '); // Some space ? + } + $oP->add("
"); +} + +function DisplayNavigatorGraphicsTab($oP, $aResults, $sClass, $id, $sRelation, $oAppContext) +{ + $oP->SetCurrentTab(Dict::S('UI:RelationshipGraph')); + + $oP->add("
\n"); + $oP->add_ready_script( +<< $aObjects) + { + foreach($aObjects as $oCurrObj) + { + $sSubClass = get_class($oCurrObj); + $aSortedElements[$sSubClass] = MetaModel::GetName($sSubClass); + } + } + + asort($aSortedElements); + $idx = 0; + foreach($aSortedElements as $sSubClass => $sClassName) + { + $oP->add(" "); + $idx++; + } + $oP->add("

"); + $oP->add("
\n"); + $oP->add("
\n"); + $oP->add("
".Dict::S('UI:ElementsDisplayed')."
\n"); + + $width = 1000; + $height = 700; + $sDrillUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&'.$oAppContext->GetForLink(); + $sParams = "pWidth=$width&pHeight=$height&drillUrl=".urlencode($sDrillUrl)."&displayController=false&xmlUrl=".urlencode("./xml.navigator.php")."&obj_class=$sClass&obj_id=$id&relation=$sRelation"; + + $oP->add("
+ + + + + + +
\n"); + $oP->add_script( +<<add_ready_script( +<<GetRelatedObjects($sRelation, 20 /* iMaxDepth */, $aResults); $oP->AddTabContainer('Navigator'); $oP->SetCurrentTabContainer('Navigator'); - $oP->SetCurrentTab(Dict::S('UI:RelationshipGraph')); + + $sFirstTab = MetaModel::GetConfig()->Get('impact_analysis_first_tab'); + if ($sFirstTab == 'list') + { + DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj); + DisplayNavigatorGraphicsTab($oP, $aResults, $sClass, $id, $sRelation, $oAppContext); + } + else + { + DisplayNavigatorGraphicsTab($oP, $aResults, $sClass, $id, $sRelation, $oAppContext); + DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj); + } - $oP->add("
\n"); - $oP->add_ready_script( -<<GetRelatedObjects($sRelation, 20 /* iMaxDepth */, $aResults); - foreach($aResults as $sClassIdx => $aObjects) - { - foreach($aObjects as $oCurrObj) - { - $sSubClass = get_class($oCurrObj); - $aSortedElements[$sSubClass] = MetaModel::GetName($sSubClass); - } - } - - asort($aSortedElements); - $idx = 0; - foreach($aSortedElements as $sSubClass => $sClassName) - { - $oP->add(" "); - $idx++; - } - $oP->add("

"); - $oP->add("
\n"); - $oP->add("
\n"); - $oP->add("
".Dict::S('UI:ElementsDisplayed')."
\n"); - - $width = 1000; - $height = 700; - $sDrillUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&'.$oAppContext->GetForLink(); - $sParams = "pWidth=$width&pHeight=$height&drillUrl=".urlencode($sDrillUrl)."&displayController=false&xmlUrl=".urlencode("./xml.navigator.php")."&obj_class=$sClass&obj_id=$id&relation=$sRelation"; - - $oP->add("
- - - - - - -
\n"); - $oP->SetCurrentTab(Dict::S('UI:RelationshipList')); - $oP->add("

 

"); - $oP->add_script( -<<add_ready_script( -<<SetCurrentTab(''); break;