diff options
author | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2020-07-28 16:26:19 +0300 |
---|---|---|
committer | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2020-07-28 16:26:19 +0300 |
commit | 402e72fb6df163a0df46686c80d4b3aa06406abf (patch) | |
tree | a884f5d904ef3e4e09426d03c140c2971b124b44 /ui/app/controllers | |
parent | b40564e9eb89c43bc81f4465eb862a6aabb6071f (diff) |
..F....... [ZBXNEXT-710] tab result counters php code
Diffstat (limited to 'ui/app/controllers')
-rw-r--r-- | ui/app/controllers/CControllerHost.php | 64 | ||||
-rw-r--r-- | ui/app/controllers/CControllerHostViewRefresh.php | 4 |
2 files changed, 64 insertions, 4 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php index dc9f63df700..d51fd4dc42f 100644 --- a/ui/app/controllers/CControllerHost.php +++ b/ui/app/controllers/CControllerHost.php @@ -68,8 +68,68 @@ abstract class CControllerHost extends CController { * @return int */ protected function getCount(array $filter) { - // TODO - return 1; + $child_groups = []; + + if ($filter['groupids']) { + $filter_groups = API::HostGroup()->get([ + 'output' => ['groupid', 'name'], + 'groupids' => $filter['groupids'], + 'preservekeys' => true + ]); + + if ($filter_groups) { + foreach ($filter_groups as $group) { + $child_groups[] = $group['name'].'/'; + } + } + else { + $filter['groupids'] = []; + } + } + + $groupids = null; + + if ($child_groups) { + $filter_groups += API::HostGroup()->get([ + 'output' => ['groupid'], + 'search' => ['name' => $child_groups], + 'startSearch' => true, + 'searchByAny' => true, + 'preservekeys' => true + ]); + + $groupids = array_keys($filter_groups); + } + + $config = select_config(); + + $count = API::Host()->get([ + 'output' => ['hostid', 'name', 'status'], + 'evaltype' => $filter['evaltype'], + 'tags' => $filter['tags'], + 'inheritedTags' => true, + 'groupids' => $groupids, + 'severities' => $filter['severities'] ? $filter['severities'] : null, + 'withProblemsSuppressed' => $filter['severities'] + ? (($filter['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE) ? null : false) + : null, + 'search' => [ + 'name' => ($filter['name'] === '') ? null : $filter['name'], + 'ip' => ($filter['ip'] === '') ? null : $filter['ip'], + 'dns' => ($filter['dns'] === '') ? null : $filter['dns'] + ], + 'filter' => [ + 'status' => ($filter['status'] == -1) ? null : $filter['status'], + 'port' => ($filter['port'] === '') ? null : $filter['port'], + 'maintenance_status' => ($filter['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) + ? null + : HOST_MAINTENANCE_STATUS_OFF, + ], + 'limit' => $config['search_limit'] + 1, + 'countOutput' => true + ]); + + return $count; } /** diff --git a/ui/app/controllers/CControllerHostViewRefresh.php b/ui/app/controllers/CControllerHostViewRefresh.php index 02a0b167a7f..4edf57b8697 100644 --- a/ui/app/controllers/CControllerHostViewRefresh.php +++ b/ui/app/controllers/CControllerHostViewRefresh.php @@ -94,8 +94,8 @@ class CControllerHostViewRefresh extends CControllerHost { $profile->setFilterDefaults(static::FILTER_FIELDS_DEFAULT); $show_counters = []; - foreach ($profile->getTabsWithDefaults() as $index => $filter) { - $show_counters[$index] = $filter['show_counter'] ? $this->getCount($filter) : 0; + foreach ($profile->getTabsWithDefaults() as $index => $tabfilter) { + $show_counters[$index] = $tabfilter['show_counter'] ? $this->getCount($tabfilter['filter']) : 0; } $data['filter_counters'] = $show_counters; |