NotificationsListCtrl.ts 875 B

1234567891011121314151617181920212223242526272829
  1. import { coreModule, NavModelSrv } from 'app/core/core';
  2. import { BackendSrv } from 'app/core/services/backend_srv';
  3. export class AlertNotificationsListCtrl {
  4. notifications: any;
  5. navModel: any;
  6. /** @ngInject */
  7. constructor(private backendSrv: BackendSrv, navModelSrv: NavModelSrv) {
  8. this.loadNotifications();
  9. this.navModel = navModelSrv.getNav('alerting', 'channels', 0);
  10. }
  11. loadNotifications() {
  12. this.backendSrv.get(`/api/alert-notifications`).then((result: any) => {
  13. this.notifications = result;
  14. });
  15. }
  16. deleteNotification(id: number) {
  17. this.backendSrv.delete(`/api/alert-notifications/${id}`).then(() => {
  18. this.notifications = this.notifications.filter((notification: any) => {
  19. return notification.id !== id;
  20. });
  21. });
  22. }
  23. }
  24. coreModule.controller('AlertNotificationsListCtrl', AlertNotificationsListCtrl);