|
@@ -142,7 +142,9 @@ export class AlertTabCtrl {
|
|
|
isDefault: false,
|
|
isDefault: false,
|
|
|
uid: model.uid
|
|
uid: model.uid
|
|
|
});
|
|
});
|
|
|
- if (!_.find(this.alert.notifications, { id: model.id})) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // avoid duplicates using both id and uid to be backwards compatible.
|
|
|
|
|
+ if (!_.find(this.alert.notifications, n => n.id === model.id || n.uid === model.uid)) {
|
|
|
this.alert.notifications.push({ uid: model.uid });
|
|
this.alert.notifications.push({ uid: model.uid });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -152,9 +154,11 @@ export class AlertTabCtrl {
|
|
|
this.addNotificationSegment.fake = true;
|
|
this.addNotificationSegment.fake = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- removeNotification(deleteUid) {
|
|
|
|
|
- _.remove(this.alert.notifications, { uid: deleteUid});
|
|
|
|
|
- _.remove(this.alertNotifications, { uid: deleteUid});
|
|
|
|
|
|
|
+ removeNotification(an) {
|
|
|
|
|
+ // remove notifiers refeered to by id and uid to support notifiers added
|
|
|
|
|
+ // before and after we added support for uid
|
|
|
|
|
+ _.remove(this.alert.notifications, n => n.uid === an.uid || n.id === an.id);
|
|
|
|
|
+ _.remove(this.alertNotifications, n => n.uid === an.uid || n.id === an.id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
initModel() {
|
|
initModel() {
|
|
@@ -190,7 +194,14 @@ export class AlertTabCtrl {
|
|
|
ThresholdMapper.alertToGraphThresholds(this.panel);
|
|
ThresholdMapper.alertToGraphThresholds(this.panel);
|
|
|
|
|
|
|
|
for (const addedNotification of alert.notifications) {
|
|
for (const addedNotification of alert.notifications) {
|
|
|
- const model = _.find(this.notifications, { id: addedNotification.id });
|
|
|
|
|
|
|
+ // lookup notifier type by uid
|
|
|
|
|
+ let model = _.find(this.notifications, { uid: addedNotification.uid });
|
|
|
|
|
+
|
|
|
|
|
+ // fallback to using id if uid is missing
|
|
|
|
|
+ if (!model) {
|
|
|
|
|
+ model = _.find(this.notifications, { id: addedNotification.id });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (model && model.isDefault === false) {
|
|
if (model && model.isDefault === false) {
|
|
|
model.iconClass = this.getNotificationIcon(model.type);
|
|
model.iconClass = this.getNotificationIcon(model.type);
|
|
|
this.alertNotifications.push(model);
|
|
this.alertNotifications.push(model);
|