diff options
-rw-r--r-- | ui/app/controllers/CControllerHost.php | 2 | ||||
-rw-r--r-- | ui/app/controllers/CControllerHostView.php | 8 | ||||
-rw-r--r-- | ui/app/controllers/CControllerHostViewRefresh.php | 2 | ||||
-rw-r--r-- | ui/app/controllers/CControllerTimeSelectorUpdate.php | 2 | ||||
-rw-r--r-- | ui/app/views/monitoring.host.view.php | 2 | ||||
-rw-r--r-- | ui/include/classes/html/CTabFilter.php | 31 | ||||
-rw-r--r-- | ui/js/class.tabfilter.js | 27 | ||||
-rw-r--r-- | ui/js/gtlc.js | 4 |
8 files changed, 50 insertions, 28 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php index 78ee6668272..cfec8b61cfd 100644 --- a/ui/app/controllers/CControllerHost.php +++ b/ui/app/controllers/CControllerHost.php @@ -41,8 +41,6 @@ abstract class CControllerHost extends CController { 'severities' => [], 'show_suppressed' => ZBX_PROBLEM_SUPPRESSED_FALSE, 'maintenance_status' => HOST_MAINTENANCE_STATUS_ON, - 'from' => 'now-1d', - 'to' => 'now', 'page' => null, 'sort' => 'name', 'sortorder' => ZBX_SORT_UP diff --git a/ui/app/controllers/CControllerHostView.php b/ui/app/controllers/CControllerHostView.php index cea6d0e2ebd..451c2943235 100644 --- a/ui/app/controllers/CControllerHostView.php +++ b/ui/app/controllers/CControllerHostView.php @@ -46,8 +46,12 @@ class CControllerHostView extends CControllerHostViewRefresh { 'refresh_interval' => CWebUser::getRefresh() * 1000, 'filter_view' => 'monitoring.host.filter', 'filter_defaults' => $profile->filter_defaults, - 'from' => $filter['from'], - 'to' => $filter['to'], + 'timerange' => [ + 'idx' => '', + 'idx2' => '', + 'from' => ZBX_PERIOD_DEFAULT_FROM, + 'to' => ZBX_PERIOD_DEFAULT_TO, + ], 'filter_tabs' => $filter_tabs, 'tab_selected' => $profile->selected, 'tab_expanded' => $profile->expanded diff --git a/ui/app/controllers/CControllerHostViewRefresh.php b/ui/app/controllers/CControllerHostViewRefresh.php index b6e1e819b87..f4894196386 100644 --- a/ui/app/controllers/CControllerHostViewRefresh.php +++ b/ui/app/controllers/CControllerHostViewRefresh.php @@ -45,8 +45,6 @@ class CControllerHostViewRefresh extends CControllerHost { 'sort' => 'in name,status', 'sortorder' => 'in '.ZBX_SORT_UP.','.ZBX_SORT_DOWN, 'page' => 'ge 1', - 'from' => 'string', - 'to' => 'string', 'filter_name' => 'string', 'filter_custom_time' => 'in 1,0', 'filter_show_counter' => 'in 1,0', diff --git a/ui/app/controllers/CControllerTimeSelectorUpdate.php b/ui/app/controllers/CControllerTimeSelectorUpdate.php index 6982010dbb1..7ad5d34038a 100644 --- a/ui/app/controllers/CControllerTimeSelectorUpdate.php +++ b/ui/app/controllers/CControllerTimeSelectorUpdate.php @@ -40,7 +40,7 @@ class CControllerTimeSelectorUpdate extends CController { protected function checkInput() { $profiles = ['web.dashbrd.filter', 'web.screens.filter', 'web.charts.filter', 'web.httpdetails.filter', 'web.problem.filter', 'web.auditlog.filter', 'web.slides.filter', 'web.auditacts.filter', - 'web.item.graph.filter', 'web.toptriggers.filter', 'web.avail_report.filter' + 'web.item.graph.filter', 'web.toptriggers.filter', 'web.avail_report.filter', CControllerHost::FILTER_IDX ]; $fields = [ diff --git a/ui/app/views/monitoring.host.view.php b/ui/app/views/monitoring.host.view.php index e7ba9e893dc..6f39427e666 100644 --- a/ui/app/views/monitoring.host.view.php +++ b/ui/app/views/monitoring.host.view.php @@ -56,7 +56,7 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { $filter->addTemplatedTab($tab['filter_name'], $tab); } - $filter->addTimeselector($data['from'], $data['to']); + $filter->addTimeselector($data['timerange']); // Set javascript options for tab filter initialization in monitoring.host.view.js.php file. $data['filter_options'] = $filter->options; diff --git a/ui/include/classes/html/CTabFilter.php b/ui/include/classes/html/CTabFilter.php index 419d6639249..2a0bd769c6c 100644 --- a/ui/include/classes/html/CTabFilter.php +++ b/ui/include/classes/html/CTabFilter.php @@ -183,19 +183,24 @@ class CTabFilter extends CDiv { /** * Add time range selector tab. Time range selcetor have static [data-target] equal 'tabfilter_timeselector'. * - * @param string $from Time range start. - * @param string $to Time range end. + * @param array $timerange Time range data array, array keys: from, to, idx, idx2 * @param string $date_format Date selector format. */ - public function addTimeselector($from, $to, $date_format = ZBX_FULL_DATE_TIME) { + public function addTimeselector(array $timerange, $date_format = ZBX_FULL_DATE_TIME) { $data = [ 'format' => $date_format, - 'label' => relativeDateToText($from, $to), - 'from' => $from, - 'to' => $to + 'label' => relativeDateToText($timerange['from'], $timerange['to']), + 'from' => $timerange['from'], + 'to' => $timerange['to'] ]; $content = (new CDiv(new CPartial('timeselector.filter', $data)))->setId(static::CSS_ID_PREFIX.'timeselector'); + $this + ->addClass('filter-space') + ->setAttribute('data-disable-initial-check', 1) + ->setAttribute('data-accessible', 1) + ->setAttribute('data-profile-idx', $timerange['idx']) + ->setAttribute('data-profile-idx2', $timerange['idx2']); return $this->addTab($data['label'], $content); } @@ -261,19 +266,19 @@ class CTabFilter extends CDiv { if ($timeselector) { $tab = $this->options['data'][$this->options['selected']] + ['filter_custom_time' => 0]; - $timeselector->addClass(( - $this->options['support_custom_time'] && !$tab['filter_custom_time']) ? null : ZBX_STYLE_DISABLED - ); + $enabled = ($this->options['support_custom_time'] && !$tab['filter_custom_time']); + $timeselector->addClass($enabled ? null : ZBX_STYLE_DISABLED); + $nav = array_merge($nav, [ - $timeselector, + $timeselector->addClass(ZBX_STYLE_BTN_TIME), (new CSimpleButton()) - ->setEnabled(false) + ->setEnabled($enabled) ->addClass(ZBX_STYLE_BTN_TIME_LEFT), (new CSimpleButton(_('Zoom out'))) - ->setEnabled(false) + ->setEnabled($enabled) ->addClass(ZBX_STYLE_BTN_TIME_OUT), (new CSimpleButton()) - ->setEnabled(false) + ->setEnabled($enabled) ->addClass(ZBX_STYLE_BTN_TIME_RIGHT) ]); } diff --git a/ui/js/class.tabfilter.js b/ui/js/class.tabfilter.js index da831c4c12a..b3c1628ec68 100644 --- a/ui/js/class.tabfilter.js +++ b/ui/js/class.tabfilter.js @@ -89,9 +89,7 @@ class CTabFilter extends CBaseComponent { } if (this._active_item != this._timeselector) { - this._timeselector.setDisabled( - !this._options.support_custom_time || this._active_item.hasCustomTime() - ); + this.updateTimeselector(); } } }, @@ -156,9 +154,7 @@ class CTabFilter extends CBaseComponent { */ updateItem: (ev) => { if (this._active_item != this._timeselector) { - this._timeselector.setDisabled( - !this._options.support_custom_time || this._active_item.hasCustomTime() - ); + this.updateTimeselector(); } }, @@ -343,6 +339,25 @@ class CTabFilter extends CBaseComponent { } /** + * Update timeselector tab and timeselector buttons accessibility according active item. + */ + updateTimeselector() { + let disabled = !this._options.support_custom_time || this._active_item.hasCustomTime(), + buttons = this._target.querySelectorAll('button.btn-time-left,button.btn-time-out,button.btn-time-right'); + + this._timeselector.setDisabled(disabled); + + for (const button of buttons) { + if (disabled) { + button.setAttribute('disabled', 'disabled'); + } + else { + button.removeAttribute('disabled'); + } + } + } + + /** * Updates filter values in user profile. Aborts any previous unfinished updates. * * @param {string} property Filter property to be updated: 'selected', 'expanded', 'properties'. diff --git a/ui/js/gtlc.js b/ui/js/gtlc.js index 9e12817c5a7..fbfdf310eb3 100644 --- a/ui/js/gtlc.js +++ b/ui/js/gtlc.js @@ -490,7 +490,9 @@ jQuery(function($) { }); } - checkDisableTimeSelectorUI(); + if (!$container.data('disable-initial-check')) { + checkDisableTimeSelectorUI(); + } }); /** |