diff --git a/ui-ngx/src/app/core/http/notification.service.ts b/ui-ngx/src/app/core/http/notification.service.ts index 722dcdd045..86631140f5 100644 --- a/ui-ngx/src/app/core/http/notification.service.ts +++ b/ui-ngx/src/app/core/http/notification.service.ts @@ -51,6 +51,10 @@ export class NotificationService { defaultHttpOptionsFromConfig(config)); } + public deleteNotification(id: string, config?: RequestConfig): Observable { + return this.http.delete(`/api/notification/${id}`, defaultHttpOptionsFromConfig(config)); + } + public markNotificationAsRead(id: string, config?: RequestConfig): Observable { return this.http.put(`/api/notification/${id}/read`, defaultHttpOptionsFromConfig(config)); } diff --git a/ui-ngx/src/app/modules/home/pages/notification/inbox/inbox-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/inbox/inbox-table-config.resolver.ts index 4a6f4e15bf..219bfae14c 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/inbox/inbox-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/inbox/inbox-table-config.resolver.ts @@ -20,7 +20,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import { EntityTypeResource } from '@shared/models/entity-type.models'; +import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { DatePipe } from '@angular/common'; import { Direction } from '@shared/models/page/sort-order'; import { @@ -50,17 +50,19 @@ export class InboxTableConfigResolver implements Resolve; + this.config.deleteEntityTitle = () => this.translate.instant('notification.delete-notification-title'); + this.config.deleteEntityContent = () => this.translate.instant('notification.delete-notification-text'); + this.config.deleteEntitiesTitle = count => this.translate.instant('notification.delete-notifications-title', {count}); + this.config.deleteEntitiesContent = () => this.translate.instant('notification.delete-notifications-text'); + + this.config.deleteEntity = id => this.notificationService.deleteNotification(id.id); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotifications(pageLink, this.config.componentsData.unreadOnly); diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts index bc9d7fae22..ef7a198dba 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts @@ -20,7 +20,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import { EntityTypeResource } from '@shared/models/entity-type.models'; +import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { Direction } from '@shared/models/page/sort-order'; import { NotificationTarget, NotificationTargetTypeTranslationMap } from '@shared/models/notification.models'; import { NotificationService } from '@core/http/notification.service'; @@ -46,15 +46,13 @@ export class RecipientTableConfigResolver implements Resolve; this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink); diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts index 91e90bb221..2a1b1e65fd 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts @@ -20,7 +20,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import { EntityTypeResource } from '@shared/models/entity-type.models'; +import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { Direction } from '@shared/models/page/sort-order'; import { NotificationRule, TriggerTypeTranslationMap } from '@shared/models/notification.models'; import { NotificationService } from '@core/http/notification.service'; @@ -46,15 +46,13 @@ export class RuleTableConfigResolver implements Resolve; this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRules(pageLink); diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html index dfe68d6c26..1f3e5aba96 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html @@ -28,7 +28,8 @@
- @@ -55,22 +56,6 @@
- - notification.subject - - - {{ 'notification.subject-required' | translate }} - - {{ notificationTemplateTypeTranslateMap.get(notificationType.GENERAL).hint | translate }} - - - notification.message - - - {{ 'notification.message-required' | translate }} - - {{ notificationTemplateTypeTranslateMap.get(notificationType.GENERAL).hint | translate }} -
- + notification.subject - + + + {{ 'notification.subject-required' | translate }} + - + notification.message + + {{ 'notification.message-required' | translate }} +
@@ -215,9 +205,12 @@ {{ notificationTemplateTypeTranslateMap.get(notificationType.GENERAL).hint | translate }} - + notification.subject - + + + {{ 'notification.subject-required' | translate }} + notification.message @@ -232,15 +225,17 @@ {{ notificationTemplateTypeTranslateMap.get(notificationType.GENERAL).hint | translate }} - + notification.message + + {{ 'notification.message-required' | translate }} + @@ -252,15 +247,17 @@ {{ notificationTemplateTypeTranslateMap.get(notificationType.GENERAL).hint | translate }}
- + notification.message + + {{ 'notification.message-required' | translate }} + diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss index 2fe0583a1b..e262510ec9 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss @@ -17,7 +17,7 @@ @import "../../../../../../theme"; :host-context(.tb-fullscreen-dialog .mat-mdc-dialog-container) { - width: 800px; + width: 1000px; height: 100%; max-width: 100%; max-height: 100vh; diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts index 66ed42a3b7..8a95b4d8cb 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.componet.ts @@ -60,6 +60,8 @@ export class SentNotificationDialogComponent extends @ViewChild('createNotification', {static: true}) createNotification: MatStepper; stepperOrientation: Observable; + stepperLabelPosition: Observable<'bottom' | 'end'>; + isAdd = true; entityType = EntityType; notificationType = NotificationType; @@ -87,6 +89,9 @@ export class SentNotificationDialogComponent extends this.stepperOrientation = this.breakpointObserver.observe(MediaBreakpoints['gt-sm']) .pipe(map(({matches}) => matches ? 'horizontal' : 'vertical')); + this.stepperLabelPosition = this.breakpointObserver.observe(MediaBreakpoints['gt-md']) + .pipe(map(({matches}) => matches ? 'end' : 'bottom')); + this.notificationRequestForm = this.fb.group({ useTemplate: [false], templateId: [{value: null, disabled: true}, Validators.required], @@ -148,12 +153,8 @@ export class SentNotificationDialogComponent extends } nextStepLabel(): string { - if (this.selectedIndex !== 0) { - if (this.selectedIndex >= this.maxStepperIndex) { - return 'action.send'; - } else if (this.createNotification.selected.stepControl.pristine) { - return 'action.skip'; - } + if (this.selectedIndex >= this.maxStepperIndex) { + return 'action.send'; } return 'action.next'; } diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-table-config.resolver.ts index 285d6c1434..b1a806a2e6 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-table-config.resolver.ts @@ -32,7 +32,7 @@ import { import { NotificationService } from '@core/http/notification.service'; import { TranslateService } from '@ngx-translate/core'; import { MatDialog } from '@angular/material/dialog'; -import { EntityTypeResource } from '@shared/models/entity-type.models'; +import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { Direction } from '@shared/models/page/sort-order'; import { DatePipe } from '@angular/common'; import { EntityAction } from '@home/models/entity/entity-component.models'; @@ -60,21 +60,20 @@ export class SentTableConfigResolver implements Resolve; - this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRequests(pageLink); - - this.config.deleteEnabled = (request) => request.status === NotificationRequestStatus.SCHEDULED; this.config.deleteEntityTitle = () => this.translate.instant('notification.delete-request-title'); this.config.deleteEntityContent = () => this.translate.instant('notification.delete-request-text'); + this.config.deleteEntitiesTitle = count => this.translate.instant('notification.delete-requests-title', {count}); + this.config.deleteEntitiesContent = () => this.translate.instant('notification.delete-requests-text'); + this.config.deleteEntity = id => this.notificationService.deleteNotificationRequest(id.id); + this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRequests(pageLink); this.config.cellActionDescriptors = this.configureCellActions(); diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts index 260690e30a..2eaf1807a0 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts @@ -79,8 +79,6 @@ export abstract class TemplateConfiguration extends DialogComponent< name: ['', Validators.required], notificationType: [NotificationType.GENERAL], configuration: this.fb.group({ - notificationSubject: ['', Validators.required], - defaultTextTemplate: ['', Validators.required], deliveryMethodsTemplates: this.fb.group({}, {validators: this.atLeastOne()}) }) }); @@ -91,8 +89,8 @@ export abstract class TemplateConfiguration extends DialogComponent< }); this.webTemplateForm = this.fb.group({ - subject: [''], - body: [''], + subject: ['', Validators.required], + body: ['', Validators.required], additionalConfig: this.fb.group({ icon: this.fb.group({ enabled: [false], @@ -153,16 +151,16 @@ export abstract class TemplateConfiguration extends DialogComponent< }); this.emailTemplateForm = this.fb.group({ - subject: [''], - body: [''] + subject: ['', Validators.required], + body: ['', Validators.required] }); this.smsTemplateForm = this.fb.group({ - body: [''] + body: ['', Validators.required] }); this.slackTemplateForm = this.fb.group({ - body: [''] + body: ['', Validators.required] }); this.deliveryMethodFormsMap = new Map([ diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html index 67ae8d0e49..17dcbd848a 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html @@ -28,7 +28,9 @@
- check @@ -52,22 +54,6 @@
- - notification.subject - - - {{ 'notification.subject-required' | translate }} - - {{ notificationTemplateTypeTranslateMap.get(templateNotificationForm.get('notificationType').value).hint | translate }} - - - notification.message - - - {{ 'notification.message-required' | translate }} - - {{ notificationTemplateTypeTranslateMap.get(templateNotificationForm.get('notificationType').value).hint | translate }} -
- + notification.subject - + + + {{ 'notification.subject-required' | translate }} + - + notification.message + + {{ 'notification.message-required' | translate }} +
@@ -178,9 +169,12 @@ {{ notificationTemplateTypeTranslateMap.get(templateNotificationForm.get('notificationType').value).hint | translate }} - + notification.subject - + + + {{ 'notification.subject-required' | translate }} + notification.message @@ -194,15 +188,17 @@ {{ notificationTemplateTypeTranslateMap.get(templateNotificationForm.get('notificationType').value).hint | translate }} - + notification.message + + {{ 'notification.message-required' | translate }} + @@ -213,15 +209,17 @@ {{ notificationTemplateTypeTranslateMap.get(templateNotificationForm.get('notificationType').value).hint | translate }}
- + notification.message + + {{ 'notification.message-required' | translate }} + 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 2c3ca06ba6..f7f7a41add 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 @@ -54,6 +54,7 @@ export class TemplateNotificationDialogComponent @ViewChild('notificationTemplateStepper', {static: true}) notificationTemplateStepper: MatStepper; stepperOrientation: Observable; + stepperLabelPosition: Observable<'bottom' | 'end'>; dialogTitle = 'notification.edit-notification-template'; @@ -81,6 +82,9 @@ export class TemplateNotificationDialogComponent this.stepperOrientation = this.breakpointObserver.observe(MediaBreakpoints['gt-sm']) .pipe(map(({matches}) => matches ? 'horizontal' : 'vertical')); + this.stepperLabelPosition = this.breakpointObserver.observe(MediaBreakpoints['gt-md']) + .pipe(map(({matches}) => matches ? 'end' : 'bottom')); + if (isDefinedAndNotNull(this.data?.predefinedType)) { this.hideSelectType = true; this.templateNotificationForm.get('notificationType').setValue(this.data.predefinedType, {emitEvents: false}); @@ -132,12 +136,8 @@ export class TemplateNotificationDialogComponent } nextStepLabel(): string { - if (this.selectedIndex !== 0) { - if (this.selectedIndex >= this.maxStepperIndex) { - return (this.data.isAdd || this.data.isCopy) ? 'action.add' : 'action.save'; - } else if (this.notificationTemplateStepper.selected.stepControl.pristine) { - return 'action.skip'; - } + if (this.selectedIndex >= this.maxStepperIndex) { + return (this.data.isAdd || this.data.isCopy) ? 'action.add' : 'action.save'; } return 'action.next'; } diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts index fe14fe23ec..7a1523f924 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts @@ -20,7 +20,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import { EntityTypeResource } from '@shared/models/entity-type.models'; +import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { Direction } from '@shared/models/page/sort-order'; import { NotificationTemplate, NotificationTemplateTypeTranslateMap } from '@shared/models/notification.models'; import { NotificationService } from '@core/http/notification.service'; @@ -46,15 +46,13 @@ export class TemplateTableConfigResolver implements Resolve; this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTemplates(pageLink); @@ -77,13 +75,9 @@ export class TemplateTableConfigResolver implements Resolve('createdTime', 'notification.created-time', this.datePipe, '170px'), - new EntityTableColumn('notificationType', 'notification.type', '15%', + new EntityTableColumn('notificationType', 'notification.type', '20%', (template) => this.translate.instant(NotificationTemplateTypeTranslateMap.get(template.notificationType).name)), - new EntityTableColumn('name', 'notification.template', '25%'), - new EntityTableColumn('configuration.notificationSubject', 'notification.subject', '25%', - (template) => template.configuration.notificationSubject, () => ({}), false), - new EntityTableColumn('configuration.defaultTextTemplate', 'notification.message', '35%', - (template) => template.configuration.defaultTextTemplate, () => ({}), false) + new EntityTableColumn('name', 'notification.template', '80%') ); } diff --git a/ui-ngx/src/app/shared/components/notification/notification.component.html b/ui-ngx/src/app/shared/components/notification/notification.component.html index 5e9871e475..fe489a213a 100644 --- a/ui-ngx/src/app/shared/components/notification/notification.component.html +++ b/ui-ngx/src/app/shared/components/notification/notification.component.html @@ -38,7 +38,8 @@
{{ notification.createdTime ?? currentDate | dateAgo }} -
diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index fb40b78944..a3b4321335 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -350,31 +350,42 @@ export const entityTypeTranslations = new Map