diff options
-rw-r--r-- | ui/app/controllers/CControllerHost.php | 2 | ||||
-rw-r--r-- | ui/app/controllers/CControllerProblem.php | 4 | ||||
-rw-r--r-- | ui/app/views/js/monitoring.host.view.js.php | 25 | ||||
-rw-r--r-- | ui/app/views/monitoring.host.view.php | 3 | ||||
-rw-r--r-- | ui/include/classes/services/CTabFilterProfile.php | 10 |
5 files changed, 31 insertions, 13 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php index 6d6b5f874bd..f07dbe47801 100644 --- a/ui/app/controllers/CControllerHost.php +++ b/ui/app/controllers/CControllerHost.php @@ -362,7 +362,7 @@ abstract class CControllerHost extends CController { * @return array */ protected function cleanInput(array $input): array { - if ($input['tags']) { + 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/CControllerProblem.php b/ui/app/controllers/CControllerProblem.php index b86ef23eca0..bdb69d39a91 100644 --- a/ui/app/controllers/CControllerProblem.php +++ b/ui/app/controllers/CControllerProblem.php @@ -153,13 +153,13 @@ abstract class CControllerProblem extends CController { * @return array */ protected function cleanInput(array $input): array { - if ($input['tags']) { + if (array_key_exists('tags', $input) && $input['tags']) { $input['tags'] = array_filter($input['tags'], function($tag) { return $tag['tag'] !== '' && $tag['value'] !== ''; }); } - if ($input['inventory']) { + if (array_key_exists('inventory', $input) && $input['inventory']) { $input['inventory'] = array_filter($input['inventory'], function($inventory) { return $inventory['value'] !== ''; }); diff --git a/ui/app/views/js/monitoring.host.view.js.php b/ui/app/views/js/monitoring.host.view.js.php index ffe2adcbda2..68ee7899fdc 100644 --- a/ui/app/views/js/monitoring.host.view.js.php +++ b/ui/app/views/js/monitoring.host.view.js.php @@ -26,20 +26,25 @@ <script type="text/javascript"> jQuery(function($) { function hostPage() { + let filter_options = <?= json_encode($data['filter_options']) ?>; + this.refresh_url = '<?= $data['refresh_url'] ?>'; this.refresh_interval = <?= $data['refresh_interval'] ?>; this.running = false; this.timeout = null; - this.refresh_counters = this.createCountersRefresh(1); - this.filter = new CTabFilter($('#monitoring_hosts_filter')[0], <?= json_encode($data['filter_options']) ?>); - this.filter.on(TABFILTER_EVENT_URLSET, (ev) => { - let url = new Curl('', false); - - url.setArgument('action', 'host.view.refresh'); - this.refresh_url = url.getUrl(); - this.stop(); - this.start(); - }); + + if (filter_options) { + this.refresh_counters = this.createCountersRefresh(1); + this.filter = new CTabFilter($('#monitoring_hosts_filter')[0], filter_options); + this.filter.on(TABFILTER_EVENT_URLSET, (ev) => { + let url = new Curl('', false); + + url.setArgument('action', 'host.view.refresh'); + this.refresh_url = url.getUrl(); + this.stop(); + this.start(); + }); + } } hostPage.prototype = { diff --git a/ui/app/views/monitoring.host.view.php b/ui/app/views/monitoring.host.view.php index 18932cd71af..0c13e605124 100644 --- a/ui/app/views/monitoring.host.view.php +++ b/ui/app/views/monitoring.host.view.php @@ -60,6 +60,9 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { $data['filter_options'] = $filter->options; $widget->addItem($filter); } +else { + $data['filter_options'] = null; +} $widget->addItem((new CForm())->setName('host_view')->addClass('is-loading')); $widget->show(); diff --git a/ui/include/classes/services/CTabFilterProfile.php b/ui/include/classes/services/CTabFilterProfile.php index b05218c0436..34a3b14bb7b 100644 --- a/ui/include/classes/services/CTabFilterProfile.php +++ b/ui/include/classes/services/CTabFilterProfile.php @@ -71,6 +71,11 @@ class CTabFilterProfile { */ public $filter_defaults; + /** + * Is selected tab modified by user input. + */ + public $modified = false; + public function __construct($idx, array $filter_defaults) { $this->namespace = $idx; $this->tabfilters = []; @@ -180,6 +185,11 @@ class CTabFilterProfile { unset($input['filter_name']); } + $this->modified = array_diff_assoc( + array_map('serialize', CArrayHelper::unsetEqualValues($input, $this->filter_defaults)), + array_map('serialize', $this->tabfilters[$this->selected]) + ); + $input += $this->filter_defaults; $input['filter_show_counter'] = (int) $input['filter_show_counter']; $input['filter_custom_time'] = (int) $input['filter_custom_time']; |