updates for integration with backend

This commit is contained in:
Valentin 2021-11-04 22:42:49 +02:00
parent ffd75f5f6f
commit 64297e1736
11 changed files with 93 additions and 152 deletions

View File

@ -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);
}
}
}

View File

@ -13,113 +13,37 @@
</div>
<form (submit)="save()" [formGroup]="formGroup">
<div class="dialog-content">
<div *ngFor="let category of notificationCategories" formGroupName="{{ category }}">
<div *ngFor="let category of notificationCategories">
<div class="iqser-input-group header w-full">
<mat-slide-toggle color="primary" formControlName="isActive">{{
<mat-slide-toggle color="primary" formControlName="{{ category }}Enabled">{{
translations[category] | translate
}}</mat-slide-toggle>
</div>
<div class="options-content" *ngIf="isFormActive(category)">
<div class="radio-container" *ngIf="getSchedule(category)">
<div class="radio-button" *ngFor="let schedule of sendSchedules">
<div class="options-content" *ngIf="isCategoryActive(category)">
<div class="radio-container" *ngIf="category === 'emailNotifications'">
<div class="radio-button" *ngFor="let type of emailNotificationTypes">
<iqser-round-checkbox
[active]="getSchedule(category).value === schedule"
(click)="setSchedule(schedule)"
[active]="getEmailNotificationType() === type"
(click)="setEmailNotificationType(type)"
>
</iqser-round-checkbox>
<span> {{ translations[schedule] | translate }} </span>
<span> {{ translations[type.toLocaleLowerCase()] | translate }} </span>
</div>
</div>
<div class="statement" translate="notifications-screen.options-title"></div>
<div class="group">
<div class="group-title" translate="notifications-screen.groups.dossiers-you-own"></div>
<div class="group" *ngFor="let key of notificationGroupsKeys; let i = index">
<div class="group-title" translate="notifications-screen.groups.{{ key }}"></div>
<div class="iqser-input-group">
<mat-checkbox
*ngFor="let preference of notificationGroupsValues[i]"
color="primary"
formControlName="dossierStatusChanges"
name="dossierStatusChanges"
[checked]="isPreferenceChecked(category, preference)"
(change)="addRemovePreference($event.checked, category, preference)"
>
{{ 'notifications-screen.options.dossier-status-changes' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="requestToJoinTheDossier"
name="requestToJoinTheDossier"
>
{{ 'notifications-screen.options.request-to-join-the-dossier' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="documentStatusChanges"
name="documentStatusChanges"
>
{{ 'notifications-screen.options.document-status-changes' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="documentIsSentForApproval"
name="documentIsSentForApproval"
>
{{ 'notifications-screen.options.document-is-sent-for-approval' | translate }}
</mat-checkbox>
</div>
</div>
<div class="group">
<div class="group-title" translate="notifications-screen.groups.dossiers-you-are-reviewer-on"></div>
<div class="iqser-input-group">
<mat-checkbox
color="primary"
formControlName="whenIAmAssignedOnADocument"
name="whenIAmAssignedOnADocument"
>
{{ 'notifications-screen.options.when-i-am-assigned-on-a-document' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="whenIAmUnassignedFromADocument"
name="whenIAmUnassignedFromADocument"
>
{{ 'notifications-screen.options.when-i-am-unassigned-from-a-document' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="whenADocumentIsApproved"
name="whenADocumentIsApproved"
>
{{ 'notifications-screen.options.when-a-document-is-approved' | translate }}
</mat-checkbox>
</div>
</div>
<div class="group">
<div class="group-title" translate="notifications-screen.groups.dossiers-you-are-approver-on"></div>
<div class="iqser-input-group">
<mat-checkbox
color="primary"
formControlName="whenADocumentIsSentForApproval"
name="whenADocumentIsSentForApproval"
>
{{ 'notifications-screen.options.when-a-document-is-sent-for-approval' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="whenADocumentIsAssignedToAReviewer"
name="whenADocumentIsAssignedToAReviewer"
>
{{ 'notifications-screen.options.when-a-document-is-assigned-to-a-reviewer' | translate }}
</mat-checkbox>
<mat-checkbox
color="primary"
formControlName="whenAReviewerIsUnassignedFromADocument"
name="whenAReviewerIsUnassignedFromADocument"
>
{{
'notifications-screen.options.when-a-reviewer-is-unassigned-from-a-document' | translate
}}
{{ translations[preference] | translate }}
</mat-checkbox>
</div>
</div>

View File

@ -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<void> {
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],
});
}
}

View File

@ -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;

View File

@ -295,7 +295,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
}
private _setSelectionMode(): void {
const textTool = (<unknown>this.instance.Core.Tools.TextTool) as TextTool;
const textTool = (<unknown> this.instance.Core.Tools.TextTool) as TextTool;
textTool.SELECTION_MODE = this._configService.values.SELECTION_MODE;
}

View File

@ -38,8 +38,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
})
export class DossiersListingScreenComponent
extends ListingComponent<Dossier>
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');

View File

@ -45,7 +45,7 @@ export class NeedsWorkBadgeComponent {
}
get hasAnnotationComments(): boolean {
return this.needsWorkInput instanceof File && (<any>this.needsWorkInput).hasAnnotationComments;
return this.needsWorkInput instanceof File && (<any> this.needsWorkInput).hasAnnotationComments;
}
reanalysisRequired() {

View File

@ -12,6 +12,10 @@ export class NotificationPreferencesService extends GenericService<any> {
}
getNotificationPreferences(): Observable<any> {
return super._getOne([this._userService.currentUser.id]);
return super.get();
}
updateNotificationPreferences(body: any): Observable<any> {
return super._post(body);
}
}

View File

@ -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 }> {

View File

@ -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"
}

View File

@ -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": {