From 46cd3c68fa68ee616ba8463f27d6073f48d528fd Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Fri, 19 May 2023 13:38:45 +0300 Subject: [PATCH] UI for exceeded rate limits notifications --- .../rule-notification-dialog.component.html | 12 ++++ .../rule-notification-dialog.component.ts | 55 +++++++++++-------- .../template-notification-dialog.component.ts | 43 ++++++++------- .../app/shared/models/notification.models.ts | 13 ++++- .../assets/locale/locale.constant-en_US.json | 5 +- 5 files changed, 81 insertions(+), 47 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html index fc48392e8c..0cf94e0292 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html @@ -496,6 +496,18 @@ + + {{ 'notification.rate-limits-trigger-settings' | translate }} +
+
+ + notification.description + + +
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts index 93b22911f3..9b8640a6f2 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts @@ -28,38 +28,38 @@ import { TriggerType, TriggerTypeTranslationMap } from '@shared/models/notification.models'; -import { Component, Inject, OnDestroy, ViewChild } from '@angular/core'; -import { DialogComponent } from '@shared/components/dialog.component'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { Router } from '@angular/router'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { NotificationService } from '@core/http/notification.service'; -import { EntityType } from '@shared/models/entity-type.models'; -import { deepClone, deepTrim, isDefined } from '@core/utils'; -import { Observable, Subject } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { StepperOrientation, StepperSelectionEvent } from '@angular/cdk/stepper'; -import { MatStepper } from '@angular/material/stepper'; -import { MediaBreakpoints } from '@shared/models/constants'; -import { BreakpointObserver } from '@angular/cdk/layout'; +import {Component, Inject, OnDestroy, ViewChild} from '@angular/core'; +import {DialogComponent} from '@shared/components/dialog.component'; +import {Store} from '@ngrx/store'; +import {AppState} from '@core/core.state'; +import {Router} from '@angular/router'; +import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material/dialog'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {NotificationService} from '@core/http/notification.service'; +import {EntityType} from '@shared/models/entity-type.models'; +import {deepClone, deepTrim, isDefined} from '@core/utils'; +import {Observable, Subject} from 'rxjs'; +import {map, takeUntil} from 'rxjs/operators'; +import {StepperOrientation, StepperSelectionEvent} from '@angular/cdk/stepper'; +import {MatStepper} from '@angular/material/stepper'; +import {MediaBreakpoints} from '@shared/models/constants'; +import {BreakpointObserver} from '@angular/cdk/layout'; import { AlarmSearchStatus, alarmSearchStatusTranslations, AlarmSeverity, alarmSeverityTranslations } from '@shared/models/alarm.models'; -import { TranslateService } from '@ngx-translate/core'; +import {TranslateService} from '@ngx-translate/core'; import { RecipientNotificationDialogComponent, RecipientNotificationDialogData } 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'; -import { AuthUser } from '@shared/models/user.model'; -import { Authority } from '@shared/models/authority.enum'; +import {MatButton} from '@angular/material/button'; +import {AuthState} from '@core/auth/auth.models'; +import {getCurrentAuthState} from '@core/auth/auth.selectors'; +import {AuthUser} from '@shared/models/user.model'; +import {Authority} from '@shared/models/authority.enum'; import { ApiFeature, ApiFeatureTranslationMap, @@ -95,6 +95,7 @@ export class RuleNotificationDialogComponent extends entitiesLimitTemplateForm: FormGroup; apiUsageLimitTemplateForm: FormGroup; newPlatformVersionTemplateForm: FormGroup; + rateLimitsTemplateForm: FormGroup; triggerType = TriggerType; triggerTypes: TriggerType[]; @@ -302,6 +303,12 @@ export class RuleNotificationDialogComponent extends }) }); + this.rateLimitsTemplateForm = this.fb.group({ + triggerConfig: this.fb.group({ + + }) + }); + this.triggerTypeFormsMap = new Map([ [TriggerType.ALARM, this.alarmTemplateForm], [TriggerType.ALARM_COMMENT, this.alarmCommentTemplateForm], @@ -311,7 +318,8 @@ export class RuleNotificationDialogComponent extends [TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, this.ruleEngineEventsTemplateForm], [TriggerType.ENTITIES_LIMIT, this.entitiesLimitTemplateForm], [TriggerType.API_USAGE_LIMIT, this.apiUsageLimitTemplateForm], - [TriggerType.NEW_PLATFORM_VERSION, this.newPlatformVersionTemplateForm] + [TriggerType.NEW_PLATFORM_VERSION, this.newPlatformVersionTemplateForm], + [TriggerType.RATE_LIMITS, this.rateLimitsTemplateForm] ]); if (data.isAdd || data.isCopy) { @@ -447,6 +455,7 @@ export class RuleNotificationDialogComponent extends TriggerType.ENTITIES_LIMIT, TriggerType.API_USAGE_LIMIT, TriggerType.NEW_PLATFORM_VERSION, + TriggerType.RATE_LIMITS ]); if (this.isSysAdmin()) { diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.ts index b4ba480732..ff0c58f984 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.ts @@ -14,27 +14,27 @@ /// limitations under the License. /// -import { NotificationDeliveryMethod, NotificationTemplate, NotificationType } from '@shared/models/notification.models'; -import { Component, Inject, OnDestroy, ViewChild } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { Router } from '@angular/router'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { FormBuilder } from '@angular/forms'; -import { NotificationService } from '@core/http/notification.service'; -import { deepClone, isDefinedAndNotNull } from '@core/utils'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { StepperOrientation, StepperSelectionEvent } from '@angular/cdk/stepper'; -import { MatStepper } from '@angular/material/stepper'; -import { BreakpointObserver } from '@angular/cdk/layout'; -import { MediaBreakpoints } from '@shared/models/constants'; -import { TranslateService } from '@ngx-translate/core'; -import { TemplateConfiguration } from '@home/pages/notification/template/template-configuration'; -import { AuthState } from '@core/auth/auth.models'; -import { getCurrentAuthState } from '@core/auth/auth.selectors'; -import { AuthUser } from '@shared/models/user.model'; -import { Authority } from '@shared/models/authority.enum'; +import {NotificationDeliveryMethod, NotificationTemplate, NotificationType} from '@shared/models/notification.models'; +import {Component, Inject, OnDestroy, ViewChild} from '@angular/core'; +import {Store} from '@ngrx/store'; +import {AppState} from '@core/core.state'; +import {Router} from '@angular/router'; +import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import {FormBuilder} from '@angular/forms'; +import {NotificationService} from '@core/http/notification.service'; +import {deepClone, isDefinedAndNotNull} from '@core/utils'; +import {Observable} from 'rxjs'; +import {map} from 'rxjs/operators'; +import {StepperOrientation, StepperSelectionEvent} from '@angular/cdk/stepper'; +import {MatStepper} from '@angular/material/stepper'; +import {BreakpointObserver} from '@angular/cdk/layout'; +import {MediaBreakpoints} from '@shared/models/constants'; +import {TranslateService} from '@ngx-translate/core'; +import {TemplateConfiguration} from '@home/pages/notification/template/template-configuration'; +import {AuthState} from '@core/auth/auth.models'; +import {getCurrentAuthState} from '@core/auth/auth.selectors'; +import {AuthUser} from '@shared/models/user.model'; +import {Authority} from '@shared/models/authority.enum'; export interface TemplateNotificationDialogData { template?: NotificationTemplate; @@ -181,6 +181,7 @@ export class TemplateNotificationDialogComponent NotificationType.ENTITIES_LIMIT, NotificationType.API_USAGE_LIMIT, NotificationType.NEW_PLATFORM_VERSION, + NotificationType.RATE_LIMITS ]); if (this.isSysAdmin()) { diff --git a/ui-ngx/src/app/shared/models/notification.models.ts b/ui-ngx/src/app/shared/models/notification.models.ts index d0ca9c84e0..9483c7aef3 100644 --- a/ui-ngx/src/app/shared/models/notification.models.ts +++ b/ui-ngx/src/app/shared/models/notification.models.ts @@ -445,7 +445,8 @@ export enum NotificationType { ENTITIES_LIMIT = 'ENTITIES_LIMIT', API_USAGE_LIMIT = 'API_USAGE_LIMIT', NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION', - RULE_NODE = 'RULE_NODE' + RULE_NODE = 'RULE_NODE', + RATE_LIMITS = 'RATE_LIMITS' } export const NotificationTypeIcons = new Map([ @@ -550,6 +551,12 @@ export const NotificationTemplateTypeTranslateMap = new Map([ @@ -575,4 +583,5 @@ export const TriggerTypeTranslationMap = new Map([ [TriggerType.ENTITIES_LIMIT, 'notification.trigger.entities-limit'], [TriggerType.API_USAGE_LIMIT, 'notification.trigger.api-usage-limit'], [TriggerType.NEW_PLATFORM_VERSION, 'notification.trigger.new-platform-version'], + [TriggerType.RATE_LIMITS, 'notification.trigger.rate-limits'], ]); diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index fe56019c81..c13dd964e1 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2810,6 +2810,7 @@ "api-feature-hint": "If the field is empty, the trigger will be applied to all api features", "api-usage-trigger-settings": "API usage trigger settings", "new-platform-version-trigger-settings": "New platform version trigger settings", + "rate-limits-trigger-settings": "Exceeded rate limits trigger settings", "at-least-one-should-be-selected": "At least one should be selected", "basic-settings": "Basic settings", "button-text": "Button text", @@ -3005,7 +3006,8 @@ "general": "General", "rule-engine-lifecycle-event": "Rule engine lifecycle event", "rule-node": "Rule node", - "new-platform-version": "New platform version" + "new-platform-version": "New platform version", + "rate-limits": "Exceeded rate limits" }, "templates": "Templates", "notification-templates": "Notifications / Templates", @@ -3024,6 +3026,7 @@ "entity-action": "Entity action", "rule-engine-lifecycle-event": "Rule engine lifecycle event", "new-platform-version": "New platform version", + "rate-limits": "Exceeded rate limits", "trigger": "Trigger", "trigger-required": "Trigger is required" },