From 7c8349f4f53329fa5bf5c20c2b38bdc9be76a52f Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 16 Mar 2021 10:25:18 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03804=20-=20auto=20refresh=20on=20group?= =?UTF-8?q?=20by=20dashlet=20(and=20dashlet=20badge)=20lost=20user=20prefe?= =?UTF-8?q?rences=20on=20showing=20obsolete=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/dashlet.class.inc.php | 1 + pages/ajax.render.php | 7 +++--- sources/Controller/AjaxRenderController.php | 26 ++++++++------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 4d850a816..282535818 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -2052,6 +2052,7 @@ class DashletHeaderDynamic extends Dashlet $aQueryParams = array(); } $oFilter = DBObjectSearch::FromOQL($sQuery, $aQueryParams); + $oFilter->SetShowObsoleteData(utils::ShowObsoleteData()); $sClass = $oFilter->GetClass(); $oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S(str_replace('_', ':', $sTitle))) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 34e0f667f..30b0886f7 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -87,7 +87,7 @@ try case 'refreshDashletCount': $oPage->SetContentType('application/json'); - $aResult = AjaxRenderController::RefreshCount($sFilter); + $aResult = AjaxRenderController::RefreshDashletCount($sFilter); $oPage->add(json_encode($aResult)); break; @@ -102,6 +102,7 @@ try $sExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $aExtraParams = json_decode($sExtraParams, true); $oFilter = DBObjectSearch::FromOQL($sFilter); + $oFilter->SetShowObsoleteData(utils::ShowObsoleteData()); $oSet = new CMDBObjectSet($oFilter, [], $aExtraParams); $oBlock = new displayblock($oFilter, 'summary', false, [], $oSet); $oBlock->RenderContent($oPage, $aExtraParams); @@ -508,13 +509,13 @@ try // ui.linkswidget case 'doAddObjects': $oPage->SetContentType('text/html'); - $sResult = AjaxRenderController::DoAddObjects($oPage, $sClass, $sFilter); + AjaxRenderController::DoAddObjects($oPage, $sClass, $sFilter); break; // ui.linkswidget case 'doAddIndirectLinks': $oPage = new JsonPage(''); - $sResult = AjaxRenderController::DoAddIndirectLinks($oPage, $sClass, $sFilter); + AjaxRenderController::DoAddIndirectLinks($oPage, $sClass, $sFilter); break; //////////////////////////////////////////////////////////// /// WizardHelper : see the corresponding PHP class, and JS class diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index b606810cc..98dd7c94e 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -10,13 +10,16 @@ use AjaxPage; use ApplicationContext; use ApplicationMenu; use AttributeLinkedSet; +use AttributeOneWayPassword; use BinaryExpression; use BulkExport; use BulkExportException; use CMDBObjectSet; use CMDBSource; +use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings; use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory; use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntryFactory; +use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityPanelHelper; use Combodo\iTop\Renderer\BlockRenderer; use DBObjectSearch; use DBObjectSet; @@ -25,6 +28,8 @@ use Dict; use Exception; use ExecutionKPI; use Expression; +use FieldExpression; +use FunctionExpression; use InlineImage; use JsonPage; use MetaModel; @@ -234,10 +239,8 @@ class AjaxRenderController // The first column is used for the selection (radio / checkbox) and is not sortable $iSortCol--; } - $bDisplayKey = utils::ReadParam('display_key', 'true') == 'true'; $aColumns = utils::ReadParam('columns', array(), false, 'raw_data'); $aClassAliases = utils::ReadParam('class_aliases', array()); - $iListId = utils::ReadParam('list_id', 0); // Filter the list to removed linked set since we are not able to display them here $sIdName = ""; @@ -329,6 +332,7 @@ class AjaxRenderController array_push($aResult["data"], $aObj); } } + $oKPI->ComputeAndReport('Data fetch and format'); return $aResult; } @@ -487,14 +491,12 @@ class AjaxRenderController } /** - * @param string $sEncoding + * @param string $sStyle * @param string $sFilter * * @return array * @throws \ArchivedObjectException * @throws \CoreException - * @throws \CoreUnexpectedValue - * @throws \DictExceptionMissingString * @throws \MissingQueryArgument * @throws \MySQLException * @throws \MySQLHasGoneAwayException @@ -504,17 +506,16 @@ class AjaxRenderController { $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $oFilter = DBObjectSearch::FromOQL($sFilter); + $oFilter->SetShowObsoleteData(utils::ShowObsoleteData()); if (isset($aExtraParams['group_by'])) { $sAlias = $oFilter->GetClassAlias(); if (isset($aExtraParams['group_by_label'])) { $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); - $sGroupByLabel = $aExtraParams['group_by_label']; } else { // Backward compatibility: group_by is simply a field id $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); - $sGroupByLabel = MetaModel::GetLabel($oFilter->GetClass(), $aExtraParams['group_by']); } // Security filtering @@ -537,9 +538,7 @@ class AjaxRenderController $aQueryParams = $aExtraParams['query_params']; } $aFunctions = array(); - $sAggregationFunction = 'count'; $sFctVar = '_itop_count_'; - $sAggregationAttr = ''; if (isset($aExtraParams['aggregation_function']) && !empty($aExtraParams['aggregation_attribute'])) { $sAggregationFunction = $aExtraParams['aggregation_function']; $sAggregationAttr = $aExtraParams['aggregation_attribute']; @@ -549,10 +548,6 @@ class AjaxRenderController $aFunctions = array($sFctVar => $oFctExpr); } - if (!empty($sAggregationAttr)) { - $sClass = $oFilter->GetClass(); - $sAggregationAttr = MetaModel::GetLabel($sClass, $sAggregationAttr); - } $iLimit = 0; if (isset($aExtraParams['limit'])) { $iLimit = intval($aExtraParams['limit']); @@ -636,10 +631,11 @@ class AjaxRenderController * @throws \MySQLHasGoneAwayException * @throws \OQLException */ - public static function RefreshCount(string $sFilter): array + public static function RefreshDashletCount(string $sFilter): array { $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $oFilter = DBObjectSearch::FromOQL($sFilter); + $oFilter->SetShowObsoleteData(utils::ShowObsoleteData()); $oSet = new CMDBObjectSet($oFilter, [], $aExtraParams); $iCount = $oSet->Count(); @@ -651,7 +647,6 @@ class AjaxRenderController /** * @param string $sFilter * - * @return string * @throws \ArchivedObjectException * @throws \CoreException * @throws \OQLException @@ -682,7 +677,6 @@ class AjaxRenderController /** * @param string $sFilter * - * @return string * @throws \ArchivedObjectException * @throws \CoreException * @throws \OQLException