RULESET INTEGRATIOn with placeholder ID

This commit is contained in:
Timo 2021-01-06 15:14:59 +02:00
parent caec8cc007
commit 02798e2edd
11 changed files with 35 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,6 +28,10 @@ export class ProjectWrapper {
return this.project.description;
}
get ruleSetId() {
return this.project.ruleSetId;
}
get ownerId() {
return this.project.ownerId;
}

View File

@ -0,0 +1 @@
export const DEFAULT_RUL_SET_UUID = '9b7bd575-4566-4408-984f-b26da1d2616e';

View File

@ -76,7 +76,7 @@ export class RuleSetControllerService {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request<RuleSetModel>('post', `${this.basePath}/rule-set/${encodeURIComponent(String(ruleSetId))}`, {
return this.httpClient.request<RuleSetModel>('post', `${this.basePath}/rule-set`, {
body: body,
withCredentials: this.configuration.withCredentials,
headers: headers,