From cd95f5bcc20e77353ac28b0860546a60bb37b9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 3 Nov 2017 10:16:25 +0100 Subject: [PATCH] refactor: alert list panel fixes and no alerts message, rewrite of PR #9721 --- .../app/plugins/panel/alertlist/editor.html | 8 +-- .../app/plugins/panel/alertlist/module.html | 63 +++++++++---------- public/app/plugins/panel/alertlist/module.ts | 14 ++--- public/sass/components/_panel_alertlist.scss | 9 +++ public/sass/pages/_alerting.scss | 7 --- 5 files changed, 50 insertions(+), 51 deletions(-) diff --git a/public/app/plugins/panel/alertlist/editor.html b/public/app/plugins/panel/alertlist/editor.html index b8cee3b3317..36c989dd72c 100644 --- a/public/app/plugins/panel/alertlist/editor.html +++ b/public/app/plugins/panel/alertlist/editor.html @@ -4,22 +4,22 @@
Show
- +
Max items - +
Sort order
- +
-
+
State filter
diff --git a/public/app/plugins/panel/alertlist/module.html b/public/app/plugins/panel/alertlist/module.html index 0e3d93d90c8..6689ea84e8c 100644 --- a/public/app/plugins/panel/alertlist/module.html +++ b/public/app/plugins/panel/alertlist/module.html @@ -1,12 +1,11 @@ -
+
+
+ {{ctrl.noAlertsMessage}} +
+
    -
    -

    - No alerts in selected interval -

    -
    -
  1. +
  2. @@ -30,29 +29,29 @@
-
    -
  1. -
    -
    -
    - -
    -
    -

    {{al.alertName}}

    -
    - {{al.stateModel.text}} - {{al.info}} -
    -
    -
    - -
    -
  2. -
-
+
    +
  1. +
    +
    +
    + +
    +
    +

    {{al.alertName}}

    +
    + {{al.stateModel.text}} + {{al.info}} +
    +
    +
    + +
    +
  2. +
+
diff --git a/public/app/plugins/panel/alertlist/module.ts b/public/app/plugins/panel/alertlist/module.ts index 1109bda5677..7aeb99c9918 100644 --- a/public/app/plugins/panel/alertlist/module.ts +++ b/public/app/plugins/panel/alertlist/module.ts @@ -21,11 +21,10 @@ class AlertListPanel extends PanelCtrl { { text: 'Importance', value: 3 }, ]; - panelHeight: any; - contentHeight: string; stateFilter: any = {}; currentAlerts: any = []; alertHistory: any = []; + noAlertsMessage: string; // Set and populate defaults panelDefaults = { show: 'current', @@ -41,8 +40,7 @@ class AlertListPanel extends PanelCtrl { _.defaults(this.panel, this.panelDefaults); this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); - this.events.on('render', this.onRender.bind(this)); - this.events.on('refresh', this.onRender.bind(this)); + this.events.on('refresh', this.onRefresh.bind(this)); for (let key in this.panel.stateFilter) { this.stateFilter[this.panel.stateFilter[key]] = true; @@ -72,12 +70,10 @@ class AlertListPanel extends PanelCtrl { } this.panel.stateFilter = result; - this.onRender(); + this.onRefresh(); } - onRender() { - this.panelHeight = this.height - 30; - this.contentHeight = "max-height: " + this.height + "px;"; + onRefresh() { if (this.panel.show === 'current') { this.getCurrentAlertState(); } @@ -109,6 +105,7 @@ class AlertListPanel extends PanelCtrl { al.info = alertDef.getAlertAnnotationInfo(al); return al; }); + this.noAlertsMessage = this.alertHistory.length === 0 ? 'No alerts in current time range' : ''; }); } @@ -128,6 +125,7 @@ class AlertListPanel extends PanelCtrl { al.newStateDateAgo = moment(al.newStateDate).locale('en').fromNow(true); return al; })); + this.noAlertsMessage = this.currentAlerts.length === 0 ? 'No alerts' : ''; }); } diff --git a/public/sass/components/_panel_alertlist.scss b/public/sass/components/_panel_alertlist.scss index c8e8354f4d7..f124c0c4b8c 100644 --- a/public/sass/components/_panel_alertlist.scss +++ b/public/sass/components/_panel_alertlist.scss @@ -1,3 +1,12 @@ .panel-alert-list { overflow-y: auto; } + +.panel-alert-list__no-alerts { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: calc(100% - 30px); +} + diff --git a/public/sass/pages/_alerting.scss b/public/sass/pages/_alerting.scss index 5ebb88f1346..6db3470f3ea 100644 --- a/public/sass/pages/_alerting.scss +++ b/public/sass/pages/_alerting.scss @@ -91,13 +91,6 @@ align-items: flex-end; } -.alert-list-no-alerts { - display: flex; - align-items: center; - justify-content: center; - width: 100%; -} - .panel-has-alert { .panel-alert-icon:before { content: "\e611";