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 0a3ff4fabb4..6689ea84e8c 100644 --- a/public/app/plugins/panel/alertlist/module.html +++ b/public/app/plugins/panel/alertlist/module.html @@ -1,42 +1,35 @@ -
-
-
    -
  1. -
    -
    -
    -

    - No alerts in selected interval -

    -
    -
    -
    -
  2. -
  3. -
    -
    -
    - -
    -
    -

    - - {{alert.name}} - -

    -

    - {{alert.stateModel.text}} - for {{alert.newStateDateAgo}} -

    -
    -
    -
    -
  4. -
-
+
+
+ {{ctrl.noAlertsMessage}} +
-
-
    +
    +
      +
    1. +
      +
      +
      + +
      +
      +

      + + {{alert.name}} + +

      +

      + {{alert.stateModel.text}} + for {{alert.newStateDateAgo}} +

      +
      +
      +
      +
    2. +
    +
    + +
    +
    1. @@ -53,7 +46,9 @@
    2. diff --git a/public/app/plugins/panel/alertlist/module.ts b/public/app/plugins/panel/alertlist/module.ts index d0b6ddc3db7..7aeb99c9918 100644 --- a/public/app/plugins/panel/alertlist/module.ts +++ b/public/app/plugins/panel/alertlist/module.ts @@ -3,7 +3,7 @@ import _ from 'lodash'; import moment from 'moment'; import alertDef from '../../../features/alerting/alert_def'; -import {PanelCtrl} from 'app/plugins/sdk'; +import { PanelCtrl } from 'app/plugins/sdk'; import * as dateMath from 'app/core/utils/datemath'; @@ -11,20 +11,20 @@ class AlertListPanel extends PanelCtrl { static templateUrl = 'module.html'; showOptions = [ - {text: 'Current state', value: 'current'}, - {text: 'Recent state changes', value: 'changes'} + { text: 'Current state', value: 'current' }, + { text: 'Recent state changes', value: 'changes' } ]; sortOrderOptions = [ - {text: 'Alphabetical (asc)', value: 1}, - {text: 'Alphabetical (desc)', value: 2}, - {text: 'Importance', value: 3}, + { text: 'Alphabetical (asc)', value: 1 }, + { text: 'Alphabetical (desc)', value: 2 }, + { text: 'Importance', value: 3 }, ]; - contentHeight: string; stateFilter: any = {}; currentAlerts: any = []; alertHistory: any = []; + noAlertsMessage: string; // Set and populate defaults panelDefaults = { show: 'current', @@ -40,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; @@ -53,7 +52,7 @@ class AlertListPanel extends PanelCtrl { return _.sortBy(alerts, a => { return alertDef.alertStateSortScore[a.state]; }); } - var result = _.sortBy(alerts, a => { return a.name.toLowerCase();}); + var result = _.sortBy(alerts, a => { return a.name.toLowerCase(); }); if (this.panel.sortOrder === 2) { result.reverse(); } @@ -71,11 +70,10 @@ class AlertListPanel extends PanelCtrl { } this.panel.stateFilter = result; - this.onRender(); + this.onRefresh(); } - onRender() { - this.contentHeight = "max-height: " + this.height + "px;"; + onRefresh() { if (this.panel.show === 'current') { this.getCurrentAlertState(); } @@ -107,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' : ''; }); } @@ -126,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); +} +