mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Types: Adds type safety to appEvents (#19418)
* Types: Add type safety to appEvents
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user