diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 6c22952fd..8458e8a21 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -13,6 +13,7 @@ import { ManualAnnotationDialogComponent } from './manual-redaction-dialog/manua import { ManualAnnotationService } from '../screens/file/service/manual-annotation.service'; import { ProjectWrapper } from '../state/model/project.wrapper'; import { AddEditDictionaryDialogComponent } from '../screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component'; +import { DEFAULT_RUL_SET_UUID } from '../utils/rule-set-default'; const dialogConfig = { width: '662px', @@ -166,7 +167,7 @@ export class DialogService { const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); ref.afterClosed().subscribe(async (result) => { if (result) { - await this._dictionaryControllerService.deleteType(dictionary.type).toPromise(); + await this._dictionaryControllerService.deleteType(dictionary.type, DEFAULT_RUL_SET_UUID).toPromise(); if (cb) cb(); } }); diff --git a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 94e114440..fcba3769e 100644 --- a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -10,6 +10,7 @@ import { ManualRedactionEntryWrapper } from '../../screens/file/model/manual-red import { ManualAnnotationService } from '../../screens/file/service/manual-annotation.service'; import { ManualAnnotationResponse } from '../../screens/file/model/manual-annotation-response'; import { PermissionsService } from '../../common/service/permissions.service'; +import { DEFAULT_RUL_SET_UUID } from '../../utils/rule-set-default'; export interface LegalBasisOption { label?: string; @@ -56,7 +57,7 @@ export class ManualAnnotationDialogComponent implements OnInit { ) {} async ngOnInit() { - this._legalBasisMappingControllerService.getLegalBasisMapping().subscribe((data) => { + this._legalBasisMappingControllerService.getLegalBasisMapping(DEFAULT_RUL_SET_UUID).subscribe((data) => { for (const key of Object.keys(data.reasonByLegalBasis)) { this.legalOptions.push({ legalBasis: key, diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts index c6b9704b3..b7bb110f7 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts @@ -6,6 +6,7 @@ import { DictionaryControllerService, TypeValue } from '@redaction/red-ui-http'; import { Observable } from 'rxjs'; import { NotificationService, NotificationType } from '../../../../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; +import { DEFAULT_RUL_SET_UUID } from '../../../../utils/rule-set-default'; @Component({ selector: 'redaction-add-edit-dictionary-dialog', @@ -59,10 +60,10 @@ export class AddEditDictionaryDialogComponent { let observable: Observable; if (this.dictionary) { // edit mode - observable = this._dictionaryControllerService.updateType(typeValue, typeValue.type); + observable = this._dictionaryControllerService.updateType(typeValue, typeValue.type, DEFAULT_RUL_SET_UUID); } else { // create mode - observable = this._dictionaryControllerService.addType(typeValue); + observable = this._dictionaryControllerService.addType(typeValue, DEFAULT_RUL_SET_UUID); } // diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts index 56dca53e6..f3a649bc7 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts @@ -10,6 +10,7 @@ import { PermissionsService } from '../../../common/service/permissions.service' import { FormBuilder, FormGroup } from '@angular/forms'; import { debounce } from '../../../utils/debounce'; import { UserPreferenceService } from '../../../common/service/user-preference.service'; +import { DEFAULT_RUL_SET_UUID } from '../../../utils/rule-set-default'; @Component({ selector: 'redaction-dictionary-listing-screen', @@ -57,7 +58,7 @@ export class DictionaryListingScreenComponent implements OnInit { this.displayedDictionaries = [...this.dictionaries]; const dataObs = []; this.dictionaries.forEach((item) => { - const observable = this._dictionaryControllerService.getDictionaryForType(item.type).pipe( + const observable = this._dictionaryControllerService.getDictionaryForType(item.type, DEFAULT_RUL_SET_UUID).pipe( tap((values) => { item.entries = values.entries ? values.entries : []; }) diff --git a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.ts b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.ts index 42aec8f96..08edd23d5 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.ts +++ b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.ts @@ -10,6 +10,7 @@ import { NotificationService, NotificationType } from '../../../notification/not import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { saveAs } from 'file-saver'; +import { DEFAULT_RUL_SET_UUID } from '../../../utils/rule-set-default'; import { ComponentHasChanges } from '../../../utils/can-deactivate.guard'; declare var ace; @@ -69,7 +70,7 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges { } private _initialize() { - this._dictionaryControllerService.getDictionaryForType(this.dictionary.type).subscribe( + this._dictionaryControllerService.getDictionaryForType(this.dictionary.type, DEFAULT_RUL_SET_UUID).subscribe( (data) => { this.initialDictionaryEntries = data.entries.sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' })); this.revert(); @@ -185,9 +186,9 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges { this.processing = true; let obs: Observable; if (entriesToAdd.length > 0) { - obs = this._dictionaryControllerService.addEntry(entriesToAdd, this.dictionary.type, true); + obs = this._dictionaryControllerService.addEntry(entriesToAdd, this.dictionary.type, DEFAULT_RUL_SET_UUID, true); } else { - obs = this._dictionaryControllerService.deleteEntries(this.initialDictionaryEntries, this.dictionary.type); + obs = this._dictionaryControllerService.deleteEntries(this.initialDictionaryEntries, this.dictionary.type, DEFAULT_RUL_SET_UUID); } obs.subscribe( diff --git a/apps/red-ui/src/app/screens/admin/rules-screen/rules-screen.component.ts b/apps/red-ui/src/app/screens/admin/rules-screen/rules-screen.component.ts index e1fef741a..2e6883b14 100644 --- a/apps/red-ui/src/app/screens/admin/rules-screen/rules-screen.component.ts +++ b/apps/red-ui/src/app/screens/admin/rules-screen/rules-screen.component.ts @@ -5,6 +5,7 @@ import { RulesControllerService } from '@redaction/red-ui-http'; import { NotificationService, NotificationType } from '../../../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; import { saveAs } from 'file-saver'; +import { DEFAULT_RUL_SET_UUID } from '../../../utils/rule-set-default'; import { ComponentHasChanges } from '../../../utils/can-deactivate.guard'; declare var ace; @@ -41,7 +42,7 @@ export class RulesScreenComponent extends ComponentHasChanges { } private _initialize() { - this._rulesControllerService.downloadRules().subscribe( + this._rulesControllerService.downloadRules(DEFAULT_RUL_SET_UUID).subscribe( (rules) => { this.rules = rules.rules; this.revert(); @@ -83,7 +84,7 @@ export class RulesScreenComponent extends ComponentHasChanges { public async save(): Promise { this.processing = true; - this._rulesControllerService.uploadRules({ rules: this.editorComponent.getEditor().getValue() }).subscribe( + this._rulesControllerService.uploadRules({ rules: this.editorComponent.getEditor().getValue() }, DEFAULT_RUL_SET_UUID).subscribe( () => { this._initialize(); this._notificationService.showToastNotification(this._translateService.instant('rules-screen.success.generic'), null, NotificationType.SUCCESS); diff --git a/apps/red-ui/src/app/screens/admin/watermark-screen/watermark-screen.component.ts b/apps/red-ui/src/app/screens/admin/watermark-screen/watermark-screen.component.ts index 7b58743b1..9567fce5d 100644 --- a/apps/red-ui/src/app/screens/admin/watermark-screen/watermark-screen.component.ts +++ b/apps/red-ui/src/app/screens/admin/watermark-screen/watermark-screen.component.ts @@ -10,6 +10,7 @@ import { debounce } from '../../../utils/debounce'; import { WatermarkControllerService, WatermarkModel } from '@redaction/red-ui-http'; import { NotificationService, NotificationType } from '../../../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; +import { DEFAULT_RUL_SET_UUID } from '../../../utils/rule-set-default'; export const DEFAULT_WATERMARK: WatermarkModel = { text: @@ -71,7 +72,7 @@ export class WatermarkScreenComponent implements OnInit { } private _loadWatermark() { - this._watermarkControllerService.getWatermark().subscribe( + this._watermarkControllerService.getWatermark(DEFAULT_RUL_SET_UUID).subscribe( (watermark) => { this._watermark = watermark; this.configForm.setValue(this._watermark); @@ -94,7 +95,7 @@ export class WatermarkScreenComponent implements OnInit { const watermark = { ...this.configForm.getRawValue() }; - this._watermarkControllerService.saveWatermark(watermark).subscribe( + this._watermarkControllerService.saveWatermark(watermark, DEFAULT_RUL_SET_UUID).subscribe( () => { this._loadWatermark(); this._notificationService.showToastNotification( 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 3dd23d04c..ef71353eb 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -20,6 +20,7 @@ import { humanize } from '../utils/functions'; import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper'; import { ProjectWrapper } from './model/project.wrapper'; import { saveAs } from 'file-saver'; +import { DEFAULT_RUL_SET_UUID } from '../utils/rule-set-default'; export interface AppState { projects: ProjectWrapper[]; @@ -35,6 +36,7 @@ export interface AppState { @Injectable({ providedIn: 'root' }) +// TODO everything needs to be stored ruleSetBased in either an Object ( Dict ) or Map Structure. export class AppStateService { private _appState: AppState; private _dictionaryData: { [key: string]: TypeValue } = null; @@ -303,7 +305,9 @@ export class AppStateService { async addOrUpdateProject(project: Project) { try { - const updatedProject = await this._projectControllerService.createProjectOrUpdateProject(project).toPromise(); + // TODO fix after adding this to the Dialog + project.ruleSetId = DEFAULT_RUL_SET_UUID; + const updatedProject = await this._projectControllerService.createOrUpdateProject(project).toPromise(); let foundProject = this._appState.projects.find((p) => p.project.projectId === updatedProject.projectId); if (foundProject) { Object.assign((foundProject.project = updatedProject)); @@ -381,7 +385,7 @@ export class AppStateService { async loadDictionaryData() { this._dictionaryData = {}; - const typeObs = this._dictionaryControllerService.getAllTypes().pipe( + const typeObs = this._dictionaryControllerService.getAllTypes(DEFAULT_RUL_SET_UUID).pipe( tap((typesResponse) => { for (const type of typesResponse.types) { this._dictionaryData[type.type] = type; @@ -389,7 +393,7 @@ export class AppStateService { } }) ); - const colorsObs = this._dictionaryControllerService.getColors().pipe( + const colorsObs = this._dictionaryControllerService.getColors(DEFAULT_RUL_SET_UUID).pipe( tap((colors) => { // declined this._dictionaryData['declined-suggestion'] = { @@ -491,8 +495,8 @@ export class AppStateService { } async updateDictionaryVersion() { - const result = await this._versionsControllerService.getVersions().toPromise(); - this._appState.dictionaryVersion = result.dictionaryVersion; - this._appState.ruleVersion = result.rulesVersion; + const result = await this._versionsControllerService.getVersions([DEFAULT_RUL_SET_UUID]).toPromise(); + this._appState.dictionaryVersion = result[DEFAULT_RUL_SET_UUID].dictionaryVersion; + this._appState.ruleVersion = result[DEFAULT_RUL_SET_UUID].rulesVersion; } } diff --git a/apps/red-ui/src/app/state/model/project.wrapper.ts b/apps/red-ui/src/app/state/model/project.wrapper.ts index b08f2f69d..76e7949db 100644 --- a/apps/red-ui/src/app/state/model/project.wrapper.ts +++ b/apps/red-ui/src/app/state/model/project.wrapper.ts @@ -28,6 +28,10 @@ export class ProjectWrapper { return this.project.description; } + get ruleSetId() { + return this.project.ruleSetId; + } + get ownerId() { return this.project.ownerId; } diff --git a/apps/red-ui/src/app/utils/rule-set-default.ts b/apps/red-ui/src/app/utils/rule-set-default.ts new file mode 100644 index 000000000..d617d1133 --- /dev/null +++ b/apps/red-ui/src/app/utils/rule-set-default.ts @@ -0,0 +1 @@ +export const DEFAULT_RUL_SET_UUID = '9b7bd575-4566-4408-984f-b26da1d2616e'; diff --git a/libs/red-ui-http/src/lib/api/ruleSetController.service.ts b/libs/red-ui-http/src/lib/api/ruleSetController.service.ts index e902e4b8f..c3d747a7f 100644 --- a/libs/red-ui-http/src/lib/api/ruleSetController.service.ts +++ b/libs/red-ui-http/src/lib/api/ruleSetController.service.ts @@ -76,7 +76,7 @@ export class RuleSetControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/rule-set/${encodeURIComponent(String(ruleSetId))}`, { + return this.httpClient.request('post', `${this.basePath}/rule-set`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers,