UI for notification configs VC

This commit is contained in:
ViacheslavKlimov 2023-05-12 14:56:16 +03:00
parent b7f19a12cf
commit 97141efd5d
9 changed files with 48 additions and 12 deletions

View File

@ -422,6 +422,14 @@ export class EntityService {
pageLink.sortOrder.property = 'name';
entitiesObservable = this.notificationService.getNotificationTargets(pageLink, subType as NotificationType, config);
break;
case EntityType.NOTIFICATION_TEMPLATE:
pageLink.sortOrder.property = 'name';
entitiesObservable = this.notificationService.getNotificationTemplates(pageLink, null, config);
break;
case EntityType.NOTIFICATION_RULE:
pageLink.sortOrder.property = 'name';
entitiesObservable = this.notificationService.getNotificationRules(pageLink, config);
break;
}
return entitiesObservable;
}

View File

@ -66,10 +66,10 @@
<mat-checkbox *ngIf="entityTypeFormGroup.get('entityType').value === entityTypes.DEVICE" formControlName="saveCredentials">
{{ 'version-control.export-credentials' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="saveAttributes">
<mat-checkbox *ngIf="!entityTypesWithNoRelatedData.includes(entityTypeFormGroup.get('entityType').value)" formControlName="saveAttributes">
{{ 'version-control.export-attributes' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="saveRelations">
<mat-checkbox *ngIf="!entityTypesWithNoRelatedData.includes(entityTypeFormGroup.get('entityType').value)" formControlName="saveRelations">
{{ 'version-control.export-relations' | translate }}
</mat-checkbox>
</div>

View File

@ -31,6 +31,7 @@ import { PageComponent } from '@shared/components/page.component';
import {
EntityTypeVersionCreateConfig,
exportableEntityTypes,
entityTypesWithNoRelatedData,
SyncStrategy,
syncStrategyTranslationMap
} from '@shared/models/vc.models';
@ -73,6 +74,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements
syncStrategyTranslations = syncStrategyTranslationMap;
entityTypes = EntityType;
entityTypesWithNoRelatedData = entityTypesWithNoRelatedData
loading = true;

View File

@ -66,10 +66,10 @@
<mat-checkbox *ngIf="entityTypeFormGroup.get('entityType').value === entityTypes.DEVICE" formControlName="loadCredentials">
{{ 'version-control.load-credentials' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="loadAttributes">
<mat-checkbox *ngIf="!entityTypesWithNoRelatedData.includes(entityTypeFormGroup.get('entityType').value)" formControlName="loadAttributes">
{{ 'version-control.load-attributes' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="loadRelations">
<mat-checkbox *ngIf="!entityTypesWithNoRelatedData.includes(entityTypeFormGroup.get('entityType').value)" formControlName="loadRelations">
{{ 'version-control.load-relations' | translate }}
</mat-checkbox>
</div>

View File

@ -28,7 +28,12 @@ import {
Validators
} from '@angular/forms';
import { PageComponent } from '@shared/components/page.component';
import { EntityTypeVersionLoadConfig, exportableEntityTypes, VersionCreationResult } from '@shared/models/vc.models';
import {
EntityTypeVersionLoadConfig,
exportableEntityTypes,
entityTypesWithNoRelatedData,
VersionCreationResult
} from '@shared/models/vc.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { TranslateService } from '@ngx-translate/core';
@ -66,6 +71,7 @@ export class EntityTypesVersionLoadComponent extends PageComponent implements On
public entityTypesVersionLoadFormGroup: UntypedFormGroup;
entityTypes = EntityType;
entityTypesWithNoRelatedData = entityTypesWithNoRelatedData
loading = true;

View File

@ -368,6 +368,8 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
EntityType.NOTIFICATION_RULE,
{
type: 'entity.type-notification-rule',
typePlural: 'entity.type-notification-rules',
list: 'entity.list-of-notification-rules',
noEntities: 'notification.no-rules-notification',
search: 'notification.search-rules',
selectedEntities: 'notification.selected-rules'
@ -377,6 +379,8 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
EntityType.NOTIFICATION_TARGET,
{
type: 'entity.type-notification-target',
typePlural: 'entity.type-notification-targets',
list: 'entity.list-of-notification-targets',
noEntities: 'notification.no-recipients-notification',
search: 'notification.search-recipients',
selectedEntities: 'notification.selected-recipients'
@ -386,6 +390,8 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
EntityType.NOTIFICATION_TEMPLATE,
{
type: 'entity.type-notification-template',
typePlural: 'entity.type-notification-templates',
list: 'entity.list-of-notification-templates',
noEntities: 'notification.no-notification-templates',
search: 'notification.search-templates',
selectedEntities: 'notification.selected-template'

View File

@ -17,7 +17,7 @@
import { NotificationId } from '@shared/models/id/notification-id';
import { NotificationRequestId } from '@shared/models/id/notification-request-id';
import { UserId } from '@shared/models/id/user-id';
import { BaseData } from '@shared/models/base-data';
import { BaseData, ExportableEntity } from '@shared/models/base-data';
import { TenantId } from '@shared/models/id/tenant-id';
import { NotificationTargetId } from '@shared/models/id/notification-target-id';
import { NotificationTemplateId } from '@shared/models/id/notification-template-id';
@ -25,7 +25,6 @@ import { EntityId } from '@shared/models/id/entity-id';
import { NotificationRuleId } from '@shared/models/id/notification-rule-id';
import { AlarmSearchStatus, AlarmSeverity, AlarmStatus } from '@shared/models/alarm.models';
import { EntityType } from '@shared/models/entity-type.models';
import { User } from '@shared/models/user.model';
import { ApiFeature, ApiUsageStateValue } from '@shared/models/api-usage.models';
export interface Notification {
@ -107,7 +106,7 @@ export interface SlackConversation {
type: string;
}
export interface NotificationRule extends Omit<BaseData<NotificationRuleId>, 'label'>{
export interface NotificationRule extends Omit<BaseData<NotificationRuleId>, 'label'>, ExportableEntity<NotificationRuleId> {
tenantId: TenantId;
templateId: NotificationTemplateId;
triggerType: TriggerType;
@ -234,7 +233,7 @@ export interface NonConfirmedNotificationEscalation {
targets: Array<string>;
}
export interface NotificationTarget extends Omit<BaseData<NotificationTargetId>, 'label'>{
export interface NotificationTarget extends Omit<BaseData<NotificationTargetId>, 'label'>, ExportableEntity<NotificationTargetId> {
tenantId: TenantId;
configuration: NotificationTargetConfig;
}
@ -279,7 +278,7 @@ export const NotificationTargetTypeTranslationMap = new Map<NotificationTargetTy
[NotificationTargetType.SLACK, 'notification.delivery-method.slack']
]);
export interface NotificationTemplate extends Omit<BaseData<NotificationTemplateId>, 'label'>{
export interface NotificationTemplate extends Omit<BaseData<NotificationTemplateId>, 'label'>, ExportableEntity<NotificationTemplateId> {
tenantId: TenantId;
notificationType: NotificationType;
configuration: NotificationTemplateConfig;

View File

@ -30,9 +30,18 @@ export const exportableEntityTypes: Array<EntityType> = [
EntityType.DEVICE_PROFILE,
EntityType.ASSET_PROFILE,
EntityType.RULE_CHAIN,
EntityType.WIDGETS_BUNDLE
EntityType.WIDGETS_BUNDLE,
EntityType.NOTIFICATION_TEMPLATE,
EntityType.NOTIFICATION_TARGET,
EntityType.NOTIFICATION_RULE
];
export const entityTypesWithNoRelatedData: Array<EntityType> = [
EntityType.NOTIFICATION_TEMPLATE,
EntityType.NOTIFICATION_TARGET,
EntityType.NOTIFICATION_RULE
]
export interface VersionCreateConfig {
saveRelations: boolean;
saveAttributes: boolean;

View File

@ -2060,9 +2060,15 @@
"type-queue": "Queue",
"type-notification": "Notification",
"type-notification-rule": "Notification rule",
"type-notification-rules": "Notification rules",
"list-of-notification-rules": "{ count, plural, =1 {One notification rule} other {List of # notification rules} }",
"type-notification-target": "Notification recipient",
"type-notification-targets": "Notification recipients",
"list-of-notification-targets": "{ count, plural, =1 {One notification recipient} other {List of # notification recipients} }",
"type-notification-request": "Notification request",
"type-notification-template": "Notification template"
"type-notification-template": "Notification template",
"type-notification-templates": "Notification templates",
"list-of-notification-templates": "{ count, plural, =1 {One notification template} other {List of # notification templates} }"
},
"entity-field": {
"created-time": "Created time",