Browse Source

UI: Add new notification template/rule RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT

pull/7911/head
Vladyslav_Prykhodko 4 years ago
parent
commit
14b05a57bd
  1. 59
      ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html
  2. 4
      ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.scss
  3. 18
      ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.ts
  4. 38
      ui-ngx/src/app/shared/models/notification.models.ts
  5. 25
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -333,6 +333,65 @@
</section>
</form>
</mat-step>
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT"
[stepControl]="ruleEngineEventsTemplateForm">
<ng-template matStepLabel>{{ 'notification.rule-engine-events-trigger-settings' | translate }}</ng-template>
<form [formGroup]="ruleEngineEventsTemplateForm">
<section formGroupName="triggerConfig">
<fieldset class="fields-group tb-margin">
<legend translate>notification.rule-engine-filter</legend>
<tb-entity-list
formControlName="ruleChains"
subscriptSizing="dynamic"
labelText="{{ 'rulechain.rulechains' | translate }}"
placeholderText="{{ 'rulechain.rulechains' | translate }}"
hint="{{ 'notification.rule-chain-list-rule-hint' | translate }}"
[entityType]="entityType.RULE_CHAIN">
</tb-entity-list>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>rulechain.rulechain-events</mat-label>
<mat-select formControlName="ruleChainEvents" multiple
placeholder="{{ !ruleEngineEventsTemplateForm.get('triggerConfig.ruleChainEvents').value?.length ? ('event.all-events' | translate) : '' }}">
<mat-option *ngFor="let componentLifecycleEvent of componentLifecycleEvents" [value]="componentLifecycleEvent">
{{ componentLifecycleEventTranslationMap.get(componentLifecycleEvent) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-slide-toggle formControlName="onlyRuleChainLifecycleFailures">
{{ 'notification.only-rule-chain-lifecycle-failures' | translate }}
</mat-slide-toggle>
</fieldset>
<fieldset class="fields-group tb-margin">
<legend translate>notification.rule-node-filter</legend>
<mat-slide-toggle formControlName="trackRuleNodeEvents">
{{ 'notification.track-rule-node-events' | translate }}
</mat-slide-toggle>
<section *ngIf="ruleEngineEventsTemplateForm.get('triggerConfig.trackRuleNodeEvents').value">
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>rulenode.rule-node-events</mat-label>
<mat-select formControlName="ruleNodeEvents" multiple
placeholder="{{ !ruleEngineEventsTemplateForm.get('triggerConfig.ruleNodeEvents').value?.length ? ('event.all-events' | translate) : '' }}">
<mat-option *ngFor="let componentLifecycleEvent of componentLifecycleEvents" [value]="componentLifecycleEvent">
{{ componentLifecycleEventTranslationMap.get(componentLifecycleEvent) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-slide-toggle formControlName="onlyRuleNodeLifecycleFailures">
{{ 'notification.only-rule-node-lifecycle-failures' | translate }}
</mat-slide-toggle>
</section>
</fieldset>
</section>
</form>
<form [formGroup]="ruleNotificationForm">
<section formGroupName="additionalConfig">
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
</form>
</mat-step>
</mat-horizontal-stepper>
</div>
<mat-divider></mat-divider>

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

@ -60,6 +60,10 @@
.clear-button-space {
margin-right: 48px;
}
.mat-mdc-slide-toggle {
margin-bottom: 16px;
}
}
::ng-deep {

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

@ -19,6 +19,8 @@ import {
AlarmActionTranslationMap,
AlarmAssignmentAction,
AlarmAssignmentActionTranslationMap,
ComponentLifecycleEvent,
ComponentLifecycleEventTranslationMap,
NotificationRule,
NotificationTarget,
TriggerType,
@ -77,6 +79,7 @@ export class RuleNotificationDialogComponent extends
entityActionTemplateForm: FormGroup;
alarmCommentTemplateForm: FormGroup;
alarmAssignmentTemplateForm: FormGroup;
ruleEngineEventsTemplateForm: FormGroup;
triggerType = TriggerType;
triggerTypes: TriggerType[] = Object.values(TriggerType);
@ -99,6 +102,9 @@ export class RuleNotificationDialogComponent extends
alarmAssignmentActions: AlarmAssignmentAction[] = Object.values(AlarmAssignmentAction);
alarmAssignmentActionTranslationMap = AlarmAssignmentActionTranslationMap;
componentLifecycleEvents: ComponentLifecycleEvent[] = Object.values(ComponentLifecycleEvent);
componentLifecycleEventTranslationMap = ComponentLifecycleEventTranslationMap;
entityType = EntityType;
entityTypes: EntityType[] = Object.values(EntityType);
isAdd = true;
@ -226,12 +232,24 @@ export class RuleNotificationDialogComponent extends
})
});
this.ruleEngineEventsTemplateForm = this.fb.group({
triggerConfig: this.fb.group({
ruleChains: [null],
ruleChainEvents: [null],
onlyRuleChainLifecycleFailures: [false],
trackRuleNodeEvents: [false],
ruleNodeEvents: [null],
onlyRuleNodeLifecycleFailures: [false]
})
});
this.triggerTypeFormsMap = new Map<TriggerType, FormGroup>([
[TriggerType.ALARM, this.alarmTemplateForm],
[TriggerType.ALARM_COMMENT, this.alarmCommentTemplateForm],
[TriggerType.DEVICE_INACTIVITY, this.deviceInactivityTemplateForm],
[TriggerType.ENTITY_ACTION, this.entityActionTemplateForm],
[TriggerType.ALARM_ASSIGNMENT, this.alarmAssignmentTemplateForm],
[TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, this.ruleEngineEventsTemplateForm]
]);
if (data.isAdd || data.isCopy) {

38
ui-ngx/src/app/shared/models/notification.models.ts

@ -109,7 +109,8 @@ export interface NotificationRule extends Omit<BaseData<NotificationRuleId>, 'la
additionalConfig: {description: string};
}
export type NotificationRuleTriggerConfig = Partial<AlarmNotificationRuleTriggerConfig & DeviceInactivityNotificationRuleTriggerConfig & EntityActionNotificationRuleTriggerConfig & AlarmCommentNotificationRuleTriggerConfig & AlarmAssignmentNotificationRuleTriggerConfig>
export type NotificationRuleTriggerConfig = Partial<AlarmNotificationRuleTriggerConfig & DeviceInactivityNotificationRuleTriggerConfig & EntityActionNotificationRuleTriggerConfig & AlarmCommentNotificationRuleTriggerConfig & AlarmAssignmentNotificationRuleTriggerConfig &
RuleEngineLifecycleEventNotificationRuleTriggerConfig>
export interface AlarmNotificationRuleTriggerConfig {
alarmTypes?: Array<string>;
@ -149,6 +150,27 @@ export interface AlarmAssignmentNotificationRuleTriggerConfig {
notifyOn: Array<AlarmAssignmentAction>;
}
export interface RuleEngineLifecycleEventNotificationRuleTriggerConfig {
ruleChains?: Array<string>;
ruleChainEvents?: Array<ComponentLifecycleEvent>;
onlyRuleChainLifecycleFailures: boolean;
trackRuleNodeEvents: boolean;
ruleNodeEvents: Array<any>;
onlyRuleNodeLifecycleFailures: ComponentLifecycleEvent;
}
export enum ComponentLifecycleEvent {
STARTED = 'STARTED',
UPDATED = 'UPDATED',
STOPPED = 'STOPPED'
}
export const ComponentLifecycleEventTranslationMap = new Map<ComponentLifecycleEvent, string>([
[ComponentLifecycleEvent.STARTED, 'event.started'],
[ComponentLifecycleEvent.UPDATED, 'event.updated'],
[ComponentLifecycleEvent.STOPPED, 'event.stopped']
])
export enum AlarmAction {
CREATED = 'CREATED',
SEVERITY_CHANGED = 'SEVERITY_CHANGED',
@ -347,7 +369,8 @@ export enum NotificationType {
DEVICE_INACTIVITY = 'DEVICE_INACTIVITY',
ENTITY_ACTION = 'ENTITY_ACTION',
ALARM_COMMENT = 'ALARM_COMMENT',
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT'
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT',
RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT = 'RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT'
}
export const NotificationTypeIcons = new Map<NotificationType, string | null>([
@ -356,6 +379,7 @@ export const NotificationTypeIcons = new Map<NotificationType, string | null>([
[NotificationType.ENTITY_ACTION, 'devices'],
[NotificationType.ALARM_COMMENT, 'comment'],
[NotificationType.ALARM_ASSIGNMENT, 'assignment_turned_in'],
[NotificationType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, 'settings_ethernet']
]);
export const AlarmSeverityNotificationColors = new Map<AlarmSeverity, string>(
@ -419,6 +443,12 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
name: 'notification.template-type.alarm-assignment',
hint: 'notification.template-hint.alarm-assignment'
}
],
[NotificationType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT,
{
name: 'notification.template-type.rule-engine-lifecycle-event',
hint: 'notification.template-hint.rule-engine-lifecycle-event'
}
]
]);
@ -427,7 +457,8 @@ export enum TriggerType {
DEVICE_INACTIVITY = 'DEVICE_INACTIVITY',
ENTITY_ACTION = 'ENTITY_ACTION',
ALARM_COMMENT = 'ALARM_COMMENT',
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT'
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT',
RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT = 'RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT'
}
export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
@ -436,4 +467,5 @@ export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
[TriggerType.ENTITY_ACTION, 'notification.trigger.entity-action'],
[TriggerType.ALARM_COMMENT, 'notification.trigger.alarm-comment'],
[TriggerType.ALARM_ASSIGNMENT, 'notification.trigger.alarm-assignment'],
[TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, 'notification.trigger.rule-engine-lifecycle-event'],
]);

25
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2174,7 +2174,10 @@
"entity-type": "Entity type",
"clear-filter": "Clear Filter",
"clear-request-title": "Clear all events",
"clear-request-text": "Are you sure you want to clear all events?"
"clear-request-text": "Are you sure you want to clear all events?",
"started": "Started",
"updated": "Updated",
"stopped": "Stopped"
},
"extension": {
"extensions": "Extensions",
@ -2836,8 +2839,12 @@
},
"review": "Review",
"rule": "Rule",
"rule-chain-list-rule-hint": "If the field is empty, the trigger will be applied to all rule chains",
"rule-engine-events-trigger-settings": "Rule engine events trigger settings",
"rule-engine-filter": "Rule engine filter",
"rule-name": "Rule name",
"rule-name-required": "Name is required",
"rule-node-filter": "Rule node filter",
"rules": "Rules",
"scheduler-later": "Schedule for later",
"search-notification": "Search notification",
@ -2882,7 +2889,8 @@
"alarm-comment": "Available params: ${comment}, ${alarmType}, ${alarmId}, ${alarmType}, ${alarmSeverity}, ${alarmStatus}, ${alarmOriginatorEntityType}, ${alarmOriginatorId}, ${alarmId}, ${alarmAction}",
"device-inactivity": "Available params: ${deviceName}, ${deviceLabel}, ${deviceType}, ${deviceId}",
"entity-action": "Available params: ${actionType}, ${entityType}, ${entityName}, ${entityId}, ${originatorUserName}, ${originatorUserId}",
"general": "Available params: ${recipientEmail}, ${recipientFirstName}, ${recipientLastName}"
"general": "Available params: ${recipientEmail}, ${recipientFirstName}, ${recipientLastName}",
"rule-engine-lifecycle-event": "Available params: ${ruleChainName}, ${componentName}, ${eventType}, ${error}, ${ruleChainId}, ${componentId}"
},
"template-name": "Template name",
"template-required": "Template is required",
@ -2892,12 +2900,14 @@
"alarm-comment": "Alarm comment",
"device-inactivity": "Device inactivity",
"entity-action": "Entity action",
"general": "General"
"general": "General",
"rule-engine-lifecycle-event": "Rule engine lifecycle event"
},
"templates": "Templates",
"tenants-list-rule-hint": "If the field is empty, the trigger will be applied to all tenants",
"tenant-profiles-list-rule-hint": "If the field is empty, the trigger will be applied to all tenant profiles",
"time": "Time",
"track-rule-node-events": "Track rule node events",
"trigger": {
"alarm": "Alarm",
"alarm-assignment": "Alarm assignment",
@ -2905,14 +2915,17 @@
"device-inactivity": "Device inactivity",
"entity-action": "Entity action",
"trigger": "Trigger",
"trigger-required": "Trigger is required"
"trigger-required": "Trigger is required",
"rule-engine-lifecycle-event": "Rule engine lifecycle event"
},
"type": "Type",
"unread": "Unread",
"updated": "Updated",
"use-template": "Use template",
"view-all": "View all",
"web-settings": "Web settings"
"web-settings": "Web settings",
"only-rule-chain-lifecycle-failures": "Only rule chain lifecycle failures",
"only-rule-node-lifecycle-failures": "Only rule node lifecycle failures"
},
"ota-update": {
"add": "Add package",
@ -3145,6 +3158,7 @@
},
"rulechain": {
"rulechain": "Rule chain",
"rulechain-events": "Rule chain events",
"rulechains": "Rule chains",
"root": "Root",
"delete": "Delete rule chain",
@ -3206,6 +3220,7 @@
"unassign-rulechains": "Unassign rulechains"
},
"rulenode": {
"rule-node-events": "Rule node events",
"details": "Details",
"events": "Events",
"search": "Search nodes",

Loading…
Cancel
Save