Merge branch 'alertList-no-alerts'

This commit is contained in:
Torkel Ödegaard 2017-11-03 10:17:07 +01:00
commit f18de7e6a0
4 changed files with 60 additions and 56 deletions

View File

@ -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>

View File

@ -1,17 +1,10 @@
<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">
<li class="card-item-wrapper" ng-show="!ctrl.currentAlerts.length">
<div class="alert-list card-item card-item--alert">
<div class="alert-list-body">
<div class="alert-list-main">
<p class="alert-list-title">
No alerts in selected interval
</p>
</div>
</div>
</div>
</li>
<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">
@ -53,7 +46,9 @@
</div>
<div class="alert-list-footer">
<span class="alert-list-text">{{al.time}}</span>
<span class="alert-list-text"><!--Img Link--></span>
<span class="alert-list-text">
<!--Img Link-->
</span>
</div>
</div>
</li>

View File

@ -21,10 +21,10 @@ class AlertListPanel extends PanelCtrl {
{ 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;
@ -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' : '';
});
}

View File

@ -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);
}