Commit cd95f5bc by Torkel Ödegaard

refactor: alert list panel fixes and no alerts message, rewrite of PR #9721

parent a433698d
......@@ -4,22 +4,22 @@
<div class="gf-form">
<span class="gf-form-label width-8">Show</span>
<div class="gf-form-select-wrapper max-width-15">
<select class="gf-form-input" ng-model="ctrl.panel.show" ng-options="f.value as f.text for f in ctrl.showOptions" ng-change="ctrl.onRender()"></select>
<select class="gf-form-input" ng-model="ctrl.panel.show" ng-options="f.value as f.text for f in ctrl.showOptions" ng-change="ctrl.onRefresh()"></select>
</div>
</div>
<div class="gf-form">
<span class="gf-form-label width-8">Max items</span>
<input type="text" class="gf-form-input max-width-15" ng-model="ctrl.panel.limit" ng-change="ctrl.onRender()" />
<input type="text" class="gf-form-input max-width-15" ng-model="ctrl.panel.limit" ng-change="ctrl.onRefresh()" />
</div>
<div class="gf-form" ng-show="ctrl.panel.show === 'current'">
<span class="gf-form-label width-8">Sort order</span>
<div class="gf-form-select-wrapper max-width-15">
<select class="gf-form-input" ng-model="ctrl.panel.sortOrder" ng-options="f.value as f.text for f in ctrl.sortOrderOptions" ng-change="ctrl.onRender()"></select>
<select class="gf-form-input" ng-model="ctrl.panel.sortOrder" ng-options="f.value as f.text for f in ctrl.sortOrderOptions" ng-change="ctrl.onRefresh()"></select>
</div>
</div>
<gf-form-switch class="gf-form" label="Alerts from this dashboard" label-class="width-18" checked="ctrl.panel.onlyAlertsOnDashboard" on-change="ctrl.updateStateFilter()"></gf-form-switch>
</div>
<div class="section gf-form-group">
<div class="section gf-form-group" ng-show="ctrl.panel.show === 'current'">
<h5 class="section-heading">State filter</h5>
<gf-form-switch class="gf-form" label="Ok" label-class="width-10" checked="ctrl.stateFilter['ok']" on-change="ctrl.updateStateFilter()"></gf-form-switch>
<gf-form-switch class="gf-form" label="Paused" label-class="width-10" checked="ctrl.stateFilter['paused']" on-change="ctrl.updateStateFilter()"></gf-form-switch>
......
<div class="panel-alert-list" style="{{ctrl.contentHeight}}">
<div class="panel-alert-list" ng-style="{height: ctrl.height + 'px'}">
<div class="panel-alert-list__no-alerts" ng-show="ctrl.noAlertsMessage">
{{ctrl.noAlertsMessage}}
</div>
<section class="card-section card-list-layout-list" ng-if="ctrl.panel.show === 'current'">
<ol class="card-list">
<div class="alert-list-no-alerts" ng-style="{'height': + ctrl.panelHeight + 'px'}" ng-show="!ctrl.currentAlerts.length">
<p class="alert-list-title">
No alerts in selected interval
</p>
</div>
<li class="card-item-wrapper" ng-repeat="alert in ctrl.currentAlerts">
<li class="card-item-wrapper" ng-repeat="alert in ctrl.currentAlerts">
<div class="alert-list card-item card-item--alert">
<div class="alert-list-body">
<div class="alert-list-icon alert-list-item-state {{alert.stateModel.stateClass}}">
......@@ -30,29 +29,29 @@
</section>
<section class="card-section card-list-layout-list" ng-if="ctrl.panel.show === 'changes'">
<ol class="card-list">
<li class="card-item-wrapper" ng-repeat="al in ctrl.alertHistory">
<div class="alert-list card-item card-item--alert">
<div class="alert-list-body">
<div class="alert-list-icon alert-list-item-state {{al.stateModel.stateClass}}">
<i class="{{al.stateModel.iconClass}}"></i>
</div>
<div class="alert-list-main">
<p class="alert-list-title">{{al.alertName}}</p>
<div class="alert-list-text">
<span class="alert-list-state {{al.stateModel.stateClass}}">{{al.stateModel.text}}</span>
<span class="alert-list-info alert-list-info-left">{{al.info}}</span>
</div>
</div>
</div>
<div class="alert-list-footer">
<span class="alert-list-text">{{al.time}}</span>
<span class="alert-list-text">
<!--Img Link-->
</span>
</div>
</div>
</li>
</ol>
</section>
<ol class="card-list">
<li class="card-item-wrapper" ng-repeat="al in ctrl.alertHistory">
<div class="alert-list card-item card-item--alert">
<div class="alert-list-body">
<div class="alert-list-icon alert-list-item-state {{al.stateModel.stateClass}}">
<i class="{{al.stateModel.iconClass}}"></i>
</div>
<div class="alert-list-main">
<p class="alert-list-title">{{al.alertName}}</p>
<div class="alert-list-text">
<span class="alert-list-state {{al.stateModel.stateClass}}">{{al.stateModel.text}}</span>
<span class="alert-list-info alert-list-info-left">{{al.info}}</span>
</div>
</div>
</div>
<div class="alert-list-footer">
<span class="alert-list-text">{{al.time}}</span>
<span class="alert-list-text">
<!--Img Link-->
</span>
</div>
</div>
</li>
</ol>
</section>
</div>
......@@ -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' : '';
});
}
......
.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);
}
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment