feat(alerting): added clear history button to alert state history view, #6244

This commit is contained in:
Torkel Ödegaard
2016-10-14 09:33:16 +02:00
parent aeb0c5cb53
commit c9d7eb0a7a
9 changed files with 82 additions and 3 deletions

View File

@@ -59,7 +59,7 @@ export class AlertTabCtrl {
this.panelCtrl.render();
});
// build notification model
// build notification model
this.notifications = [];
this.alertNotifications = [];
this.alertHistory = [];
@@ -352,6 +352,24 @@ export class AlertTabCtrl {
this.evaluatorParamsChanged();
}
clearHistory() {
appEvents.emit('confirm-modal', {
title: 'Delete Alert History',
text: 'Are you sure you want to remove all history & annotations for this alert?',
icon: 'fa-trash',
yesText: 'Yes',
onConfirm: () => {
this.backendSrv.post('/api/annotations/mass-delete', {
dashboardId: this.panelCtrl.dashboard.id,
panelId: this.panel.id,
}).then(res => {
this.alertHistory = [];
this.panelCtrl.refresh();
});
}
});
}
test() {
this.testing = true;

View File

@@ -125,7 +125,16 @@
</div>
<div class="gf-form-group" style="max-width: 720px;" ng-if="ctrl.subTabIndex === 2">
<h5 class="section-heading">State history <span class="muted small">(last 50 state changes)</span></h5>
<button class="btn btn-mini btn-danger pull-right" ng-click="ctrl.clearHistory()"><i class="fa fa-trash"></i>&nbsp;Clear history</button>
<h5 class="section-heading" style="whitespace: nowrap">
State history <span class="muted small">(last 50 state changes)</span>
</h5>
<div ng-show="ctrl.alertHistory.length === 0">
<br>
<i>No state changes recorded</i>
</div>
<section class="card-section card-list-layout-list">
<ol class="card-list" >
<li class="card-item-wrapper" ng-repeat="ah in ctrl.alertHistory">

View File

@@ -392,17 +392,21 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
position: 'BOTTOM',
markerSize: 5,
};
types['$__ok'] = {
color: 'rgba(11, 237, 50, 1)',
position: 'BOTTOM',
markerSize: 5,
};
types['$__nodata'] = {
types['$__no_data'] = {
color: 'rgba(150, 150, 150, 1)',
position: 'BOTTOM',
markerSize: 5,
};
types['$__execution_error'] = ['$__no_data'];
for (var i = 0; i < annotations.length; i++) {
var item = annotations[i];
if (item.newState) {

View File

@@ -4,6 +4,10 @@
flex-direction: row;
}
.edit-tab-content {
flex-grow: 1;
}
.edit-sidemenu-aside {
width: 16rem;
}