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..985f121432 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 @@ -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..983ad4b569 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 @@ -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 59af9295e1..48902231ca 100644 --- a/ui-ngx/src/app/shared/models/notification.models.ts +++ b/ui-ngx/src/app/shared/models/notification.models.ts @@ -444,7 +444,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([ @@ -549,6 +550,12 @@ export const NotificationTemplateTypeTranslateMap = new Map([ @@ -574,4 +582,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/help/en_US/notification/rate_limits.md b/ui-ngx/src/assets/help/en_US/notification/rate_limits.md new file mode 100644 index 0000000000..8f6319ad80 --- /dev/null +++ b/ui-ngx/src/assets/help/en_US/notification/rate_limits.md @@ -0,0 +1,50 @@ +#### Exceeded rate limits notification templatization + +
+
+ +Notification subject and message fields support templatization. +The list of available templatization parameters depends on the template type. +See the available types and parameters below: + +Available template parameters: + +* `api` - rate-limited API label; one of: 'REST API requests', 'REST API requests per customer', 'transport messages', + 'transport messages per device', 'Cassandra queries', 'WS updates per session', 'notification requests', 'notification requests per rule', + 'entity version creation', 'entity version load'; +* `limitLevelEntityType` - entity type of the limit level entity, e.g. 'Tenant', 'Device', 'Notification rule', 'Customer', etc.; +* `limitLevelEntityId` - id of the limit level entity; +* `limitLevelEntityName` - name of the limit level entity; +* `tenantId` - id of the tenant; +* `tenantName` - name of the tenant; +* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise); +* `recipientEmail` - email of the recipient; +* `recipientFirstName` - first name of the recipient; +* `recipientLastName` - last name of the recipient; + +Parameter names must be wrapped using `${...}`. For example: `${recipientFirstName}`. +You may also modify the value of the parameter with one of the suffixes: + +* `upperCase`, for example - `${recipientFirstName:upperCase}` +* `lowerCase`, for example - `${recipientFirstName:lowerCase}` +* `capitalize`, for example - `${recipientFirstName:capitalize}` + +
+ +##### Examples + +Let's assume customer 'Customer A' exceeded rate limit for per-customer REST API requests. The following template: + +```text +Rate limits for ${api} exceeded for ${limitLevelEntityType:lowerCase} '${limitLevelEntityName}' +{:copy-code} +``` + +will be transformed to: + +```text +Rate limits for REST API requests per customer exceeded for customer 'Customer A' +``` + +
+
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 2fab5b1e85..1c20dbe740 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2818,6 +2818,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", @@ -3013,7 +3014,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", @@ -3032,6 +3034,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" },