notifications_list_ctrl.ts 902 B

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