From ae709351ce22cd957114429398b5930a576f9f63 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Wed, 1 Feb 2023 20:00:47 +0200 Subject: [PATCH] UI for alarm comment notification rule trigger --- .../rule-notification-dialog.component.html | 17 ++++++++++++ .../rule-notification-dialog.component.ts | 26 ++++++++++++++++--- .../app/shared/models/notification.models.ts | 17 +++++++++--- .../assets/locale/locale.constant-en_US.json | 10 ++++--- 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html index 055cf71ffc..15891ebd82 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html @@ -231,6 +231,23 @@ + + + {{ 'notification.alarm-comment-trigger-settings' | translate }} +
+ + + + notification.description + + +
+
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts index cfc64144df..77f1d23fd6 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts @@ -71,6 +71,7 @@ export class RuleNotificationDialogComponent extends alarmTemplateForm: FormGroup; deviceInactivityTemplateForm: FormGroup; entityActionTemplateForm: FormGroup; + alarmCommentTemplateForm: FormGroup; triggerType = TriggerType; triggerTypes: TriggerType[] = Object.values(TriggerType); @@ -181,6 +182,11 @@ export class RuleNotificationDialogComponent extends description: [''] }); + this.alarmCommentTemplateForm = this.fb.group({ + targets: [[], Validators.required], + description: [''] + }); + this.filteredDisplaySeverities = this.severityInputChange .pipe( startWith(''), @@ -220,12 +226,18 @@ export class RuleNotificationDialogComponent extends description: this.ruleNotification.additionalConfig.description }, {emitEvent: false}); this.deviceInactivityTemplateForm.get('filterByDevice').updateValueAndValidity({onlySelf: true}); - } else { + } else if (this.ruleNotification.triggerType === TriggerType.ENTITY_ACTION) { this.entityActionTemplateForm.patchValue({ targets: this.ruleNotification.recipientsConfig.targets, description: this.ruleNotification.additionalConfig.description, ...this.ruleNotification.triggerConfig }, {emitEvent: false}); + } else if (this.ruleNotification.triggerType === TriggerType.ALARM_COMMENT) { + this.alarmCommentTemplateForm.patchValue({ + targets: this.ruleNotification.recipientsConfig.targets, + description: this.ruleNotification.additionalConfig.description, + ...this.ruleNotification.triggerConfig + }, {emitEvent: false}); } } } @@ -365,6 +377,9 @@ export class RuleNotificationDialogComponent extends if (this.selectedIndex === 3 && this.selectedIndex < this.maxStepperIndex && this.entityActionTemplateForm.pristine) { return 'action.skip'; } + if (this.selectedIndex === 4 && this.selectedIndex < this.maxStepperIndex && this.alarmCommentTemplateForm.pristine) { + return 'action.skip'; + } if (this.selectedIndex !== 0 && this.selectedIndex >= this.maxStepperIndex) { return (this.data.isAdd || this.data.isCopy) ? 'action.add' : 'action.save'; } @@ -393,12 +408,17 @@ export class RuleNotificationDialogComponent extends formValue.recipientsConfig.targets = this.deviceInactivityTemplateForm.get('targets').value; formValue.additionalConfig.description = this.deviceInactivityTemplateForm.get('description').value; delete formValue.triggerConfig.filterByDevice; - } else { + } else if (triggerType === TriggerType.ENTITY_ACTION) { Object.assign(formValue.triggerConfig, this.entityActionTemplateForm.value); formValue.recipientsConfig.targets = this.entityActionTemplateForm.get('targets').value; formValue.additionalConfig.description = this.entityActionTemplateForm.get('description').value; + } else if (triggerType === TriggerType.ALARM_COMMENT) { + Object.assign(formValue.triggerConfig, this.alarmCommentTemplateForm.value); + formValue.recipientsConfig.targets = this.alarmCommentTemplateForm.get('targets').value; + formValue.additionalConfig.description = this.alarmCommentTemplateForm.get('description').value; } - if (triggerType === TriggerType.DEVICE_INACTIVITY || triggerType === TriggerType.ENTITY_ACTION) { + if (triggerType === TriggerType.DEVICE_INACTIVITY || triggerType === TriggerType.ENTITY_ACTION + || triggerType === TriggerType.ALARM_COMMENT) { delete formValue.triggerConfig.trigger; } if (this.ruleNotification) { diff --git a/ui-ngx/src/app/shared/models/notification.models.ts b/ui-ngx/src/app/shared/models/notification.models.ts index 1a06ecdca1..f799a1187a 100644 --- a/ui-ngx/src/app/shared/models/notification.models.ts +++ b/ui-ngx/src/app/shared/models/notification.models.ts @@ -277,7 +277,8 @@ export enum NotificationType { GENERAL = 'GENERAL', ALARM = 'ALARM', DEVICE_INACTIVITY = 'DEVICE_INACTIVITY', - ENTITY_ACTION = 'ENTITY_ACTION' + ENTITY_ACTION = 'ENTITY_ACTION', + ALARM_COMMENT = 'ALARM_COMMENT' } interface NotificationTemplateTypeTranslate { @@ -309,17 +310,25 @@ export const NotificationTemplateTypeTranslateMap = new Map([ [TriggerType.ALARM, 'notification.trigger.alarm'], [TriggerType.DEVICE_INACTIVITY, 'notification.trigger.device-inactivity'], - [TriggerType.ENTITY_ACTION, 'notification.trigger.entity-action'] + [TriggerType.ENTITY_ACTION, 'notification.trigger.entity-action'], + [TriggerType.ALARM_COMMENT, 'notification.trigger.alarm-comment'] ]); diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index fbbb490553..7dad7da314 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2796,13 +2796,15 @@ "alarm": "Alarm", "general": "General", "device-inactivity": "Device inactivity", - "entity-action": "Entity action" + "entity-action": "Entity action", + "alarm-comment": "Alarm comment" }, "template-hint": { "general": "Available params: ${recipientEmail}, ${recipientFirstName}, ${recipientLastName}", "alarm": "Available params: ${alarmType}, ${alarmSeverity}, ${alarmStatus}, ${alarmOriginatorEntityType}, ${alarmOriginatorId}, ${alarmId}", "device-inactivity": "Available params: ${deviceName}, ${deviceType}, ${deviceId}", - "entity-action": "Available params: ${actionType}, ${entityType}, ${entityName}, ${entityId}, ${originatorUserName}, ${originatorUserId}" + "entity-action": "Available params: ${actionType}, ${entityType}, ${entityName}, ${entityId}, ${originatorUserName}, ${originatorUserId}", + "alarm-comment": "Available params: ${comment}, ${alarmType}, ${alarmId}" }, "templates": "Templates", "text": "Text", @@ -2820,11 +2822,13 @@ "trigger-required": "Trigger is required", "alarm": "Alarm", "device-inactivity": "Device inactivity", - "entity-action": "Entity action" + "entity-action": "Entity action", + "alarm-comment": "Alarm comment" }, "alarm-trigger-settings": "Alarm trigger settings", "device-inactivity-trigger-settings": "Device inactive trigger settings", "entity-action-trigger-settings": "Entity action trigger settings", + "alarm-comment-trigger-settings": "Alarm comment trigger settings", "filter": "Filter", "clear-rule": "Clear rule", "no-severity-matching": "'{{severity}}' not found.",