diff --git a/apps/red-ui/src/app/models/notification-preferences.ts b/apps/red-ui/src/app/models/notification-preferences.ts deleted file mode 100644 index f3aad2a88..000000000 --- a/apps/red-ui/src/app/models/notification-preferences.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { FormControl } from '@angular/forms'; - -export class NotificationPreferences { - //TODO replace hardcoded values with the ones from backend when it will be done - readonly isActive: FormControl = new FormControl(true); - readonly sendSchedule?: FormControl; - - readonly dossierStatusChanges: FormControl = new FormControl(true); - readonly requestToJoinTheDossier: FormControl = new FormControl(true); - readonly documentStatusChanges: FormControl = new FormControl(true); - readonly documentIsSentForApproval: FormControl = new FormControl(true); - - readonly whenIAmAssignedOnADocument: FormControl = new FormControl(true); - readonly whenIAmUnassignedFromADocument: FormControl = new FormControl(true); - readonly whenADocumentIsApproved: FormControl = new FormControl(true); - - readonly whenADocumentIsSentForApproval: FormControl = new FormControl(true); - readonly whenADocumentIsAssignedToAReviewer: FormControl = new FormControl(true); - readonly whenAReviewerIsUnassignedFromADocument: FormControl = new FormControl(true); - - constructor(sendSchedule?: string) { - if (sendSchedule) { - this.sendSchedule = new FormControl(sendSchedule); - } - } -} diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html index e553252a4..1659a116f 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html @@ -13,113 +13,37 @@
-
+
- {{ + {{ translations[category] | translate }}
-
-
-
+
+
+
- {{ translations[schedule] | translate }} + {{ translations[type.toLocaleLowerCase()] | translate }}
-
-
+
+
- {{ 'notifications-screen.options.dossier-status-changes' | translate }} - - - {{ 'notifications-screen.options.request-to-join-the-dossier' | translate }} - - - {{ 'notifications-screen.options.document-status-changes' | translate }} - - - {{ 'notifications-screen.options.document-is-sent-for-approval' | translate }} - -
-
- -
-
-
- - {{ 'notifications-screen.options.when-i-am-assigned-on-a-document' | translate }} - - - {{ 'notifications-screen.options.when-i-am-unassigned-from-a-document' | translate }} - - - {{ 'notifications-screen.options.when-a-document-is-approved' | translate }} - -
-
- -
-
-
- - {{ 'notifications-screen.options.when-a-document-is-sent-for-approval' | translate }} - - - {{ 'notifications-screen.options.when-a-document-is-assigned-to-a-reviewer' | translate }} - - - {{ - 'notifications-screen.options.when-a-reviewer-is-unassigned-from-a-document' | translate - }} + {{ translations[preference] | translate }}
diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts index 17d820d52..3a3c8de9d 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts @@ -1,24 +1,22 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { notificationsTranslations } from '../../translations/notifications-translations'; -import { NotificationPreferences } from '../../../../models/notification-preferences'; import { NotificationPreferencesService } from '../../../../services/notification-preferences.service'; -enum SendSchedule { - INSTANT = 'instant', - DAILY = 'daily', - WEEKLY = 'weekly', -} - @Component({ selector: 'redaction-notifications-screen', templateUrl: './notifications-screen.component.html', styleUrls: ['./notifications-screen.component.scss'], }) export class NotificationsScreenComponent implements OnInit { - readonly sendSchedules = ['instant', 'daily', 'weekly']; - readonly notificationCategories = ['inAppNotifications', 'emailNotifications']; - + readonly emailNotificationTypes: string[] = ['INSTANT', 'DAILY', 'WEEKLY']; + readonly notificationCategories: string[] = ['inAppNotifications', 'emailNotifications']; + readonly notificationGroupsKeys: string[] = ['own', 'reviewer', 'approver']; + readonly notificationGroupsValues: string[][] = [ + ['dossierStatusChanges', 'requestToJoinTheDossier', 'documentStatusChanges', 'documentIsSentForApproval'], + ['whenIAmAssignedOnADocument', 'whenIAmUnassignedFromADocument', 'whenADocumentIsApproved'], + ['whenADocumentIsSentForApproval', 'whenADocumentIsAssignedToAReviewer', 'whenAReviewerIsUnassignedFromADocument'], + ]; readonly translations = notificationsTranslations; formGroup: FormGroup; @@ -26,33 +24,63 @@ export class NotificationsScreenComponent implements OnInit { constructor( private readonly _formBuilder: FormBuilder, private readonly _notificationPreferencesService: NotificationPreferencesService, - ) { - this.formGroup = this._formBuilder.group({ - inAppNotifications: new FormGroup(new NotificationPreferences() as any), - emailNotifications: new FormGroup(new NotificationPreferences(SendSchedule.INSTANT) as any), - }); - } + ) {} async ngOnInit(): Promise { await this._initializeForm(); } - setSchedule(schedule: string) { - this.formGroup.get('emailNotifications').get('sendSchedule').setValue(schedule); + isCategoryActive(category: string) { + return this.formGroup.get(`${category}Enabled`).value; } - isFormActive(category: string) { - return this.formGroup.get(category).get('isActive').value; + setEmailNotificationType(type: string) { + this.formGroup.get('emailNotificationType').setValue(type); } - getSchedule(category: string) { - return this.formGroup.get(category).get('sendSchedule'); + getEmailNotificationType() { + return this.formGroup.get('emailNotificationType').value; } - save() {} + isPreferenceChecked(category: string, preference: string) { + return this.formGroup.get(category).value.includes(preference); + } + + addRemovePreference(checked: boolean, category: string, preference: string) { + const preferences = this.formGroup.get(category).value; + if (checked) { + preferences.push(preference); + } else { + const indexOfPreference = preferences.indexOf(preference); + preferences.splice(indexOfPreference, 1); + } + this.formGroup.get(category).setValue(preferences); + } + + async save() { + console.log('formGroup: ', this.formGroup.value); + return; + await this._notificationPreferencesService.updateNotificationPreferences(this.formGroup.value).toPromise(); + } private async _initializeForm() { - const notificationPreferences = await this._notificationPreferencesService.getNotificationPreferences().toPromise(); - console.log('notificationPreferences: ', notificationPreferences); + // const notificationPreferences = await this._notificationPreferencesService.getNotificationPreferences().toPromise(); + + const notificationPreferences = { + emailNotificationType: 'DAILY', + emailNotifications: ['documentStatusChanges', 'string'], + emailNotificationsEnabled: true, + inAppNotifications: ['whenADocumentIsAssignedToAReviewer', 'whenAReviewerIsUnassignedFromADocument'], + inAppNotificationsEnabled: true, + userId: 'string', + }; + + this.formGroup = this._formBuilder.group({ + inAppNotificationsEnabled: [notificationPreferences.inAppNotificationsEnabled], + emailNotificationsEnabled: [notificationPreferences.emailNotificationsEnabled], + emailNotificationType: [notificationPreferences.emailNotificationType], + emailNotifications: [notificationPreferences.emailNotifications], + inAppNotifications: [notificationPreferences.inAppNotifications], + }); } } diff --git a/apps/red-ui/src/app/modules/account/translations/notifications-translations.ts b/apps/red-ui/src/app/modules/account/translations/notifications-translations.ts index 0685f92a9..167111342 100644 --- a/apps/red-ui/src/app/modules/account/translations/notifications-translations.ts +++ b/apps/red-ui/src/app/modules/account/translations/notifications-translations.ts @@ -6,4 +6,14 @@ export const notificationsTranslations: { [key: string]: string } = { weekly: _('notifications-screen.schedule.weekly'), inAppNotifications: _('notifications-screen.category.in-app-notifications'), emailNotifications: _('notifications-screen.category.email-notifications'), + documentIsSentForApproval: _('notifications-screen.options.document-is-sent-for-approval'), + documentStatusChanges: _('notifications-screen.options.document-status-changes'), + dossierStatusChanges: _('notifications-screen.options.dossier-status-changes'), + requestToJoinTheDossier: _('notifications-screen.options.request-to-join-the-dossier'), + whenADocumentIsApproved: _('notifications-screen.options.when-a-document-is-approved'), + whenADocumentIsAssignedToAReviewer: _('notifications-screen.options.when-a-document-is-assigned-to-a-reviewer'), + whenADocumentIsSentForApproval: _('notifications-screen.options.when-a-document-is-sent-for-approval'), + whenAReviewerIsUnassignedFromADocument: _('notifications-screen.options.when-a-reviewer-is-unassigned-from-a-document'), + whenIAmAssignedOnADocument: _('notifications-screen.options.when-i-am-assigned-on-a-document'), + whenIAmUnassignedFromADocument: _('notifications-screen.options.when-i-am-unassigned-from-a-document'), } as const; diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index 89f0532db..4cd21ba90 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -295,7 +295,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { } private _setSelectionMode(): void { - const textTool = (this.instance.Core.Tools.TextTool) as TextTool; + const textTool = ( this.instance.Core.Tools.TextTool) as TextTool; textTool.SELECTION_MODE = this._configService.values.SELECTION_MODE; } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/screen/dossiers-listing-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/screen/dossiers-listing-screen.component.ts index 09e2e3e0b..4a5321717 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/screen/dossiers-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/screen/dossiers-listing-screen.component.ts @@ -38,8 +38,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service'; }) export class DossiersListingScreenComponent extends ListingComponent - implements OnInit, AfterViewInit, OnDestroy, OnAttach, OnDetach -{ + implements OnInit, AfterViewInit, OnDestroy, OnAttach, OnDetach { readonly currentUser = this._userService.currentUser; readonly tableColumnConfigs = this._configService.tableConfig; readonly tableHeaderLabel = _('dossier-listing.table-header.title'); diff --git a/apps/red-ui/src/app/modules/dossier/shared/components/needs-work-badge/needs-work-badge.component.ts b/apps/red-ui/src/app/modules/dossier/shared/components/needs-work-badge/needs-work-badge.component.ts index 7fe83e885..847c1e6c1 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/components/needs-work-badge/needs-work-badge.component.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/components/needs-work-badge/needs-work-badge.component.ts @@ -45,7 +45,7 @@ export class NeedsWorkBadgeComponent { } get hasAnnotationComments(): boolean { - return this.needsWorkInput instanceof File && (this.needsWorkInput).hasAnnotationComments; + return this.needsWorkInput instanceof File && ( this.needsWorkInput).hasAnnotationComments; } reanalysisRequired() { diff --git a/apps/red-ui/src/app/services/notification-preferences.service.ts b/apps/red-ui/src/app/services/notification-preferences.service.ts index 11c8c0eb2..e85a2fc91 100644 --- a/apps/red-ui/src/app/services/notification-preferences.service.ts +++ b/apps/red-ui/src/app/services/notification-preferences.service.ts @@ -12,6 +12,10 @@ export class NotificationPreferencesService extends GenericService { } getNotificationPreferences(): Observable { - return super._getOne([this._userService.currentUser.id]); + return super.get(); + } + + updateNotificationPreferences(body: any): Observable { + return super._post(body); } } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 95323132d..facb109d3 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -279,7 +279,9 @@ export class AppStateService { } private _getDictionaryFor(dossier: IDossier) { - return this._dictionaryService.getFor(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId).toPromise(); + return this._dictionaryService.getFor(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId) + .pipe(catchError(() => of({ type: '' }))) + .toPromise(); } private _getDictionaryDataForDossierTemplate$(dossierTemplateId: string): Observable<{ [key: string]: any }> { diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 4b4441fbb..d1e68990c 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,7 +1,7 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dev-06.iqser.cloud/redaction-gateway-v1", + "API_URL": "https://red-staging.iqser.cloud/redaction-gateway-v1", "APP_NAME": "RedactManager", "AUTO_READ_TIME": 1.5, "BACKEND_APP_VERSION": "4.4.40", @@ -17,7 +17,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dev-06.iqser.cloud/auth/realms/redaction", + "OAUTH_URL": "https://red-staging.iqser.cloud/auth/realms/redaction", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural" } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 929c0daa2..2e0d25652 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1287,9 +1287,9 @@ "in-app-notifications": "In-App Notifications" }, "groups": { - "dossiers-you-are-approver-on": "Dossiers you are approver on", - "dossiers-you-are-reviewer-on": "Dossiers you are reviewer on", - "dossiers-you-own": "Dossiers you own" + "approver": "Dossiers you are approver on", + "own": "Dossiers you own", + "reviewer": "Dossiers you are reviewer on" }, "options-title": "Choose on which category you want to be notified", "options": {