in web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts [467:521]
editAlertDefine(alertDefineId: number) {
if (this.isLoadingEdit !== -1) return;
this.isLoadingEdit = alertDefineId;
this.isManageModalAdd = false;
this.isManageModalOkLoading = false;
const getDefine$ = this.alertDefineSvc
.getAlertDefine(alertDefineId)
.pipe(
finalize(() => {
getDefine$.unsubscribe();
this.isLoadingEdit = -1;
this.isManageModalVisible = true;
})
)
.subscribe(
message => {
if (message.code === 0) {
this.define = message.data;
if (this.define.labels && this.define.labels['severity']) {
this.severity = this.define.labels['severity'];
}
// Set default period for periodic alert if not set
if (this.define.type === 'periodic' && !this.define.period) {
this.define.period = 300;
}
// Set default type as realtime if not set
if (!this.define.type) {
this.define.type = 'realtime';
}
if (this.define.type == 'realtime') {
// Parse expression to cascade values
this.cascadeValues = this.exprToCascadeValues(this.define.expr);
this.userExpr = this.exprToUserExpr(this.define.expr);
this.parseMonitorIdsFromExpr(this.define.expr);
this.parseLabelFromExpr(this.define.expr);
this.cascadeOnChange(this.cascadeValues);
// Wait for cascade values to be set
setTimeout(() => {
if (this.cascadeValues[1] === 'availability') {
this.isExpr = false;
} else {
this.tryParseThresholdExpr(this.userExpr);
}
});
}
} else {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.query-fail'), message.msg);
}
},
error => {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.query-fail'), error.msg);
}
);
}