mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Enhancement: provide a "list" view of the "impacts" and "depends on" results on top of the graphical view.
SVN:trunk[819]
This commit is contained in:
@@ -65,7 +65,14 @@ class DisplayBlock
|
||||
public static function FromObjectSet(DBObjectSet $oSet, $sStyle, $aParams = array())
|
||||
{
|
||||
$oDummyFilter = new DBObjectSearch($oSet->GetClass());
|
||||
$oBlock = new DisplayBlock($oDummyFilter, $sStyle, false, $aParams, $oSet); // DisplayBlocks built this way are synchronous
|
||||
$aKeys = array();
|
||||
while($oObject = $oSet->Fetch())
|
||||
{
|
||||
$aKeys[] = $oObject->GetKey();
|
||||
}
|
||||
$oSet->Rewind();
|
||||
$oDummyFilter->AddCondition('id', $aKeys, 'IN');
|
||||
$oBlock = new DisplayBlock($oDummyFilter, $sStyle, false, $aParams); // DisplayBlocks built this way are synchronous
|
||||
return $oBlock;
|
||||
}
|
||||
|
||||
@@ -553,6 +560,30 @@ class DisplayBlock
|
||||
case 'actions':
|
||||
$sClass = $this->m_oFilter->GetClass();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
|
||||
if ($bContextFilter)
|
||||
{
|
||||
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
|
||||
foreach($oAppContext->GetNames() as $sFilterCode)
|
||||
{
|
||||
$sContextParamValue = trim(utils::ReadParam($sFilterCode, null));
|
||||
if (!is_null($sContextParamValue) && ! empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode))
|
||||
{
|
||||
$this->m_oFilter->AddCondition($sFilterCode, $sContextParamValue); // Use the default 'loose' operator
|
||||
}
|
||||
}
|
||||
$aQueryParams = array();
|
||||
if (isset($aExtraParams['query_params']))
|
||||
{
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
|
||||
}
|
||||
$iCount = $this->m_oSet->Count();
|
||||
$sHyperlink = '../pages/UI.php?operation=search&filter='.$this->m_oFilter->serialize();
|
||||
$sHtml .= '<p><a class="actions" href="'.$sHyperlink.'">';
|
||||
$sHtml .= MetaModel::GetClassIcon($sClass, true, 'float;left;margin-right:10px;');
|
||||
$sHtml .= MetaModel::GetName($sClass).': '.$iCount.'</a></p>';
|
||||
$sParams = $oAppContext->GetForLink();
|
||||
$sHtml .= '<p>';
|
||||
if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY))
|
||||
@@ -562,6 +593,67 @@ class DisplayBlock
|
||||
$sHtml .= "<a href=\"../pages/UI.php?operation=search_form&class={$sClass}&$sParams\">".Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass))."</a>\n";
|
||||
$sHtml .= '</p>';
|
||||
break;
|
||||
|
||||
case 'summary':
|
||||
$sClass = $this->m_oFilter->GetClass();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sTitle = isset($aExtraParams['title[block]']) ? $aExtraParams['title[block]'] : '';
|
||||
$sLabel = isset($aExtraParams['label[block]']) ? $aExtraParams['label[block]'] : '';
|
||||
$sStateAttrCode = isset($aExtraParams['status[block]']) ? $aExtraParams['status[block]'] : 'status';
|
||||
$sStatesList = isset($aExtraParams['status_codes[block]']) ? $aExtraParams['status_codes[block]'] : '';
|
||||
|
||||
$bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
|
||||
if ($bContextFilter)
|
||||
{
|
||||
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
|
||||
foreach($oAppContext->GetNames() as $sFilterCode)
|
||||
{
|
||||
$sContextParamValue = trim(utils::ReadParam($sFilterCode, null));
|
||||
if (!is_null($sContextParamValue) && ! empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode))
|
||||
{
|
||||
$this->m_oFilter->AddCondition($sFilterCode, $sContextParamValue); // Use the default 'loose' operator
|
||||
}
|
||||
}
|
||||
$aQueryParams = array();
|
||||
if (isset($aExtraParams['query_params']))
|
||||
{
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
|
||||
}
|
||||
// Summary details
|
||||
$aCounts = array();
|
||||
$aStateLabels = array();
|
||||
if (!empty($sStateAttrCode) && !empty($sStatesList))
|
||||
{
|
||||
$aStates = explode(',', $sStatesList);
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode);
|
||||
foreach($aStates as $sStateValue)
|
||||
{
|
||||
$oFilter = clone($this->m_oFilter);
|
||||
$oFilter->AddCondition($sStateAttrCode, $sStateValue, '=');
|
||||
$oSet = new DBObjectSet($oFilter);
|
||||
$aCounts[$sStateValue] = $oSet->Count();
|
||||
$aStateLabels[$sStateValue] = Dict::S("Class:".$oAttDef->GetHostClass()."/Attribute:$sStateAttrCode/Value:$sStateValue");
|
||||
if ($aCounts[$sStateValue] == 0)
|
||||
{
|
||||
$aCounts[$sStateValue] = '-';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sHyperlink = '../pages/UI.php?operation=search&filter='.$oFilter->serialize();
|
||||
$aCounts[$sStateValue] = "<a href=\"$sHyperlink\">{$aCounts[$sStateValue]}</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sHtml .= '<div class="summary-details"><table><tr><th>'.implode('</th><th>', $aStateLabels).'</th></tr>';
|
||||
$sHtml .= '<tr><td>'.implode('</td><td>', $aCounts).'</td></tr></table></div>';
|
||||
// Title & summary
|
||||
$iCount = $this->m_oSet->Count();
|
||||
$sHyperlink = '../pages/UI.php?operation=search&filter='.$this->m_oFilter->serialize();
|
||||
$sHtml .= '<h1>'.Dict::S(str_replace('_', ':', $sTitle)).'</h1>';
|
||||
$sHtml .= '<a class="summary" href="'.$sHyperlink.'">'.Dict::Format(str_replace('_', ':', $sLabel), $iCount).'</a>';
|
||||
break;
|
||||
|
||||
case 'bare_details':
|
||||
while($oObj = $this->m_oSet->Fetch())
|
||||
|
||||
42
pages/UI.php
42
pages/UI.php
@@ -1393,6 +1393,10 @@ EOF
|
||||
$sClass = utils::ReadParam('class', '');
|
||||
$id = utils::ReadParam('id', 0);
|
||||
$sRelation = utils::ReadParam('relation', 'impact');
|
||||
|
||||
$oP->AddTabContainer('Navigator');
|
||||
$oP->SetCurrentTabContainer('Navigator');
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationshipGraph'));
|
||||
$width = 1000;
|
||||
$height = 700;
|
||||
$sParams = "pWidth=$width&pHeight=$height&drillUrl=".urlencode('../pages/UI.php?operation=details')."&displayController=false&xmlUrl=".urlencode("./xml.navigator.php")."&obj_class=$sClass&obj_id=$id&relation=$sRelation";
|
||||
@@ -1404,6 +1408,44 @@ EOF
|
||||
<param name=\"movie\" value=\"../navigator/navigator.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" />
|
||||
<embed src=\"../navigator/navigator.swf\" flashVars=\"$sParams\" quality=\"high\" bgcolor=\"#ffffff\" width=\"$width\" height=\"$height\" name=\"navigator\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/go/getflashplayer\" />
|
||||
</object>\n");
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationshipList'));
|
||||
$oP->add("<div id=\"impacted_objects\" style=\"width:100%;background-color:#fff;padding:10px;\"><p style=\"height:150px;\"> </p></div>");
|
||||
$oP->add_ready_script(
|
||||
<<<EOF
|
||||
UpdateImpactedObjects('$sClass', $id, '$sRelation');
|
||||
|
||||
var ajax_request = null;
|
||||
|
||||
function UpdateImpactedObjects(sClass, iId, sRelation)
|
||||
{
|
||||
var class_name = sClass; //$('select[name=class_name]').val();
|
||||
if (class_name != '')
|
||||
{
|
||||
$('#impacted_objects').block();
|
||||
|
||||
// Make sure that we cancel any pending request before issuing another
|
||||
// since responses may arrive in arbitrary order
|
||||
if (ajax_request != null)
|
||||
{
|
||||
ajax_request.abort();
|
||||
ajax_request = null;
|
||||
}
|
||||
|
||||
ajax_request = $.get('xml.navigator.php', { class: sClass, id: iId, relation: sRelation, format: 'html' },
|
||||
function(data)
|
||||
{
|
||||
$('#impacted_objects').empty();
|
||||
$('#impacted_objects').append(data);
|
||||
$('#impacted_objects').unblock();
|
||||
$('#impacted_objects .listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
|
||||
$('#impacted_objects table.listResults').tableHover(); // hover tables
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
);
|
||||
$oP->SetCurrentTab('');
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user