Types: Adds type safety to appEvents (#19418)

* Types: Add type safety to appEvents
This commit is contained in:
kay delaney
2019-10-14 09:27:47 +01:00
committed by GitHub
parent e7c37cc316
commit 99411bf37a
138 changed files with 991 additions and 508 deletions

View File

@@ -1,6 +1,7 @@
import _ from 'lodash';
import { appEvents, coreModule, NavModelSrv } from 'app/core/core';
import { BackendSrv } from 'app/core/services/backend_srv';
import { AppEvents } from '@grafana/data';
export class AlertNotificationEditCtrl {
theForm: any;
@@ -78,23 +79,23 @@ export class AlertNotificationEditCtrl {
.put(`/api/alert-notifications/${this.model.id}`, this.model)
.then((res: any) => {
this.model = res;
appEvents.emit('alert-success', ['Notification updated', '']);
appEvents.emit(AppEvents.alertSuccess, ['Notification updated']);
})
.catch((err: any) => {
if (err.data && err.data.error) {
appEvents.emit('alert-error', [err.data.error]);
appEvents.emit(AppEvents.alertError, [err.data.error]);
}
});
} else {
this.backendSrv
.post(`/api/alert-notifications`, this.model)
.then((res: any) => {
appEvents.emit('alert-success', ['Notification created', '']);
appEvents.emit(AppEvents.alertSuccess, ['Notification created']);
this.$location.path('alerting/notifications');
})
.catch((err: any) => {
if (err.data && err.data.error) {
appEvents.emit('alert-error', [err.data.error]);
appEvents.emit(AppEvents.alertError, [err.data.error]);
}
});
}