UI: fix minnor bug in notification and change notification models
This commit is contained in:
parent
de24af159c
commit
53dd3c89f4
@ -26,7 +26,7 @@ import java.io.Serializable;
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "triggerType")
|
||||
@JsonSubTypes({
|
||||
@Type(value = AlarmNotificationRuleTriggerConfig.class, name = "ALARM"),
|
||||
@Type(value = DeviceActivityNotificationRuleTriggerConfig.class, name = "DEVICE_INACTIVITY"),
|
||||
@Type(value = DeviceActivityNotificationRuleTriggerConfig.class, name = "DEVICE_ACTIVITY"),
|
||||
@Type(value = EntityActionNotificationRuleTriggerConfig.class, name = "ENTITY_ACTION"),
|
||||
@Type(value = AlarmCommentNotificationRuleTriggerConfig.class, name = "ALARM_COMMENT"),
|
||||
@Type(value = RuleEngineComponentLifecycleEventNotificationRuleTriggerConfig.class, name = "RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT"),
|
||||
|
||||
@ -175,7 +175,6 @@ import { AssetProfileDialogComponent } from '@home/components/profile/asset-prof
|
||||
import { AssetProfileAutocompleteComponent } from '@home/components/profile/asset-profile-autocomplete.component';
|
||||
import { MODULES_MAP } from '@shared/models/constants';
|
||||
import { modulesMap } from '@modules/common/modules-map';
|
||||
import { SlackConversationAutocompleteComponent } from '@home/components/notification/slack-conversation-autocomplete.component';
|
||||
import { AlarmAssigneePanelComponent } from '@home/components/alarm/alarm-assignee-panel.component';
|
||||
import { RouterTabsComponent } from '@home/components/router-tabs.component';
|
||||
import { SendNotificationButtonComponent } from '@home/components/notification/send-notification-button.component';
|
||||
@ -325,7 +324,6 @@ import { SendNotificationButtonComponent } from '@home/components/notification/s
|
||||
RateLimitsComponent,
|
||||
RateLimitsTextComponent,
|
||||
RateLimitsDetailsDialogComponent,
|
||||
SlackConversationAutocompleteComponent,
|
||||
SendNotificationButtonComponent
|
||||
],
|
||||
imports: [
|
||||
@ -466,7 +464,6 @@ import { SendNotificationButtonComponent } from '@home/components/notification/s
|
||||
RateLimitsComponent,
|
||||
RateLimitsTextComponent,
|
||||
RateLimitsDetailsDialogComponent,
|
||||
SlackConversationAutocompleteComponent,
|
||||
SendNotificationButtonComponent
|
||||
],
|
||||
providers: [
|
||||
|
||||
@ -25,7 +25,7 @@ import { SentErrorDialogComponent } from '@home/pages/notification/sent/sent-err
|
||||
import { SentNotificationDialogComponent } from '@home/pages/notification/sent/sent-notification-dialog.componet';
|
||||
import {
|
||||
RecipientNotificationDialogComponent
|
||||
} from '@home/pages/notification/recipient/recipient-notification-dialog.componet';
|
||||
} from '@home/pages/notification/recipient/recipient-notification-dialog.component';
|
||||
import { RecipientTableHeaderComponent } from '@home/pages/notification/recipient/recipient-table-header.component';
|
||||
import { TemplateAutocompleteComponent } from '@home/pages/notification/template/template-autocomplete.component';
|
||||
import {
|
||||
|
||||
@ -39,6 +39,7 @@ import { Authority } from '@shared/models/authority.enum';
|
||||
import { AuthState } from '@core/auth/auth.models';
|
||||
import { getCurrentAuthState } from '@core/auth/auth.selectors';
|
||||
import { AuthUser } from '@shared/models/user.model';
|
||||
import { control } from 'leaflet';
|
||||
|
||||
export interface RecipientNotificationDialogData {
|
||||
target?: NotificationTarget;
|
||||
@ -48,7 +49,7 @@ export interface RecipientNotificationDialogData {
|
||||
@Component({
|
||||
selector: 'tb-target-notification-dialog',
|
||||
templateUrl: './recipient-notification-dialog.component.html',
|
||||
styleUrls: ['recipient-notification-dialog.componet.scss']
|
||||
styleUrls: ['recipient-notification-dialog.component.scss']
|
||||
})
|
||||
export class RecipientNotificationDialogComponent extends
|
||||
DialogComponent<RecipientNotificationDialogComponent, NotificationTarget> implements OnDestroy {
|
||||
@ -70,6 +71,7 @@ export class RecipientNotificationDialogComponent extends
|
||||
isAdd = true;
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private userFilterFormControls: string[];
|
||||
|
||||
constructor(protected store: Store<AppState>,
|
||||
protected router: Router,
|
||||
@ -119,10 +121,15 @@ export class RecipientNotificationDialogComponent extends
|
||||
this.targetNotificationForm.get('configuration.description').enable({emitEvent: false});
|
||||
});
|
||||
|
||||
this.userFilterFormControls = Object.keys((this.targetNotificationForm.get('configuration.usersFilter') as FormGroup).controls)
|
||||
.filter((controlName) => controlName !== 'type');
|
||||
|
||||
this.targetNotificationForm.get('configuration.usersFilter.type').valueChanges.pipe(
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe((type: NotificationTargetConfigType) => {
|
||||
this.targetNotificationForm.get('configuration.usersFilter').disable({emitEvent: false});
|
||||
this.userFilterFormControls.forEach(
|
||||
controlName => this.targetNotificationForm.get(`configuration.usersFilter.${controlName}`).disable({emitEvent: false})
|
||||
);
|
||||
switch (type) {
|
||||
case NotificationTargetConfigType.TENANT_ADMINISTRATORS:
|
||||
if (this.isSysAdmin()) {
|
||||
@ -136,7 +143,6 @@ export class RecipientNotificationDialogComponent extends
|
||||
this.targetNotificationForm.get('configuration.usersFilter.customerId').enable({emitEvent: false});
|
||||
break;
|
||||
}
|
||||
this.targetNotificationForm.get('configuration.usersFilter.type').enable({emitEvent: false});
|
||||
});
|
||||
|
||||
this.targetNotificationForm.get('configuration.usersFilter.filterByTenants').valueChanges.pipe(
|
||||
@ -28,7 +28,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 { MatDialog } from '@angular/material/dialog';
|
||||
import { EntityAction } from '@home/models/entity/entity-component.models';
|
||||
import { RecipientTableHeaderComponent } from '@home/pages/notification/recipient/recipient-table-header.component';
|
||||
|
||||
@ -37,7 +37,7 @@ import { takeUntil } from 'rxjs/operators';
|
||||
import {
|
||||
RecipientNotificationDialogComponent,
|
||||
RecipientNotificationDialogData
|
||||
} from '@home/pages/notification/recipient/recipient-notification-dialog.componet';
|
||||
} from '@home/pages/notification/recipient/recipient-notification-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
|
||||
|
||||
@ -151,9 +151,9 @@
|
||||
</form>
|
||||
</mat-step>
|
||||
|
||||
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.DEVICE_INACTIVITY"
|
||||
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.DEVICE_ACTIVITY"
|
||||
[stepControl]="deviceInactivityTemplateForm">
|
||||
<ng-template matStepLabel>{{ 'notification.device-inactivity-trigger-settings' | translate }}</ng-template>
|
||||
<ng-template matStepLabel>{{ 'notification.device-activity-trigger-settings' | translate }}</ng-template>
|
||||
<form [formGroup]="deviceInactivityTemplateForm">
|
||||
<section formGroupName="triggerConfig">
|
||||
<div fxFlex fxLayoutAlign="center center">
|
||||
@ -184,6 +184,17 @@
|
||||
[entityType]="entityType.DEVICE_PROFILE">
|
||||
</tb-entity-list>
|
||||
</ng-template>
|
||||
<mat-form-field fxFlex class="mat-block">
|
||||
<mat-label translate>notification.notify-on</mat-label>
|
||||
<mat-select formControlName="notifyOn" multiple>
|
||||
<mat-option *ngFor="let deviceEvent of deviceEvents" [value]="deviceEvent">
|
||||
{{ deviceEventTranslationMap.get(deviceEvent) | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="deviceInactivityTemplateForm.get('triggerConfig.notifyOn').hasError('required')">
|
||||
{{ 'notification.notify-on-required' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</section>
|
||||
</form>
|
||||
<form [formGroup]="ruleNotificationForm">
|
||||
@ -202,11 +213,10 @@
|
||||
<form [formGroup]="entityActionTemplateForm">
|
||||
<fieldset class="fields-group tb-margin" formGroupName="triggerConfig">
|
||||
<legend translate>notification.filter</legend>
|
||||
<tb-entity-type-select required
|
||||
showLabel
|
||||
[allowedEntityTypes]="entityTypes"
|
||||
formControlName="entityType">
|
||||
</tb-entity-type-select>
|
||||
<tb-entity-type-list required
|
||||
[allowedEntityTypes]="entityTypes"
|
||||
formControlName="entityTypes">
|
||||
</tb-entity-type-list>
|
||||
<section fxLayout="column" fxLayoutGap="8px">
|
||||
<span fxFlex translate>notification.status</span>
|
||||
<mat-slide-toggle formControlName="created">{{ 'notification.created' | translate }}</mat-slide-toggle>
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -41,7 +41,7 @@ import { getCurrentTime } from '@shared/models/time/time.models';
|
||||
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 { TemplateConfiguration } from '@home/pages/notification/template/template-configuration';
|
||||
|
||||
|
||||
@ -133,7 +133,6 @@ export class TemplateAutocompleteComponent implements ControlValueAccessor, OnIn
|
||||
}
|
||||
}),
|
||||
map(value => value ? (typeof value === 'string' ? value : value.name) : ''),
|
||||
distinctUntilChanged(),
|
||||
switchMap(name => this.fetchTemplate(name)),
|
||||
share()
|
||||
);
|
||||
|
||||
@ -203,6 +203,16 @@ export const AlarmAssignmentActionTranslationMap = new Map<AlarmAssignmentAction
|
||||
[AlarmAssignmentAction.UNASSIGNED, 'notification.notify-alarm-action.unassigned']
|
||||
]);
|
||||
|
||||
export enum DeviceEvent {
|
||||
ACTIVE = 'ACTIVE',
|
||||
INACTIVE = 'INACTIVE'
|
||||
}
|
||||
|
||||
export const DeviceEventTranslationMap = new Map<DeviceEvent, string>([
|
||||
[DeviceEvent.ACTIVE, 'notification.active'],
|
||||
[DeviceEvent.INACTIVE, 'notification.inactive']
|
||||
]);
|
||||
|
||||
export interface NotificationRuleRecipientConfig {
|
||||
targets?: Array<string>;
|
||||
escalationTable?: {[key: number]: Array<string>};
|
||||
@ -415,7 +425,7 @@ export const NotificationTargetConfigTypeInfoMap = new Map<NotificationTargetCon
|
||||
export enum NotificationType {
|
||||
GENERAL = 'GENERAL',
|
||||
ALARM = 'ALARM',
|
||||
DEVICE_INACTIVITY = 'DEVICE_INACTIVITY',
|
||||
DEVICE_ACTIVITY = 'DEVICE_ACTIVITY',
|
||||
ENTITY_ACTION = 'ENTITY_ACTION',
|
||||
ALARM_COMMENT = 'ALARM_COMMENT',
|
||||
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT',
|
||||
@ -425,7 +435,7 @@ export enum NotificationType {
|
||||
|
||||
export const NotificationTypeIcons = new Map<NotificationType, string | null>([
|
||||
[NotificationType.ALARM, 'warning'],
|
||||
[NotificationType.DEVICE_INACTIVITY, 'phonelink_off'],
|
||||
[NotificationType.DEVICE_ACTIVITY, 'phonelink_off'],
|
||||
[NotificationType.ENTITY_ACTION, 'devices'],
|
||||
[NotificationType.ALARM_COMMENT, 'comment'],
|
||||
[NotificationType.ALARM_ASSIGNMENT, 'assignment_turned_in'],
|
||||
@ -471,10 +481,10 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
|
||||
helpId: 'notification/alarm'
|
||||
}
|
||||
],
|
||||
[NotificationType.DEVICE_INACTIVITY,
|
||||
[NotificationType.DEVICE_ACTIVITY,
|
||||
{
|
||||
name: 'notification.template-type.device-inactivity',
|
||||
helpId: 'notification/device_inactivity'
|
||||
name: 'notification.template-type.device-activity',
|
||||
helpId: 'notification/device_activity'
|
||||
}
|
||||
],
|
||||
[NotificationType.ENTITY_ACTION,
|
||||
@ -510,7 +520,7 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
|
||||
|
||||
export enum TriggerType {
|
||||
ALARM = 'ALARM',
|
||||
DEVICE_INACTIVITY = 'DEVICE_INACTIVITY',
|
||||
DEVICE_ACTIVITY = 'DEVICE_ACTIVITY',
|
||||
ENTITY_ACTION = 'ENTITY_ACTION',
|
||||
ALARM_COMMENT = 'ALARM_COMMENT',
|
||||
ALARM_ASSIGNMENT = 'ALARM_ASSIGNMENT',
|
||||
@ -520,7 +530,7 @@ export enum TriggerType {
|
||||
|
||||
export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
|
||||
[TriggerType.ALARM, 'notification.trigger.alarm'],
|
||||
[TriggerType.DEVICE_INACTIVITY, 'notification.trigger.device-inactivity'],
|
||||
[TriggerType.DEVICE_ACTIVITY, 'notification.trigger.device-activity'],
|
||||
[TriggerType.ENTITY_ACTION, 'notification.trigger.entity-action'],
|
||||
[TriggerType.ALARM_COMMENT, 'notification.trigger.alarm-comment'],
|
||||
[TriggerType.ALARM_ASSIGNMENT, 'notification.trigger.alarm-assignment'],
|
||||
|
||||
@ -173,6 +173,7 @@ import { CustomDateAdapter } from '@shared/adapter/custom-datatime-adapter';
|
||||
import { CustomPaginatorIntl } from '@shared/services/custom-paginator-intl';
|
||||
import { TbScriptLangComponent } from '@shared/components/script-lang.component';
|
||||
import { NotificationComponent } from '@shared/components/notification/notification.component';
|
||||
import { SlackConversationAutocompleteComponent } from '@shared/components/slack-conversation-autocomplete.component';
|
||||
import { DateAgoPipe } from '@shared/pipe/date-ago.pipe';
|
||||
|
||||
export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) {
|
||||
@ -323,6 +324,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
|
||||
PhoneInputComponent,
|
||||
TbScriptLangComponent,
|
||||
NotificationComponent,
|
||||
SlackConversationAutocompleteComponent,
|
||||
DateAgoPipe
|
||||
],
|
||||
imports: [
|
||||
@ -535,6 +537,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
|
||||
PhoneInputComponent,
|
||||
TbScriptLangComponent,
|
||||
NotificationComponent,
|
||||
SlackConversationAutocompleteComponent,
|
||||
DateAgoPipe
|
||||
]
|
||||
})
|
||||
|
||||
@ -2729,6 +2729,7 @@
|
||||
"notification": {
|
||||
"action-button": "Action button",
|
||||
"action-type": "Action type",
|
||||
"active": "Active",
|
||||
"add-notification-recipients-group": "Add notification recipients group",
|
||||
"add-notification-template": "Add notification template",
|
||||
"add-recipient": "Add recipient",
|
||||
@ -2791,7 +2792,7 @@
|
||||
},
|
||||
"delivery-methods": "Delivery methods",
|
||||
"description": "Description",
|
||||
"device-inactivity-trigger-settings": "Device inactive trigger settings",
|
||||
"device-activity-trigger-settings": "Device active trigger settings",
|
||||
"device-list-rule-hint": "If the field is empty, the trigger will be applied to all devices",
|
||||
"device-profiles-list-rule-hint": "If the field is empty, the trigger will be applied to all device profiles",
|
||||
"edit-notification-recipients-group": "Edit notification recipients group",
|
||||
@ -2806,6 +2807,7 @@
|
||||
"fails": "Fails",
|
||||
"filter": "Filter",
|
||||
"first-recipient": "First recipient",
|
||||
"inactive": "Inactive",
|
||||
"inbox": "Inbox",
|
||||
"input-field-support-templatization": "Input field support templatization.",
|
||||
"input-fields-support-templatization": "Input fields support templatization.",
|
||||
@ -2919,7 +2921,7 @@
|
||||
"alarm": "Alarm",
|
||||
"alarm-assignment": "Alarm assignment",
|
||||
"alarm-comment": "Alarm comment",
|
||||
"device-inactivity": "Device inactivity",
|
||||
"device-activity": "Device activity",
|
||||
"entities-limit": "Entities limit",
|
||||
"entity-action": "Entity action",
|
||||
"general": "General",
|
||||
@ -2935,7 +2937,7 @@
|
||||
"alarm": "Alarm",
|
||||
"alarm-assignment": "Alarm assignment",
|
||||
"alarm-comment": "Alarm comment",
|
||||
"device-inactivity": "Device inactivity",
|
||||
"device-activity": "Device activity",
|
||||
"entities-limit": "Entities limit",
|
||||
"entity-action": "Entity action",
|
||||
"rule-engine-lifecycle-event": "Rule engine lifecycle event",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user