Browse Source

UI for exceeded rate limits notifications

pull/8622/head
ViacheslavKlimov 4 years ago
parent
commit
46cd3c68fa
  1. 12
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html
  2. 55
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts
  3. 43
      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. 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>
</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>
</div>
<mat-divider></mat-divider>

55
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, FormGroup>([
[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()) {

43
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()) {

13
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<NotificationType, string | null>([
@ -550,6 +551,12 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
name: 'notification.template-type.rule-node',
helpId: 'notification/rule_node'
}
],
[NotificationType.RATE_LIMITS,
{
name: 'notification.template-type.rate-limits',
helpId: 'notification/rate_limits'
}
]
]);
@ -562,7 +569,8 @@ export enum TriggerType {
RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT = 'RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT',
ENTITIES_LIMIT = 'ENTITIES_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>([
@ -575,4 +583,5 @@ export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
[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'],
]);

5
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"
},

Loading…
Cancel
Save