notifications_list_ctrl.ts 1.0 KB

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