From ccd8004321c3f8e5c448f62b20f2146712ed2634 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 18 Jan 2021 19:18:29 +0200 Subject: [PATCH] RED-894 RED-958 RED-959 RED-973 RED-974 RED-978 RED-982 --- apps/red-ui/src/app/app.module.ts | 9 +++++++-- apps/red-ui/src/app/auth/auth.module.ts | 8 +++++++- .../type-filter/type-filter.component.html | 4 ++-- .../file-preview-screen.component.html | 2 +- .../app/screens/file/model/annotation.wrapper.ts | 8 +------- .../file/service/annotation-draw.service.ts | 1 + .../service/annotation-processing.service.ts | 2 +- .../project-listing-screen.component.ts | 2 +- .../project-overview-screen.component.ts | 2 +- apps/red-ui/src/app/state/app-state.service.ts | 13 +++++++------ .../src/app/utils/translate-chart.service.ts | 2 +- apps/red-ui/src/assets/config/config.json | 4 ++-- apps/red-ui/src/assets/i18n/en.json | 16 ++++++++++------ 13 files changed, 42 insertions(+), 31 deletions(-) diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index f369554ac..009bd4ee4 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -105,6 +105,7 @@ import { RuleSetViewSwitchComponent } from './components/rule-set-view-switch/ru import { MatSliderModule } from '@angular/material/slider'; import { PendingChangesGuard } from './utils/can-deactivate.guard'; import { OverwriteFilesDialogComponent } from './dialogs/overwrite-files-dialog/overwrite-files-dialog.component'; +import { KeycloakService } from 'keycloak-angular'; export function HttpLoaderFactory(httpClient: HttpClient) { return new TranslateHttpLoader(httpClient, '/assets/i18n/', '.json'); @@ -395,8 +396,12 @@ const matImports = [ bootstrap: [AppComponent] }) export class AppModule { - constructor(private router: Router, private route: ActivatedRoute) { - route.queryParamMap.subscribe((queryParams) => { + constructor(private router: Router, private route: ActivatedRoute, private _keyCloakService: KeycloakService) { + this._configureKeyCloakRouteHandling(); + } + + private _configureKeyCloakRouteHandling() { + this.route.queryParamMap.subscribe((queryParams) => { if (queryParams.has('code') || queryParams.has('state') || queryParams.has('session_state')) { this.router.navigate([], { queryParams: { diff --git a/apps/red-ui/src/app/auth/auth.module.ts b/apps/red-ui/src/app/auth/auth.module.ts index 807c675f4..6eee501af 100644 --- a/apps/red-ui/src/app/auth/auth.module.ts +++ b/apps/red-ui/src/app/auth/auth.module.ts @@ -30,11 +30,17 @@ export function keycloakInitializer(keycloak: KeycloakService, appConfigService: }, enableBearerInterceptor: true }; - return keycloak.init(options); + return keycloak.init(options).then(() => configureAutomaticRedirectToLoginScreen(keycloak)); }); }; } +function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakService) { + keyCloakService.getKeycloakInstance().onAuthRefreshError = () => { + keyCloakService.logout(); + }; +} + @NgModule({ declarations: [], imports: [CommonModule, HttpClientModule, KeycloakAngularModule, AppConfigModule], diff --git a/apps/red-ui/src/app/components/type-filter/type-filter.component.html b/apps/red-ui/src/app/components/type-filter/type-filter.component.html index 8729eebe0..9d5afd5b4 100644 --- a/apps/red-ui/src/app/components/type-filter/type-filter.component.html +++ b/apps/red-ui/src/app/components/type-filter/type-filter.component.html @@ -1,8 +1,9 @@ + - + - {{ filter.label | translate }} diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index 65c75bf4a..f3df0d1b6 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -27,7 +27,7 @@ >
- {{ appStateService.activeFile.status.toLowerCase().replace('_', '-') | translate }} + {{ appStateService.activeFile.status | translate }} {{ 'by' | translate }}: diff --git a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts index a9c7b5fcd..9c17d0254 100644 --- a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts +++ b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts @@ -50,14 +50,8 @@ export class AnnotationWrapper { ); } - get isDictionaryBased() { - return this.isHint || this.superType === 'redaction'; - } - get descriptor() { - // TODO clarify: RED-894 - // return this.isDictionaryBased ? 'dictionary' : 'type'; - return 'type'; + return this.isModifyDictionary ? 'dictionary' : 'type'; } get hasTextAfter() { diff --git a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts index 7f203e7cd..1e9f8eef0 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts @@ -83,6 +83,7 @@ export class AnnotationDrawService { switch (superType) { case 'hint': case 'redaction': + case 'recommendation': color = this._appStateService.getDictionaryColor(dictionary); break; case 'ignore': diff --git a/apps/red-ui/src/app/screens/file/service/annotation-processing.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-processing.service.ts index 5a375b438..29e6f0ba6 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-processing.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-processing.service.ts @@ -17,7 +17,7 @@ export class AnnotationProcessingService { const filters: FilterModel[] = []; annotations?.forEach((a) => { - const topLevelFilter = a.superType !== 'hint' && a.superType !== 'redaction'; + const topLevelFilter = a.superType !== 'hint' && a.superType !== 'redaction' && a.superType !== 'recommendation'; const key = topLevelFilter ? a.superType : a.superType + a.dictionary; const filter = filterMap.get(key); if (filter) { diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts index adaa5e168..4adfae501 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts @@ -205,7 +205,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { allDistinctFileStatus.forEach((status) => { statusFilters.push({ key: status, - label: humanize(status) + label: this._translateService.instant(status) }); }); statusFilters.sort((a, b) => StatusSorter[a.key] - StatusSorter[b.key]); diff --git a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts index 0e9108b96..c8554c986 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts @@ -278,7 +278,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy { allDistinctFileStatusWrapper.forEach((status) => { statusFilters.push({ key: status, - label: humanize(status) + label: this._translateService.instant(status) }); }); 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 44f8f8049..45033ec08 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -488,6 +488,13 @@ export class AppStateService { type: 'manual', virtual: true }; + + // dictionary actions + dictionaryData['recommendation'] = { + hexColor: '#c5d3eb', + type: 'recommendation', + virtual: true + }; // dictionary actions dictionaryData['add-dictionary'] = { hexColor: '#dd4d50', @@ -533,12 +540,6 @@ export class AppStateService { virtual: true }; - dictionaryData['manual'] = { - hexColor: colors.defaultColor, - type: 'manual', - virtual: true - }; - dictionaryData['ignore'] = { hexColor: colors.notRedacted, type: 'ignore', diff --git a/apps/red-ui/src/app/utils/translate-chart.service.ts b/apps/red-ui/src/app/utils/translate-chart.service.ts index 25c15af12..a576a1af5 100644 --- a/apps/red-ui/src/app/utils/translate-chart.service.ts +++ b/apps/red-ui/src/app/utils/translate-chart.service.ts @@ -9,6 +9,6 @@ export class TranslateChartService { constructor(private readonly _translateService: TranslateService) {} public translateStatus(config: DoughnutChartConfig[]): DoughnutChartConfig[] { - return config.map((val) => ({ ...val, label: this._translateService.instant(val.label.toLowerCase().replace('_', '-')) })); + return config.map((val) => ({ ...val, label: this._translateService.instant(val.label) })); } } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index bfcb40971..969132fdd 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,5 +1,5 @@ { - "OAUTH_URL": "https://redkc-staging.iqser.cloud/auth/realms/redaction", + "OAUTH_URL": "https://redqa-auth.iqser.cloud/auth/realms/redaction", "OAUTH_CLIENT_ID": "redaction", - "API_URL": "https://timo-redaction-dev.iqser.cloud" + "API_URL": "https://redqa-api.iqser.cloud" } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index a46ac3e9c..dda113198 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -250,7 +250,7 @@ "last-updated": "Last updated: {{lastUpdated}}", "file-pending": "Pending...", "file-processing": "Processing...", - "file-error": "Scheduled for reanalysis." + "file-error": "Re-processing required" } }, "project-details": { @@ -422,14 +422,18 @@ "hide-comments": "Hide", "cancel": "Cancel" }, - "error": "Re-processing", - "unassigned": "Unassigned", - "under-review": "Under Review", - "under-approval": "Under Approval", + + "UNPROCESSED": "Unprocessed", + "REPROCESS": "Processing", + "PROCESSING": "Processing", + "ERROR": "Re-processing required", + "UNASSIGNED": "Unassigned", + "UNDER_REVIEW": "Under Review", + "UNDER_APPROVAL": "Under Approval", + "APPROVED": "Approved", "by": "by", "efsa": "EFSA Approval", "finished": "Finished", - "approved": "Approved", "submitted": "Submitted", "active": "Active", "archived": "Archived",