| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- ///<reference path="../../headers/common.d.ts" />
- import angular from 'angular';
- import _ from 'lodash';
- import coreModule from '../../core/core_module';
- import config from 'app/core/config';
- export class AlertNotificationEditCtrl {
- model: any;
- /** @ngInject */
- constructor(private $routeParams, private backendSrv, private $scope, private $location) {
- if ($routeParams.id) {
- this.loadNotification($routeParams.id);
- } else {
- this.model = {
- type: 'email',
- settings: {}
- };
- }
- }
- loadNotification(id) {
- this.backendSrv.get(`/api/alert-notifications/${id}`).then(result => {
- this.model = result;
- });
- }
- isNew() {
- return this.model.id === undefined;
- }
- save() {
- if (this.model.id) {
- this.backendSrv.put(`/api/alert-notifications/${this.model.id}`, this.model).then(res => {
- this.model = res;
- });
- } else {
- this.backendSrv.post(`/api/alert-notifications`, this.model).then(res => {
- this.$location.path('alerting/notification/' + res.id + '/edit');
- });
- }
- }
- }
- coreModule.controller('AlertNotificationEditCtrl', AlertNotificationEditCtrl);
|