mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Dashboard: display the most relevant label in the group by dashlets (eg: hyperlink to an ext key)
SVN:trunk[2043]
This commit is contained in:
@@ -467,8 +467,14 @@ abstract class DashletGroupBy extends Dashlet
|
||||
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||
{
|
||||
if (!$oAttDef->IsScalar()) continue; // skip link sets
|
||||
if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) continue; // skip external keys
|
||||
$aGroupBy[$sAttCode] = $oAttDef->GetLabel();
|
||||
|
||||
$sLabel = $oAttDef->GetLabel();
|
||||
if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE))
|
||||
{
|
||||
$sLabel = $oAttDef->GetLabel().' (strict)';
|
||||
}
|
||||
|
||||
$aGroupBy[$sAttCode] = $sLabel;
|
||||
|
||||
if ($oAttDef instanceof AttributeDateTime)
|
||||
{
|
||||
@@ -479,13 +485,10 @@ abstract class DashletGroupBy extends Dashlet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$oField = new DesignerComboField('group_by', 'Group by', $this->aProperties['group_by']);
|
||||
$oField->SetAllowedValues($aGroupBy);
|
||||
$oForm->AddField($oField);
|
||||
|
||||
|
||||
$aStyles = array(
|
||||
'pie' => 'Pie chart',
|
||||
'bars' => 'Bar chart',
|
||||
@@ -778,7 +781,8 @@ class DashletProto extends Dashlet
|
||||
|
||||
$oFilter = DBObjectSearch::FromOQL('SELECT FunctionalCI AS fci');
|
||||
$sGroupBy1 = 'status';
|
||||
$sGroupBy2 = 'org_id_friendlyname';
|
||||
//$sGroupBy2 = 'org_id_friendlyname';
|
||||
$sGroupBy2 = 'org_id';
|
||||
$sHtmlTitle = "Hardcoded on $sGroupBy1 and $sGroupBy2...";
|
||||
|
||||
$sAlias = $oFilter->GetClassAlias();
|
||||
@@ -807,6 +811,9 @@ class DashletProto extends Dashlet
|
||||
$sValue1 = $aRow['grouped_by_1'];
|
||||
$sValue2 = $aRow['grouped_by_2'];
|
||||
|
||||
$sDisplayValue1 = $aGroupBy['grouped_by_1']->MakeValueLabel($oFilter, $sValue1, $sValue1); // default to the raw value
|
||||
$sDisplayValue2 = $aGroupBy['grouped_by_2']->MakeValueLabel($oFilter, $sValue2, $sValue2); // default to the raw value
|
||||
|
||||
// Build the search for this subset
|
||||
$oSubsetSearch = clone $oFilter;
|
||||
$oCondition = new BinaryExpression($oGroupByExp1, '=', new ScalarExpression($sValue1));
|
||||
@@ -816,8 +823,8 @@ class DashletProto extends Dashlet
|
||||
|
||||
$sFilter = urlencode($oSubsetSearch->serialize());
|
||||
$aData[] = array (
|
||||
'group1' => htmlentities($sValue1, ENT_QUOTES, 'UTF-8'),
|
||||
'group2' => htmlentities($sValue2, ENT_QUOTES, 'UTF-8'),
|
||||
'group1' => $sDisplayValue1,
|
||||
'group2' => $sDisplayValue2,
|
||||
'value' => "<a href=\"".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&dosearch=1&$sParams&filter=$sFilter\">$iCount</a>"
|
||||
); // TO DO: add the context information
|
||||
}
|
||||
|
||||
@@ -366,28 +366,32 @@ class DisplayBlock
|
||||
$aRes = CMDBSource::QueryToArray($sSql);
|
||||
|
||||
$aGroupBy = array();
|
||||
$sLabels = array();
|
||||
$aLabels = array();
|
||||
$aValues = array();
|
||||
$iTotalCount = 0;
|
||||
foreach ($aRes as $aRow)
|
||||
foreach ($aRes as $iRow => $aRow)
|
||||
{
|
||||
$sValue = $aRow['grouped_by_1'];
|
||||
$sLabels[$sValue] = htmlentities($sValue, ENT_QUOTES, 'UTF-8');
|
||||
$aGroupBy[$sValue] = (int) $aRow['_itop_count_'];
|
||||
$aValues[$iRow] = $sValue;
|
||||
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
|
||||
$aLabels[$iRow] = $sHtmlValue;
|
||||
$aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
|
||||
$iTotalCount += $aRow['_itop_count_'];
|
||||
}
|
||||
|
||||
|
||||
$aData = array();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sParams = $oAppContext->GetForLink();
|
||||
foreach($aGroupBy as $sValue => $iCount)
|
||||
foreach($aGroupBy as $iRow => $iCount)
|
||||
{
|
||||
// Build the search for this subset
|
||||
$oSubsetSearch = clone $this->m_oFilter;
|
||||
$oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($sValue));
|
||||
$oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
|
||||
$oSubsetSearch->AddConditionExpression($oCondition);
|
||||
$sFilter = urlencode($oSubsetSearch->serialize());
|
||||
|
||||
$aData[] = array ( 'group' => $sLabels[$sValue],
|
||||
$aData[] = array ( 'group' => $aLabels[$iRow],
|
||||
'value' => "<a href=\"".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&dosearch=1&$sParams&filter=$sFilter\">$iCount</a>"); // TO DO: add the context information
|
||||
}
|
||||
$aAttribs =array(
|
||||
@@ -798,25 +802,27 @@ EOF
|
||||
$aRes = CMDBSource::QueryToArray($sSql);
|
||||
|
||||
$aGroupBy = array();
|
||||
$sLabels = array();
|
||||
$aLabels = array();
|
||||
$aValues = array();
|
||||
$iTotalCount = 0;
|
||||
foreach ($aRes as $aRow)
|
||||
foreach ($aRes as $iRow => $aRow)
|
||||
{
|
||||
$sValue = $aRow['grouped_by_1'];
|
||||
$sLabels[$sValue] = htmlentities($sValue, ENT_QUOTES, 'UTF-8');
|
||||
$aGroupBy[$sValue] = (int) $aRow['_itop_count_'];
|
||||
$aValues[$iRow] = $sValue;
|
||||
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
|
||||
$aLabels[$iRow] = $sHtmlValue;
|
||||
$aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
|
||||
$iTotalCount += $aRow['_itop_count_'];
|
||||
}
|
||||
|
||||
$aData = array();
|
||||
$aLabels = array();
|
||||
$idx = 0;
|
||||
$aURLs = array();
|
||||
foreach($aGroupBy as $sValue => $iValue)
|
||||
foreach($aGroupBy as $iRow => $iCount)
|
||||
{
|
||||
// Build the search for this subset
|
||||
$oSubsetSearch = clone $this->m_oFilter;
|
||||
$oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($sValue));
|
||||
$oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
|
||||
$oSubsetSearch->AddConditionExpression($oCondition);
|
||||
$aURLs[$idx] = $oSubsetSearch->serialize();
|
||||
$idx++;
|
||||
@@ -871,26 +877,27 @@ EOF
|
||||
$aRes = CMDBSource::QueryToArray($sSql);
|
||||
|
||||
$aGroupBy = array();
|
||||
$sLabels = array();
|
||||
$aLabels = array();
|
||||
$iTotalCount = 0;
|
||||
foreach ($aRes as $aRow)
|
||||
foreach ($aRes as $iRow => $aRow)
|
||||
{
|
||||
$sValue = $aRow['grouped_by_1'];
|
||||
$sLabels[$sValue] = htmlentities($sValue, ENT_QUOTES, 'UTF-8');
|
||||
$aGroupBy[$sValue] = (int) $aRow['_itop_count_'];
|
||||
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
|
||||
$aLabels[$iRow] = strip_tags($sHtmlValue);
|
||||
$aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
|
||||
$iTotalCount += $aRow['_itop_count_'];
|
||||
}
|
||||
|
||||
$aData = array();
|
||||
$aLabels = array();
|
||||
$aChartLabels = array();
|
||||
$maxValue = 0;
|
||||
foreach($aGroupBy as $sValue => $iValue)
|
||||
foreach($aGroupBy as $iRow => $iCount)
|
||||
{
|
||||
$oBarValue = new bar_value($iValue);
|
||||
$oBarValue = new bar_value($iCount);
|
||||
$oBarValue->on_click("ofc_drill_down_$sId");
|
||||
$aData[] = $oBarValue;
|
||||
if ($iValue > $maxValue) $maxValue = $iValue;
|
||||
$aLabels[] = $sValue;
|
||||
if ($iCount > $maxValue) $maxValue = $iCount;
|
||||
$aChartLabels[] = $aLabels[$iRow];
|
||||
}
|
||||
$oYAxis = new y_axis();
|
||||
$aMagicValues = array(1,2,5,10);
|
||||
@@ -916,7 +923,7 @@ EOF
|
||||
// set them vertical
|
||||
$oXLabels->set_vertical();
|
||||
// set the label text
|
||||
$oXLabels->set_labels($aLabels);
|
||||
$oXLabels->set_labels($aChartLabels);
|
||||
// Add the X Axis Labels to the X Axis
|
||||
$oXAxis->set_labels( $oXLabels );
|
||||
$oChart->set_x_axis( $oXAxis );
|
||||
@@ -951,25 +958,25 @@ EOF
|
||||
$aRes = CMDBSource::QueryToArray($sSql);
|
||||
|
||||
$aGroupBy = array();
|
||||
$sLabels = array();
|
||||
$aLabels = array();
|
||||
$iTotalCount = 0;
|
||||
foreach ($aRes as $aRow)
|
||||
foreach ($aRes as $iRow => $aRow)
|
||||
{
|
||||
$sValue = $aRow['grouped_by_1'];
|
||||
$sLabels[$sValue] = htmlentities($sValue, ENT_QUOTES, 'UTF-8');
|
||||
$aGroupBy[$sValue] = (int) $aRow['_itop_count_'];
|
||||
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
|
||||
$aLabels[$iRow] = strip_tags($sHtmlValue);
|
||||
$aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
|
||||
$iTotalCount += $aRow['_itop_count_'];
|
||||
}
|
||||
|
||||
$aData = array();
|
||||
foreach($aGroupBy as $sValue => $iValue)
|
||||
foreach($aGroupBy as $iRow => $iCount)
|
||||
{
|
||||
$PieValue = new pie_value($iValue, $sValue); //@@ BUG: not passed via ajax !!!
|
||||
$PieValue = new pie_value($iCount, $aLabels[$iRow]); //@@ BUG: not passed via ajax !!!
|
||||
$PieValue->on_click("ofc_drill_down_$sId");
|
||||
$aData[] = $PieValue;
|
||||
}
|
||||
|
||||
|
||||
$oChartElement->set_values( $aData );
|
||||
$oChart->x_axis = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user