Browse Source

UI for alarm comment notification rule trigger

pull/8046/head
ViacheslavKlimov 4 years ago
parent
commit
ae709351ce
  1. 17
      ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html
  2. 26
      ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts
  3. 17
      ui-ngx/src/app/shared/models/notification.models.ts
  4. 10
      ui-ngx/src/assets/locale/locale.constant-en_US.json

17
ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html

@ -231,6 +231,23 @@
</mat-form-field>
</form>
</mat-step>
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.ALARM_COMMENT"
[stepControl]="alarmCommentTemplateForm">
<ng-template matStepLabel>{{ 'notification.alarm-comment-trigger-settings' | translate }}</ng-template>
<form [formGroup]="alarmCommentTemplateForm">
<tb-entity-list
required
formControlName="targets"
[entityType]="entityType.NOTIFICATION_TARGET"
placeholderText="notification.target">
</tb-entity-list>
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</form>
</mat-step>
</mat-horizontal-stepper>
</div>
<mat-divider></mat-divider>

26
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) {

17
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<NotificationType, No
name: 'notification.template-type.entity-action',
hint: 'notification.template-hint.entity-action'
}
]
],
[NotificationType.ALARM_COMMENT,
{
name: 'notification.template-type.alarm-comment',
hint: 'notification.template-hint.alarm-comment'
}
],
]);
export enum TriggerType {
ALARM = 'ALARM',
DEVICE_INACTIVITY = 'DEVICE_INACTIVITY',
ENTITY_ACTION = 'ENTITY_ACTION'
ENTITY_ACTION = 'ENTITY_ACTION',
ALARM_COMMENT = 'ALARM_COMMENT'
}
export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
[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']
]);

10
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.",

Loading…
Cancel
Save