2017-12-20 12:33:33 +01:00
|
|
|
import { coreModule } from 'app/core/core';
|
2017-06-02 14:00:42 +02:00
|
|
|
|
|
|
|
|
export class AlertNotificationsListCtrl {
|
2016-06-16 14:29:20 +02:00
|
|
|
notifications: any;
|
2017-06-02 14:00:42 +02:00
|
|
|
navModel: any;
|
2016-06-15 10:48:04 +02:00
|
|
|
|
|
|
|
|
/** @ngInject */
|
2017-09-21 16:40:18 +02:00
|
|
|
constructor(private backendSrv, navModelSrv) {
|
2016-06-15 10:48:04 +02:00
|
|
|
this.loadNotifications();
|
2017-12-20 12:33:33 +01:00
|
|
|
this.navModel = navModelSrv.getNav('alerting', 'channels', 0);
|
2016-06-15 10:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadNotifications() {
|
2016-07-14 13:32:16 +02:00
|
|
|
this.backendSrv.get(`/api/alert-notifications`).then(result => {
|
2016-06-16 14:29:20 +02:00
|
|
|
this.notifications = result;
|
|
|
|
|
});
|
2016-06-15 10:48:04 +02:00
|
|
|
}
|
2016-06-16 15:21:44 +02:00
|
|
|
|
2016-07-25 16:26:28 +02:00
|
|
|
deleteNotification(id) {
|
|
|
|
|
this.backendSrv.delete(`/api/alert-notifications/${id}`).then(() => {
|
|
|
|
|
this.notifications = this.notifications.filter(notification => {
|
2016-07-27 10:15:21 +02:00
|
|
|
return notification.id !== id;
|
2016-06-16 15:21:44 +02:00
|
|
|
});
|
2016-07-25 16:26:28 +02:00
|
|
|
});
|
2016-06-16 15:21:44 +02:00
|
|
|
}
|
2016-06-15 10:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 12:33:33 +01:00
|
|
|
coreModule.controller('AlertNotificationsListCtrl', AlertNotificationsListCtrl);
|