From daa73dbf532c4ca10775dad3cea850b80d9b8eb5 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 22 Mar 2023 18:22:13 +0200 Subject: [PATCH] Merge remote-tracking branch 'klimov/feature/notification-system' into feature/notification-system --- ui-ngx/src/app/core/http/entity.service.ts | 3 +- .../src/app/core/http/notification.service.ts | 12 +++++--- ui-ngx/src/app/core/services/menu.service.ts | 28 +++++++++---------- ...enant-profile-configuration.component.html | 5 ++++ ...-tenant-profile-configuration.component.ts | 1 + .../tenant/rate-limits/rate-limits.models.ts | 5 +++- .../rule/escalation-form.component.html | 3 +- .../rule/escalation-form.component.ts | 7 ++++- .../rule-notification-dialog.component.html | 3 +- .../sent-notification-dialog.component.html | 3 +- .../app/shared/models/notification.models.ts | 4 +-- ui-ngx/src/app/shared/models/tenant.model.ts | 1 + .../assets/locale/locale.constant-en_US.json | 2 ++ 13 files changed, 51 insertions(+), 26 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 1f58b2f94b..f4a7217b34 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -90,6 +90,7 @@ import { QueueService } from '@core/http/queue.service'; import { AssetProfileService } from '@core/http/asset-profile.service'; import { NotificationService } from '@core/http/notification.service'; import { TenantProfileService } from '@core/http/tenant-profile.service'; +import { NotificationType } from '@shared/models/notification.models'; @Injectable({ providedIn: 'root' @@ -418,7 +419,7 @@ export class EntityService { break; case EntityType.NOTIFICATION_TARGET: pageLink.sortOrder.property = 'name'; - entitiesObservable = this.notificationService.getNotificationTargets(pageLink, config); + entitiesObservable = this.notificationService.getNotificationTargets(pageLink, subType as NotificationType, config); break; } return entitiesObservable; diff --git a/ui-ngx/src/app/core/http/notification.service.ts b/ui-ngx/src/app/core/http/notification.service.ts index 86631140f5..b4ca3b78f9 100644 --- a/ui-ngx/src/app/core/http/notification.service.ts +++ b/ui-ngx/src/app/core/http/notification.service.ts @@ -34,7 +34,7 @@ import { SlackConversation } from '@shared/models/notification.models'; import { User } from '@shared/models/user.model'; -import { isDefinedAndNotNull } from '@core/utils'; +import { isDefinedAndNotNull, isNotEmptyStr } from '@core/utils'; @Injectable({ providedIn: 'root' @@ -131,9 +131,13 @@ export class NotificationService { defaultHttpOptionsFromConfig(config)); } - public getNotificationTargets(pageLink: PageLink, config?: RequestConfig): Observable> { - return this.http.get>(`/api/notification/targets${pageLink.toQuery()}`, - defaultHttpOptionsFromConfig(config)); + public getNotificationTargets(pageLink: PageLink, type?: NotificationType, + config?: RequestConfig): Observable> { + let url = `/api/notification/targets${pageLink.toQuery()}`; + if (isNotEmptyStr(type)) { + url += `¬ificationType=${type}`; + } + return this.http.get>(url, defaultHttpOptionsFromConfig(config)); } public getRecipientsForNotificationTargetConfig(notificationTarget: NotificationTarget, pageLink: PageLink, diff --git a/ui-ngx/src/app/core/services/menu.service.ts b/ui-ngx/src/app/core/services/menu.service.ts index bcf44ae792..ac21a879a1 100644 --- a/ui-ngx/src/app/core/services/menu.service.ts +++ b/ui-ngx/src/app/core/services/menu.service.ts @@ -160,18 +160,18 @@ export class MenuService { }, { id: guid(), - name: 'notification.templates', + name: 'notification.recipients', type: 'link', - path: '/notification/templates', - icon: 'mdi:message-draw', - isMdiIcon: true + path: '/notification/recipients', + icon: 'contacts' }, { id: guid(), - name: 'notification.recipients', + name: 'notification.templates', type: 'link', - path: '/notification/recipients', - icon: 'contacts' + path: '/notification/templates', + icon: 'mdi:message-draw', + isMdiIcon: true }, { id: guid(), @@ -529,18 +529,18 @@ export class MenuService { }, { id: guid(), - name: 'notification.templates', + name: 'notification.recipients', type: 'link', - path: '/notification/templates', - icon: 'mdi:message-draw', - isMdiIcon: true + path: '/notification/recipients', + icon: 'contacts' }, { id: guid(), - name: 'notification.recipients', + name: 'notification.templates', type: 'link', - path: '/notification/recipients', - icon: 'contacts' + path: '/notification/templates', + icon: 'mdi:message-draw', + isMdiIcon: true }, { id: guid(), diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html index 35ea628784..81a1206800 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html @@ -476,6 +476,11 @@ [type]="rateLimitsType.CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION"> +
+ + +
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts index 1276a200da..e070d760ad 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts @@ -72,6 +72,7 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA transportDeviceTelemetryDataPointsRateLimit: [null, []], tenantEntityExportRateLimit: [null, []], tenantEntityImportRateLimit: [null, []], + tenantNotificationRequestsRateLimit: [null, []], maxTransportMessages: [null, [Validators.required, Validators.min(0)]], maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]], maxREExecutions: [null, [Validators.required, Validators.min(0)]], diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts index e0f383068a..70fb7af11f 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts @@ -33,7 +33,8 @@ export enum RateLimitsType { WS_UPDATE_PER_SESSION_RATE_LIMIT = 'WS_UPDATE_PER_SESSION_RATE_LIMIT', CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION = 'CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION', TENANT_ENTITY_EXPORT_RATE_LIMIT = 'TENANT_ENTITY_EXPORT_RATE_LIMIT', - TENANT_ENTITY_IMPORT_RATE_LIMIT = 'TENANT_ENTITY_IMPORT_RATE_LIMIT' + TENANT_ENTITY_IMPORT_RATE_LIMIT = 'TENANT_ENTITY_IMPORT_RATE_LIMIT', + TENANT_NOTIFICATION_REQUEST_RATE_LIMIT = 'TENANT_NOTIFICATION_REQUEST_RATE_LIMIT' } export const rateLimitsLabelTranslationMap = new Map( @@ -50,6 +51,7 @@ export const rateLimitsLabelTranslationMap = new Map( [RateLimitsType.CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION, 'tenant-profile.cassandra-tenant-limits-configuration'], [RateLimitsType.TENANT_ENTITY_EXPORT_RATE_LIMIT, 'tenant-profile.tenant-entity-export-rate-limit'], [RateLimitsType.TENANT_ENTITY_IMPORT_RATE_LIMIT, 'tenant-profile.tenant-entity-import-rate-limit'], + [RateLimitsType.TENANT_NOTIFICATION_REQUEST_RATE_LIMIT, 'tenant-profile.tenant-notification-request-rate-limit'], ] ); @@ -67,6 +69,7 @@ export const rateLimitsDialogTitleTranslationMap = new Map