From 7b70e0ff3a7d7ccd83cd0f8298c3576742e67ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Oct 2016 09:51:43 +0200 Subject: [PATCH] fix(UI): fixed 3 UI bugs, fixes #6225 --- .../app/features/alerting/alert_tab_ctrl.ts | 1 + public/app/features/dashboard/viewStateSrv.js | 5 +++- public/app/features/panel/panel_directive.ts | 30 +++++++++++++++---- public/app/features/panel/panel_menu.js | 3 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/public/app/features/alerting/alert_tab_ctrl.ts b/public/app/features/alerting/alert_tab_ctrl.ts index 0ea5d5fd804..f57ebe2d89e 100644 --- a/public/app/features/alerting/alert_tab_ctrl.ts +++ b/public/app/features/alerting/alert_tab_ctrl.ts @@ -315,6 +315,7 @@ export class AlertTabCtrl { this.alert = null; this.panel.thresholds = []; this.conditionModels = []; + this.panelCtrl.alertState = null; this.panelCtrl.render(); } }); diff --git a/public/app/features/dashboard/viewStateSrv.js b/public/app/features/dashboard/viewStateSrv.js index 73f0c038c7f..6cf3afc5463 100644 --- a/public/app/features/dashboard/viewStateSrv.js +++ b/public/app/features/dashboard/viewStateSrv.js @@ -83,6 +83,9 @@ function (angular, _, $) { }; DashboardViewState.prototype.update = function(state) { + // remember if editStateChanged + this.editStateChanged = state.edit !== this.state.edit; + _.extend(this.state, state); this.dashboard.meta.fullscreen = this.state.fullscreen; @@ -115,7 +118,7 @@ function (angular, _, $) { if (this.fullscreenPanel) { // if already fullscreen - if (this.fullscreenPanel === panelScope) { + if (this.fullscreenPanel === panelScope && this.editStateChanged === false) { return; } else { this.leaveFullscreen(false); diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index 4f020fd29b4..be8e2df42e4 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -68,21 +68,39 @@ module.directive('grafanaPanel', function() { // the reason for handling these classes this way is for performance // limit the watchers on panels etc + var transparentLastState; + var lastHasAlertRule; + var lastAlertState; + var hasAlertRule; ctrl.events.on('render', () => { - panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true); - panelContainer.toggleClass('panel-has-alert', ctrl.panel.alert !== undefined); - - if (panelContainer.hasClass('panel-has-alert')) { - panelContainer.removeClass('panel-alert-state--ok panel-alert-state--alerting'); + if (transparentLastState !== ctrl.panel.transparent) { + panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true); + transparentLastState = ctrl.panel.transparent; + } + + hasAlertRule = ctrl.panel.alert !== undefined; + if (lastHasAlertRule !== hasAlertRule) { + panelContainer.toggleClass('panel-has-alert', hasAlertRule); + + lastHasAlertRule = hasAlertRule; } - // set special class for ok, or alerting states if (ctrl.alertState) { + if (lastAlertState) { + panelContainer.removeClass('panel-alert-state--' + lastAlertState); + } + if (ctrl.alertState.state === 'ok' || ctrl.alertState.state === 'alerting') { panelContainer.addClass('panel-alert-state--' + ctrl.alertState.state); } + + lastAlertState = ctrl.alertState.state; + } else if (lastAlertState) { + panelContainer.removeClass('panel-alert-state--' + lastAlertState); + lastAlertState = null; } + }); scope.$watchGroup(['ctrl.fullscreen', 'ctrl.containerHeight'], function() { diff --git a/public/app/features/panel/panel_menu.js b/public/app/features/panel/panel_menu.js index 6f0c3f64d96..bf420f7dc15 100644 --- a/public/app/features/panel/panel_menu.js +++ b/public/app/features/panel/panel_menu.js @@ -88,7 +88,8 @@ function (angular, $, _, Tether) { $scope.$watchCollection('ctrl.panel.links', function(newValue) { var showIcon = (newValue ? newValue.length > 0 : false) && ctrl.panel.title !== ''; - $panelLinksBtn.toggle(showIcon); + // cannot use toggle here, only works for attached elements + $panelLinksBtn.css({display: showIcon ? 'inline' : 'none'}); }); function dismiss(time, force) {