|
|
|
@ -20,7 +20,7 @@ import { |
|
|
|
AlarmAssignmentAction, |
|
|
|
AlarmAssignmentActionTranslationMap, |
|
|
|
ComponentLifecycleEvent, |
|
|
|
ComponentLifecycleEventTranslationMap, |
|
|
|
ComponentLifecycleEventTranslationMap, DeviceEvent, DeviceEventTranslationMap, |
|
|
|
NotificationRule, |
|
|
|
NotificationTarget, |
|
|
|
TriggerType, |
|
|
|
@ -52,7 +52,7 @@ import { TranslateService } from '@ngx-translate/core'; |
|
|
|
import { |
|
|
|
RecipientNotificationDialogComponent, |
|
|
|
RecipientNotificationDialogData |
|
|
|
} from '@home/pages/notification/recipient/recipient-notification-dialog.componet'; |
|
|
|
} from '@home/pages/notification/recipient/recipient-notification-dialog.component'; |
|
|
|
import { MatButton } from '@angular/material/button'; |
|
|
|
import { AuthState } from '@core/auth/auth.models'; |
|
|
|
import { getCurrentAuthState } from '@core/auth/auth.selectors'; |
|
|
|
@ -110,6 +110,9 @@ export class RuleNotificationDialogComponent extends |
|
|
|
componentLifecycleEvents: ComponentLifecycleEvent[] = Object.values(ComponentLifecycleEvent); |
|
|
|
componentLifecycleEventTranslationMap = ComponentLifecycleEventTranslationMap; |
|
|
|
|
|
|
|
deviceEvents: DeviceEvent[] = Object.values(DeviceEvent); |
|
|
|
deviceEventTranslationMap = DeviceEventTranslationMap; |
|
|
|
|
|
|
|
entityType = EntityType; |
|
|
|
entityTypes = Array.from(entityTypeTranslations.keys()).filter(type => !!this.entityType[type]); |
|
|
|
isAdd = true; |
|
|
|
@ -197,7 +200,8 @@ export class RuleNotificationDialogComponent extends |
|
|
|
triggerConfig: this.fb.group({ |
|
|
|
filterByDevice: [true], |
|
|
|
devices: [null], |
|
|
|
deviceProfiles: [{value: null, disabled: true}] |
|
|
|
deviceProfiles: [{value: null, disabled: true}], |
|
|
|
notifyOn: [[DeviceEvent.INACTIVE], Validators.required] |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
@ -215,7 +219,7 @@ export class RuleNotificationDialogComponent extends |
|
|
|
|
|
|
|
this.entityActionTemplateForm = this.fb.group({ |
|
|
|
triggerConfig: this.fb.group({ |
|
|
|
entityType: [EntityType.DEVICE], |
|
|
|
entityTypes: [[EntityType.DEVICE], Validators.required], |
|
|
|
created: [false], |
|
|
|
updated: [false], |
|
|
|
deleted: [false] |
|
|
|
@ -262,7 +266,7 @@ export class RuleNotificationDialogComponent extends |
|
|
|
this.triggerTypeFormsMap = new Map<TriggerType, FormGroup>([ |
|
|
|
[TriggerType.ALARM, this.alarmTemplateForm], |
|
|
|
[TriggerType.ALARM_COMMENT, this.alarmCommentTemplateForm], |
|
|
|
[TriggerType.DEVICE_INACTIVITY, this.deviceInactivityTemplateForm], |
|
|
|
[TriggerType.DEVICE_ACTIVITY, this.deviceInactivityTemplateForm], |
|
|
|
[TriggerType.ENTITY_ACTION, this.entityActionTemplateForm], |
|
|
|
[TriggerType.ALARM_ASSIGNMENT, this.alarmAssignmentTemplateForm], |
|
|
|
[TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, this.ruleEngineEventsTemplateForm], |
|
|
|
@ -283,7 +287,7 @@ export class RuleNotificationDialogComponent extends |
|
|
|
this.ruleNotificationForm.get('triggerType').updateValueAndValidity({onlySelf: true}); |
|
|
|
const currentForm = this.triggerTypeFormsMap.get(this.ruleNotification.triggerType); |
|
|
|
currentForm.patchValue(this.ruleNotification, {emitEvent: false}); |
|
|
|
if (this.ruleNotification.triggerType === TriggerType.DEVICE_INACTIVITY) { |
|
|
|
if (this.ruleNotification.triggerType === TriggerType.DEVICE_ACTIVITY) { |
|
|
|
this.deviceInactivityTemplateForm.get('triggerConfig.filterByDevice') |
|
|
|
.patchValue(!!this.ruleNotification.triggerConfig.devices, {onlySelf: true}); |
|
|
|
} |
|
|
|
@ -329,7 +333,7 @@ export class RuleNotificationDialogComponent extends |
|
|
|
const triggerType: TriggerType = this.ruleNotificationForm.get('triggerType').value; |
|
|
|
const currentForm = this.triggerTypeFormsMap.get(triggerType); |
|
|
|
Object.assign(formValue, currentForm.value); |
|
|
|
if (triggerType === TriggerType.DEVICE_INACTIVITY) { |
|
|
|
if (triggerType === TriggerType.DEVICE_ACTIVITY) { |
|
|
|
delete formValue.triggerConfig.filterByDevice; |
|
|
|
} |
|
|
|
formValue.recipientsConfig.triggerType = triggerType; |
|
|
|
|