From 3fa7b364a683ade0676ed01281962ed01ee0f09a Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 2 Aug 2023 17:16:00 +0300 Subject: [PATCH] Update get tables feature --- .../preferences/preferences.component.html | 10 +++++++++- .../screens/preferences/preferences.component.ts | 15 +++++++++++++-- .../file-preview/services/tables.service.ts | 13 +++++-------- .../src/app/users/user-preference.service.ts | 5 +++++ apps/red-ui/src/assets/config/config.json | 4 ++-- apps/red-ui/src/assets/i18n/redact/de.json | 1 + apps/red-ui/src/assets/i18n/redact/en.json | 1 + apps/red-ui/src/assets/i18n/scm/de.json | 1 + apps/red-ui/src/assets/i18n/scm/en.json | 1 + 9 files changed, 38 insertions(+), 13 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html index 26f5d5bfa..46054815e 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html @@ -8,17 +8,25 @@ {{ 'preferences-screen.form.auto-expand-filters-on-action' | translate }} +
{{ 'preferences-screen.form.show-suggestions-in-preview' | translate }}
-
+ +
{{ 'preferences-screen.form.open-structured-view-by-default' | translate }}
+ +
+ + +
+

{{ 'preferences-screen.warnings-subtitle' | translate }}

{{ 'preferences-screen.warnings-description' | translate }}

diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts index 3880756bc..025b79e6d 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts @@ -11,6 +11,7 @@ interface PreferencesForm { autoExpandFiltersOnActions: boolean; displaySuggestionsInPreview: boolean; openStructuredComponentManagementDialogByDefault: boolean; + tableExtractionType: string; // warnings preferences unapprovedSuggestionsWarning: boolean; loadAllAnnotationsWarning: boolean; @@ -39,10 +40,10 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { readonly roles = Roles; constructor( + route: ActivatedRoute, readonly userPreferenceService: UserPreferenceService, private readonly _formBuilder: FormBuilder, private readonly _permissionsService: IqserPermissionsService, - private readonly _route: ActivatedRoute, private readonly _changeRef: ChangeDetectorRef, private readonly _loadingService: LoadingService, ) { @@ -54,6 +55,7 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { openStructuredComponentManagementDialogByDefault: [ this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault(), ], + tableExtractionType: [this.userPreferenceService.getTableExtractionType()], // warnings preferences unapprovedSuggestionsWarning: [this.userPreferenceService.getUnapprovedSuggestionsWarning()], loadAllAnnotationsWarning: [this.userPreferenceService.getBool(PreferencesKeys.loadAllAnnotationsWarning)], @@ -63,8 +65,12 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { this.form.disable(); } + if (!this._permissionsService.has(Roles.getTables)) { + this.form.controls.tableExtractionType.disable(); + } + this.initialFormValue = this.form.getRawValue(); - this.currentScreen = _route.snapshot.data.screen; + this.currentScreen = route.snapshot.data.screen; } ngOnInit() { @@ -88,6 +94,10 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { await this.userPreferenceService.toggleUnapprovedSuggestionsWarning(); } + if (this.form.controls.tableExtractionType.value !== this.userPreferenceService.getTableExtractionType()) { + await this.userPreferenceService.save(PreferencesKeys.tableExtractionType, this.form.controls.tableExtractionType.value); + } + if ( this.form.controls.loadAllAnnotationsWarning.value !== this.userPreferenceService.getBool(PreferencesKeys.loadAllAnnotationsWarning) @@ -111,6 +121,7 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { displaySuggestionsInPreview: this.userPreferenceService.getDisplaySuggestionsInPreview(), openStructuredComponentManagementDialogByDefault: this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault(), + tableExtractionType: this.userPreferenceService.getTableExtractionType(), unapprovedSuggestionsWarning: this.userPreferenceService.getUnapprovedSuggestionsWarning(), loadAllAnnotationsWarning: this.userPreferenceService.getBool(PreferencesKeys.loadAllAnnotationsWarning), }); diff --git a/apps/red-ui/src/app/modules/file-preview/services/tables.service.ts b/apps/red-ui/src/app/modules/file-preview/services/tables.service.ts index 609b8f3fb..7bd4ec0bd 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/tables.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/tables.service.ts @@ -2,7 +2,7 @@ import { inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { firstValueFrom } from 'rxjs'; import { map } from 'rxjs/operators'; -import { log } from '@common-ui/utils'; +import { UserPreferenceService } from '@users/user-preference.service'; export interface BoundingBox { readonly x: number; @@ -32,15 +32,12 @@ export class TablesService { readonly #http = inject(HttpClient); readonly #serviceName = 'table-provider'; readonly #defaultUrl = 'tables'; + readonly #userPreferencesService = inject(UserPreferenceService); get(dossierId: string, fileId: string, pageNumber: number) { const url = `/${this.#serviceName}/${encodeURI(this.#defaultUrl)}/${dossierId}/${fileId}`; - const request$ = this.#http.post(url, { pageNumber, tableExtractionType: 'STABLE' }); - return firstValueFrom( - request$.pipe( - map(response => response.tables), - log('TablesService.get'), - ), - ); + const body = { pageNumber, tableExtractionType: this.#userPreferencesService.getTableExtractionType() }; + const request$ = this.#http.post(url, body); + return firstValueFrom(request$.pipe(map(response => response.tables))); } } diff --git a/apps/red-ui/src/app/users/user-preference.service.ts b/apps/red-ui/src/app/users/user-preference.service.ts index 4f8423e91..fedf90503 100644 --- a/apps/red-ui/src/app/users/user-preference.service.ts +++ b/apps/red-ui/src/app/users/user-preference.service.ts @@ -11,6 +11,7 @@ export const PreferencesKeys = { unapprovedSuggestionsWarning: 'Unapproved-Suggestions-Warning', loadAllAnnotationsWarning: 'Load-All-Annotations-Warning', openStructuredComponentManagementDialogByDefault: 'Open-Structured-Component-Management-By-Default', + tableExtractionType: 'Table-Extraction-Type', } as const; @Injectable({ @@ -92,4 +93,8 @@ export class UserPreferenceService extends IqserUserPreferenceService { async saveFilesListingMode(listingMode: ListingMode): Promise { await this.save(PreferencesKeys.filesListingMode, listingMode); } + + getTableExtractionType() { + return this._getAttribute(PreferencesKeys.tableExtractionType, 'EXPERIMENTAL_IF_MISSING'); + } } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 9734775ed..a1bd20386 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://dan.iqser.cloud", + "API_URL": "https://dom1.iqser.cloud", "APP_NAME": "RedactManager", "IS_DOCUMINE": false, "AUTO_READ_TIME": 3, @@ -12,7 +12,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dan.iqser.cloud/auth", + "OAUTH_URL": "https://dom1.iqser.cloud/auth", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index c592fb7a6..945a774fe 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1951,6 +1951,7 @@ "load-all-annotations-warning": "", "open-structured-view-by-default": "", "show-suggestions-in-preview": "", + "table-extraction-type": "", "unapproved-suggestions-warning": "" }, "label": "", diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 259b6fed9..1d31bc6fb 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1951,6 +1951,7 @@ "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", "open-structured-view-by-default": "Display structured component management modal by default", "show-suggestions-in-preview": "Display suggestions in document preview", + "table-extraction-type": "Table extraction type", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" }, "label": "Preferences", diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index c43325f0c..c52f9eeef 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1951,6 +1951,7 @@ "load-all-annotations-warning": "", "open-structured-view-by-default": "", "show-suggestions-in-preview": "", + "table-extraction-type": "", "unapproved-suggestions-warning": "" }, "label": "", diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 593d4cec3..e9817afce 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1951,6 +1951,7 @@ "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", "open-structured-view-by-default": "Display Component View by default when opening a document", "show-suggestions-in-preview": "Display suggestions in document preview", + "table-extraction-type": "Table extraction type", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" }, "label": "Preferences",