Browse Source

UI part and help page for exceeded rate limits notification rule

pull/8702/head
ViacheslavKlimov 3 years ago
parent
commit
d5d087d826
  1. 12
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html
  2. 11
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts
  3. 1
      ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.ts
  4. 13
      ui-ngx/src/app/shared/models/notification.models.ts
  5. 50
      ui-ngx/src/assets/help/en_US/notification/rate_limits.md
  6. 5
      ui-ngx/src/assets/locale/locale.constant-en_US.json

12
ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html

@ -496,6 +496,18 @@
</form> </form>
</mat-step> </mat-step>
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.RATE_LIMITS"
[stepControl]="rateLimitsTemplateForm">
<ng-template matStepLabel>{{ 'notification.rate-limits-trigger-settings' | translate }}</ng-template>
<form [formGroup]="ruleNotificationForm">
<section formGroupName="additionalConfig">
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
</form>
</mat-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>
</div> </div>
<mat-divider></mat-divider> <mat-divider></mat-divider>

11
ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts

@ -95,6 +95,7 @@ export class RuleNotificationDialogComponent extends
entitiesLimitTemplateForm: FormGroup; entitiesLimitTemplateForm: FormGroup;
apiUsageLimitTemplateForm: FormGroup; apiUsageLimitTemplateForm: FormGroup;
newPlatformVersionTemplateForm: FormGroup; newPlatformVersionTemplateForm: FormGroup;
rateLimitsTemplateForm: FormGroup;
triggerType = TriggerType; triggerType = TriggerType;
triggerTypes: 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, FormGroup>([ this.triggerTypeFormsMap = new Map<TriggerType, FormGroup>([
[TriggerType.ALARM, this.alarmTemplateForm], [TriggerType.ALARM, this.alarmTemplateForm],
[TriggerType.ALARM_COMMENT, this.alarmCommentTemplateForm], [TriggerType.ALARM_COMMENT, this.alarmCommentTemplateForm],
@ -311,7 +318,8 @@ export class RuleNotificationDialogComponent extends
[TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, this.ruleEngineEventsTemplateForm], [TriggerType.RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT, this.ruleEngineEventsTemplateForm],
[TriggerType.ENTITIES_LIMIT, this.entitiesLimitTemplateForm], [TriggerType.ENTITIES_LIMIT, this.entitiesLimitTemplateForm],
[TriggerType.API_USAGE_LIMIT, this.apiUsageLimitTemplateForm], [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) { if (data.isAdd || data.isCopy) {
@ -447,6 +455,7 @@ export class RuleNotificationDialogComponent extends
TriggerType.ENTITIES_LIMIT, TriggerType.ENTITIES_LIMIT,
TriggerType.API_USAGE_LIMIT, TriggerType.API_USAGE_LIMIT,
TriggerType.NEW_PLATFORM_VERSION, TriggerType.NEW_PLATFORM_VERSION,
TriggerType.RATE_LIMITS
]); ]);
if (this.isSysAdmin()) { if (this.isSysAdmin()) {

1
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.ENTITIES_LIMIT,
NotificationType.API_USAGE_LIMIT, NotificationType.API_USAGE_LIMIT,
NotificationType.NEW_PLATFORM_VERSION, NotificationType.NEW_PLATFORM_VERSION,
NotificationType.RATE_LIMITS
]); ]);
if (this.isSysAdmin()) { if (this.isSysAdmin()) {

13
ui-ngx/src/app/shared/models/notification.models.ts

@ -444,7 +444,8 @@ export enum NotificationType {
ENTITIES_LIMIT = 'ENTITIES_LIMIT', ENTITIES_LIMIT = 'ENTITIES_LIMIT',
API_USAGE_LIMIT = 'API_USAGE_LIMIT', API_USAGE_LIMIT = 'API_USAGE_LIMIT',
NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION', NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION',
RULE_NODE = 'RULE_NODE' RULE_NODE = 'RULE_NODE',
RATE_LIMITS = 'RATE_LIMITS'
} }
export const NotificationTypeIcons = new Map<NotificationType, string | null>([ export const NotificationTypeIcons = new Map<NotificationType, string | null>([
@ -549,6 +550,12 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
name: 'notification.template-type.rule-node', name: 'notification.template-type.rule-node',
helpId: 'notification/rule_node' helpId: 'notification/rule_node'
} }
],
[NotificationType.RATE_LIMITS,
{
name: 'notification.template-type.rate-limits',
helpId: 'notification/rate_limits'
}
] ]
]); ]);
@ -561,7 +568,8 @@ export enum TriggerType {
RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT = 'RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT', RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT = 'RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT',
ENTITIES_LIMIT = 'ENTITIES_LIMIT', ENTITIES_LIMIT = 'ENTITIES_LIMIT',
API_USAGE_LIMIT = 'API_USAGE_LIMIT', API_USAGE_LIMIT = 'API_USAGE_LIMIT',
NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION' NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION',
RATE_LIMITS = 'RATE_LIMITS'
} }
export const TriggerTypeTranslationMap = new Map<TriggerType, string>([ export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
@ -574,4 +582,5 @@ export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
[TriggerType.ENTITIES_LIMIT, 'notification.trigger.entities-limit'], [TriggerType.ENTITIES_LIMIT, 'notification.trigger.entities-limit'],
[TriggerType.API_USAGE_LIMIT, 'notification.trigger.api-usage-limit'], [TriggerType.API_USAGE_LIMIT, 'notification.trigger.api-usage-limit'],
[TriggerType.NEW_PLATFORM_VERSION, 'notification.trigger.new-platform-version'], [TriggerType.NEW_PLATFORM_VERSION, 'notification.trigger.new-platform-version'],
[TriggerType.RATE_LIMITS, 'notification.trigger.rate-limits'],
]); ]);

50
ui-ngx/src/assets/help/en_US/notification/rate_limits.md

@ -0,0 +1,50 @@
#### Exceeded rate limits notification templatization
<div class="divider"></div>
<br/>
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}`
<div class="divider"></div>
##### 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'
```
<br>
<br>

5
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-feature-hint": "If the field is empty, the trigger will be applied to all api features",
"api-usage-trigger-settings": "API usage trigger settings", "api-usage-trigger-settings": "API usage trigger settings",
"new-platform-version-trigger-settings": "New platform version 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", "at-least-one-should-be-selected": "At least one should be selected",
"basic-settings": "Basic settings", "basic-settings": "Basic settings",
"button-text": "Button text", "button-text": "Button text",
@ -3013,7 +3014,8 @@
"general": "General", "general": "General",
"rule-engine-lifecycle-event": "Rule engine lifecycle event", "rule-engine-lifecycle-event": "Rule engine lifecycle event",
"rule-node": "Rule node", "rule-node": "Rule node",
"new-platform-version": "New platform version" "new-platform-version": "New platform version",
"rate-limits": "Exceeded rate limits"
}, },
"templates": "Templates", "templates": "Templates",
"notification-templates": "Notifications / Templates", "notification-templates": "Notifications / Templates",
@ -3032,6 +3034,7 @@
"entity-action": "Entity action", "entity-action": "Entity action",
"rule-engine-lifecycle-event": "Rule engine lifecycle event", "rule-engine-lifecycle-event": "Rule engine lifecycle event",
"new-platform-version": "New platform version", "new-platform-version": "New platform version",
"rate-limits": "Exceeded rate limits",
"trigger": "Trigger", "trigger": "Trigger",
"trigger-required": "Trigger is required" "trigger-required": "Trigger is required"
}, },

Loading…
Cancel
Save