From fa0201d8799b06402e168a003ef385272203c557 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Thu, 14 Sep 2023 06:28:54 +0000 Subject: [PATCH] * Display table header without data,bug#38536. --- module/metric/ui/viewphpmetric.html.php | 2 +- module/metric/zen.php | 65 +++---------------------- 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/module/metric/ui/viewphpmetric.html.php b/module/metric/ui/viewphpmetric.html.php index e6c06a26e6..c3c026fafb 100644 --- a/module/metric/ui/viewphpmetric.html.php +++ b/module/metric/ui/viewphpmetric.html.php @@ -79,7 +79,7 @@ detailHeader $fnGenerateDataDisplay = function() use($resultData, $resultHeader, $lang, $metric) { - if(empty($resultData)) return null; + if(empty($resultData)) $resultData = array($resultData); if(count($resultData) == 1 && count((array)$resultData[0]) == 1) return div ( set::className('card-data'), diff --git a/module/metric/zen.php b/module/metric/zen.php index c6cb9e7a52..46cf6f49d7 100644 --- a/module/metric/zen.php +++ b/module/metric/zen.php @@ -324,7 +324,11 @@ class metricZen extends metric */ protected function getViewTableHeader($result) { - if(empty($result)) return false; + if(empty($result)) return array + ( + array('name' => 'value', 'title' => $this->lang->metric->value), + array('name' => 'calcTime', 'title' => $this->lang->metric->calcTime, 'width' => 150) + ); $fieldList = array_keys((array)current($result)); $scopeList = array_intersect($fieldList, $this->config->metric->scopeList); @@ -340,33 +344,6 @@ class metricZen extends metric return $header; } - /** - * 获取度量数据表的表头。 - * Get header of result table. - * - * @param array $result - * @access protected - * @return array|false - */ - protected function getResultTableHeader($result) - { - if(empty($result)) return false; - - $header = array(); - $fieldList = array_keys(current($result)); - $scopeList = array_keys($this->lang->metric->scopeList); - $dateList = array_keys($this->lang->metric->dateList); - - foreach($fieldList as $field) - { - if(in_array($field, $scopeList)) $header[] = array('name' => $field, 'title' => $this->lang->metric->scopeList[$field]); - if(in_array($field, $dateList)) $header[] = array('name' => $field, 'title' => $this->lang->metric->dateList[$field]); - if($field == 'value') $header[] = array('name' => 'value', 'title' => $this->lang->metric->value); - } - - return $header; - } - /** * 获取度量数据表的数据。 * Get data of result table. @@ -379,7 +356,7 @@ class metricZen extends metric protected function getViewTableData($metric, $result) { $scope = $metric->scope; - if(empty($result)) return false; + if(empty($result)) return array(); if($metric->scope != 'system') $objectPairs = $this->metric->getPairsByScope($scope); @@ -402,36 +379,6 @@ class metricZen extends metric return $tableData; } - /** - * 获取度量数据表的数据。 - * Get data of result table. - * - * @param object $metric - * @param array $result - * @access protected - * @return array|false - */ - protected function getResultTableData($metric, $result) - { - $scope = $metric->scope; - if(empty($result)) return false; - - if($metric->scope != 'system') $objectPairs = $this->metric->getPairsByScope($scope); - - foreach($result as $record) - { - $fieldList = array_keys($record); - - $row = new stdclass(); - if($scope != 'system') $row->$scope = $objectPairs[$record[$scope]]; - $row->value = $record['value']; - - $tableData[] = $row; - } - - return $tableData; - } - /** * 根据后台配置的估算单位对列表赋值。 * Assign unitList['measure'] by custom hourPoint.