diff options
author | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2020-10-12 12:55:45 +0300 |
---|---|---|
committer | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2020-10-12 12:55:45 +0300 |
commit | 71f92a54451554983bbd42934a7c7a6bd771a133 (patch) | |
tree | fc516a096eaf9e67b7b6ea8676c8aa88fa896d9a /ui/app | |
parent | 2645c25a71b766b47aed0d3b9f177d57c966e61e (diff) |
..F....... [ZBXNEXT-710] fixed filter unsaved state on multiselect data changes between database data and user posted data; added filter_reset for monitoring host
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/controllers/CControllerHost.php | 6 | ||||
-rw-r--r-- | ui/app/controllers/CControllerHostView.php | 10 | ||||
-rw-r--r-- | ui/app/controllers/CControllerProblem.php | 4 | ||||
-rw-r--r-- | ui/app/controllers/CControllerProblemView.php | 14 |
4 files changed, 23 insertions, 11 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php index ac7020047c2..398163d2e0d 100644 --- a/ui/app/controllers/CControllerHost.php +++ b/ui/app/controllers/CControllerHost.php @@ -296,6 +296,10 @@ abstract class CControllerHost extends CController { * @return array */ protected function cleanInput(array $input): array { + if (array_key_exists('filter_reset', $input) && $input['filter_reset']) { + return array_intersect_key(['filter_name' => ''], $input); + } + if (array_key_exists('tags', $input) && $input['tags']) { $input['tags'] = array_filter($input['tags'], function($tag) { return !($tag['tag'] === '' && $tag['value'] === ''); @@ -303,8 +307,6 @@ abstract class CControllerHost extends CController { $input['tags'] = array_values($input['tags']); } - $input += ['severities' => []]; - return $input; } } diff --git a/ui/app/controllers/CControllerHostView.php b/ui/app/controllers/CControllerHostView.php index 8d7eb96df5c..d2a20f3d4c9 100644 --- a/ui/app/controllers/CControllerHostView.php +++ b/ui/app/controllers/CControllerHostView.php @@ -46,6 +46,7 @@ class CControllerHostView extends CControllerHost { 'filter_custom_time' => 'in 1,0', 'filter_show_counter' => 'in 1,0', 'filter_counters' => 'in 1', + 'filter_reset' => 'in 1', 'counter_index' => 'ge 0' ]; @@ -88,11 +89,16 @@ class CControllerHostView extends CControllerHost { ->read() ->setInput($this->cleanInput($this->getInputAll())); - foreach ($profile->getTabsWithDefaults() as $filter_tab) { + foreach ($profile->getTabsWithDefaults() as $index => $filter_tab) { + if ($index == $profile->selected) { + // Initialize multiselect data for filter_scr to allow tabfilter correctly handle unsaved state. + $filter_tab['filter_src']['filter_view_data'] = $this->getAdditionalData($filter_tab['filter_src']); + } + $filter_tabs[] = $filter_tab + ['filter_view_data' => $this->getAdditionalData($filter_tab)]; } - $filter = $profile->getTabFilter($profile->selected); + $filter = $filter_tabs[$profile->selected]; $refresh_curl = new CUrl('zabbix.php'); $filter['action'] = 'host.view.refresh'; array_map([$refresh_curl, 'setArgument'], array_keys($filter), $filter); diff --git a/ui/app/controllers/CControllerProblem.php b/ui/app/controllers/CControllerProblem.php index b3f523c6f92..73fbedfbbd2 100644 --- a/ui/app/controllers/CControllerProblem.php +++ b/ui/app/controllers/CControllerProblem.php @@ -156,6 +156,10 @@ abstract class CControllerProblem extends CController { * @return array */ protected function cleanInput(array $input): array { + if (array_key_exists('filter_reset', $input) && $input['filter_reset']) { + return array_intersect_key(['filter_name' => ''], $input); + } + if (array_key_exists('tags', $input) && $input['tags']) { $input['tags'] = array_filter($input['tags'], function($tag) { return !($tag['tag'] === '' && $tag['value'] === ''); diff --git a/ui/app/controllers/CControllerProblemView.php b/ui/app/controllers/CControllerProblemView.php index e6205e65b1b..31387c02230 100644 --- a/ui/app/controllers/CControllerProblemView.php +++ b/ui/app/controllers/CControllerProblemView.php @@ -105,21 +105,21 @@ class CControllerProblemView extends CControllerProblem { ->read() ->setInput($this->cleanInput($this->getInputAll())); - foreach ($profile->getTabsWithDefaults() as $filter_tab) { + foreach ($profile->getTabsWithDefaults() as $index => $filter_tab) { if ($filter_tab['filter_custom_time']) { $filter_tab['show'] = TRIGGERS_OPTION_ALL; $filter_tab['filter_src']['show'] = TRIGGERS_OPTION_ALL; } - $filter_tabs[] = $filter_tab + ['filter_view_data' => $this->getAdditionalData($filter_tab)]; - } - - $filter = $profile->getTabFilter($profile->selected); + if ($index == $profile->selected) { + // Initialize multiselect data for filter_scr to allow tabfilter correctly handle unsaved state. + $filter_tab['filter_src']['filter_view_data'] = $this->getAdditionalData($filter_tab['filter_src']); + } - if ($filter_tab['filter_custom_time']) { - $filter_tab['show'] = TRIGGERS_OPTION_ALL; + $filter_tabs[] = $filter_tab + ['filter_view_data' => $this->getAdditionalData($filter_tab)]; } + $filter = $filter_tabs[$profile->selected]; $refresh_curl = (new CUrl('zabbix.php')); $filter['action'] = 'problem.view.refresh'; array_map([$refresh_curl, 'setArgument'], array_keys($filter), $filter); |