From 902cd73000ef3b25ff0cd317c2d3569aab7fd6cd Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 24 Feb 2023 11:29:36 +0200 Subject: [PATCH] UI: Add support in web notification action open dashboard --- .../notification-center.module.ts | 1 - ...request-notification-dialog.component.html | 56 +++++++++++++------ .../rule-table/escalations.component.ts | 11 +--- .../rule-notification-dialog.component.html | 1 + .../rule-notification-dialog.component.scss | 1 + .../template-autocomplete.component.html | 3 +- .../template-autocomplete.component.ts | 20 ++----- .../template-table/template-configuration.ts | 31 ++++++++-- ...emplate-notification-dialog.component.html | 48 +++++++++++----- ...ashboard-state-autocomplete.component.html | 38 ++----------- .../dashboard-state-autocomplete.component.ts | 24 ++++---- .../notification/notification.component.ts | 25 ++++++++- .../string-items-list.component.html | 1 + .../components/string-items-list.component.ts | 13 +++-- .../app/shared/decorators/coerce-boolean.ts | 35 ++++++++++++ .../app/shared/models/notification.models.ts | 15 ++++- .../assets/locale/locale.constant-en_US.json | 5 ++ 17 files changed, 216 insertions(+), 112 deletions(-) create mode 100644 ui-ngx/src/app/shared/decorators/coerce-boolean.ts diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/notification-center.module.ts b/ui-ngx/src/app/modules/home/pages/notification-center/notification-center.module.ts index e51ac5507f..584c244e63 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/notification-center.module.ts +++ b/ui-ngx/src/app/modules/home/pages/notification-center/notification-center.module.ts @@ -51,7 +51,6 @@ import { EscalationFormComponent } from '@home/pages/notification-center/rule-ta import { AlarmSeveritiesListComponent } from '@home/pages/notification-center/rule-table/alarm-severities-list.component'; -import { TemplateConfiguration } from '@home/pages/notification-center/template-table/template-configuration'; @NgModule({ declarations: [ diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/request-table/request-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/request-table/request-notification-dialog.component.html index 42cd7a3c31..0d0b9a1252 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/request-table/request-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification-center/request-table/request-notification-dialog.component.html @@ -112,15 +112,15 @@ notification.time - + - {{ 'notification.web-settings' | translate }}
@@ -158,7 +158,7 @@ {{ 'notification.action-button' | translate }}
-
+
notification.button-text @@ -169,20 +169,42 @@
- - notification.link - - - {{ 'notification.link-required' | translate }} - - +
+ + notification.action-type + + + {{ actionButtonLinkTypeTranslateMap.get(actionButtonLinkType) | translate }} + + + + + notification.link + + + {{ 'notification.link-required' | translate }} + + + + + + + + +
- {{ 'notification.email-settings' | translate }} @@ -199,8 +221,8 @@ - {{ 'notification.sms-settings' | translate }}
@@ -219,8 +241,8 @@ - {{ 'notification.slack-settings' | translate }}
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.ts b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.ts index 189f12c918..14f93566ee 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.ts +++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.ts @@ -29,10 +29,10 @@ import { } from '@angular/forms'; import { Store } from '@ngrx/store'; import { AppState } from '@app/core/core.state'; -import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { Subject } from 'rxjs'; import { NonConfirmedNotificationEscalation } from '@shared/models/notification.models'; import { takeUntil } from 'rxjs/operators'; +import { coerceBoolean } from '@shared/decorators/coerce-boolean'; @Component({ selector: 'tb-escalations-component', @@ -56,14 +56,9 @@ export class EscalationsComponent implements ControlValueAccessor, Validator, On escalationsFormGroup: FormGroup; newEscalation = false; - private requiredValue: boolean; - get required(): boolean { - return this.requiredValue; - } @Input() - set required(value: boolean) { - this.requiredValue = coerceBooleanProperty(value); - } + @coerceBoolean() + required: boolean; @Input() disabled: boolean; diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html index 52bdf742e6..1305f72271 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html @@ -90,6 +90,7 @@
notification.filter - notification.template + extends DialogComponent< notificationDeliveryMethodTranslateMap = NotificationDeliveryMethodTranslateMap; notificationTemplateTypeTranslateMap = NotificationTemplateTypeTranslateMap; + actionButtonLinkType = ActionButtonLinkType; + actionButtonLinkTypes = Object.keys(ActionButtonLinkType) as ActionButtonLinkType[]; + actionButtonLinkTypeTranslateMap = ActionButtonLinkTypeTranslateMap; + tinyMceOptions: Record = { base_url: '/assets/tinymce', suffix: '.min', @@ -97,7 +103,10 @@ export abstract class TemplateConfiguration extends DialogComponent< enabled: [false], text: [{value: '', disabled: true}, Validators.required], color: ['#305680'], - link: [{value: '', disabled: true}, Validators.required] + linkType: [ActionButtonLinkType.LINK], + link: [{value: '', disabled: true}, Validators.required], + dashboardId: [{value: null, disabled: true}, Validators.required], + dashboardState: [{value: null, disabled: true}] }), }) }); @@ -116,11 +125,25 @@ export abstract class TemplateConfiguration extends DialogComponent< takeUntil(this.destroy$) ).subscribe((value) => { if (value) { - this.pushTemplateForm.get('additionalConfig.actionButtonConfig.text').enable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig').enable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.linkType').updateValueAndValidity({onlySelf: true}); + } else { + this.pushTemplateForm.get('additionalConfig.actionButtonConfig').disable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.enabled').enable({emitEvent: false}); + } + }); + + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.linkType').valueChanges.pipe( + takeUntil(this.destroy$) + ).subscribe((value) => { + if (value === ActionButtonLinkType.LINK) { this.pushTemplateForm.get('additionalConfig.actionButtonConfig.link').enable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.dashboardId').disable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.dashboardState').disable({emitEvent: false}); } else { - this.pushTemplateForm.get('additionalConfig.actionButtonConfig.text').disable({emitEvent: false}); this.pushTemplateForm.get('additionalConfig.actionButtonConfig.link').disable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.dashboardId').enable({emitEvent: false}); + this.pushTemplateForm.get('additionalConfig.actionButtonConfig.dashboardState').enable({emitEvent: false}); } }); @@ -150,7 +173,7 @@ export abstract class TemplateConfiguration extends DialogComponent< this.destroy$.complete(); } - private atLeastOne() { + atLeastOne() { return (group: FormGroup): ValidationErrors | null => { let hasAtLeastOne = true; if (group?.controls) { diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html index 3f5f7e40bb..09fbc6897c 100644 --- a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html @@ -28,7 +28,7 @@
- check @@ -84,7 +84,7 @@ - {{ 'notification.web-settings' | translate }}
@@ -122,7 +122,7 @@ {{ 'notification.action-button' | translate }}
-
+
notification.button-text @@ -133,19 +133,41 @@
- - notification.link - - - {{ 'notification.link-required' | translate }} - - +
+ + notification.action-type + + + {{ actionButtonLinkTypeTranslateMap.get(actionButtonLinkType) | translate }} + + + + + notification.link + + + {{ 'notification.link-required' | translate }} + + + + + + + + +
- {{ 'notification.email-settings' | translate }} @@ -162,7 +184,7 @@ - {{ 'notification.sms-settings' | translate }}
@@ -181,7 +203,7 @@ - {{ 'notification.slack-settings' | translate }}
diff --git a/ui-ngx/src/app/shared/components/dashboard-state-autocomplete.component.html b/ui-ngx/src/app/shared/components/dashboard-state-autocomplete.component.html index 5ce3ff51ca..82b6f44e3c 100644 --- a/ui-ngx/src/app/shared/components/dashboard-state-autocomplete.component.html +++ b/ui-ngx/src/app/shared/components/dashboard-state-autocomplete.component.html @@ -15,11 +15,13 @@ limitations under the License. --> - - + {{ label }} +