in web-app/src/app/routes/setting/status/status.component.ts [332:398]
onIncidentModalOk() {
if (this.statusOrg.id == undefined) {
this.notifySvc.warning(this.i18nSvc.fanyi('status.component.notify.need-org'), '');
return;
}
if (this.incidentForm.invalid) {
Object.values(this.incidentForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
return;
}
// incident message content
if (this.currentStatusIncident.contents == undefined) {
this.currentStatusIncident.contents = [];
}
this.currentIncidentContent.timestamp = new Date().getTime();
this.currentIncidentContent.state = this.currentStatusIncident.state;
this.currentIncidentContent.incidentId = this.currentStatusIncident.id;
this.currentStatusIncident.contents.push(this.currentIncidentContent);
// components check options
let components: StatusPageComponent[] = [];
this.currentIncidentComponentOptions.forEach(item => {
if (item.checked) {
components.push(item.value);
}
});
this.currentStatusIncident.components = components;
this.currentStatusIncident.orgId = this.statusOrg.id;
if (this.isIncidentModalAdd) {
this.statusPageService.newStatusPageIncident(this.currentStatusIncident).subscribe(
(message: Message<void>) => {
if (message.code === 0) {
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
this.onIncidentModalCancel();
this.syncIncidence();
} else {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg);
this.onIncidentModalCancel();
}
},
error => {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg);
this.onIncidentModalCancel();
}
);
} else {
this.statusPageService.editStatusPageIncident(this.currentStatusIncident).subscribe(
(message: Message<void>) => {
if (message.code === 0) {
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), '');
this.onIncidentModalCancel();
this.syncIncidence();
} else {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg);
this.onIncidentModalCancel();
}
},
error => {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg);
this.onIncidentModalCancel();
}
);
}
}