notifications_list_ctrl.ts 791 B

1234567891011121314151617181920212223242526272829303132
  1. ///<reference path="../../headers/common.d.ts" />
  2. import {coreModule} from 'app/core/core';
  3. export class AlertNotificationsListCtrl {
  4. notifications: any;
  5. navModel: any;
  6. /** @ngInject */
  7. constructor(private backendSrv, navModelSrv) {
  8. this.loadNotifications();
  9. this.navModel = navModelSrv.getAlertingNav(1);
  10. }
  11. loadNotifications() {
  12. this.backendSrv.get(`/api/alert-notifications`).then(result => {
  13. this.notifications = result;
  14. });
  15. }
  16. deleteNotification(id) {
  17. this.backendSrv.delete(`/api/alert-notifications/${id}`).then(() => {
  18. this.notifications = this.notifications.filter(notification => {
  19. return notification.id !== id;
  20. });
  21. });
  22. }
  23. }
  24. coreModule.controller('AlertNotificationsListCtrl', AlertNotificationsListCtrl);