diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html
index 88ec0641b..52ade2630 100644
--- a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html
+++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html
@@ -13,8 +13,8 @@
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts
index 62a8119ab..d5ffaae8b 100644
--- a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts
+++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts
@@ -1,10 +1,9 @@
import { Component, Inject, OnInit } from '@angular/core';
-import { BaseDialogComponent, IconButtonTypes } from '@iqser/common-ui';
+import { BaseDialogComponent, CircleButtonTypes } from '@iqser/common-ui';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { RssService } from '@services/files/rss.service';
-import { IFile, IRssEntry } from '@red/domain';
+import { IFile, RssEntry, RssResult } from '@red/domain';
import { BehaviorSubject, firstValueFrom } from 'rxjs';
-import { map } from 'rxjs/operators';
import { FilesMapService } from '@services/files/files-map.service';
import { UserPreferenceService } from '@users/user-preference.service';
import { KeyValue } from '@angular/common';
@@ -18,9 +17,9 @@ interface RssData {
styleUrls: ['./rss-dialog.component.scss'],
})
export class RssDialogComponent extends BaseDialogComponent implements OnInit {
- readonly iconButtonTypes = IconButtonTypes;
+ readonly circleButtonTypes = CircleButtonTypes;
- rssData$ = new BehaviorSubject
(null);
+ rssData$ = new BehaviorSubject(null);
constructor(
protected readonly _dialogRef: MatDialogRef,
@@ -36,7 +35,7 @@ export class RssDialogComponent extends BaseDialogComponent implements OnInit {
await this.#loadData();
}
- originalOrder = (a: KeyValue, b: KeyValue): number => 0;
+ originalOrder = (a: KeyValue, b: KeyValue): number => 0;
exportJSON() {
this._rssService.exportJSON(this.data.file.dossierId, this.data.file.fileId, this.data.file.filename).subscribe();
@@ -58,38 +57,21 @@ export class RssDialogComponent extends BaseDialogComponent implements OnInit {
this.exportJSON();
}
- async undo(entry: KeyValue) {
+ async undo(originalKey: string) {
this._loadingService.start();
- await firstValueFrom(this._rssService.revertOverride(this.data.file.dossierId, this.data.file.fileId, [entry.value.originalKey]));
+ await firstValueFrom(this._rssService.revertOverride(this.data.file.dossierId, this.data.file.fileId, [originalKey]));
await this.#loadData();
}
- async saveEdit(event: string, entry: KeyValue) {
+ async saveEdit(event: string, originalKey: string) {
this._loadingService.start();
- await firstValueFrom(
- this._rssService.override(this.data.file.dossierId, this.data.file.fileId, { [entry.value.originalKey]: event }),
- );
+ await firstValueFrom(this._rssService.override(this.data.file.dossierId, this.data.file.fileId, { [originalKey]: event }));
await this.#loadData();
}
async #loadData(): Promise {
this._loadingService.start();
- const rssData = await firstValueFrom(
- this._rssService.getRSSData(this.data.file.dossierId, this.data.file.fileId).pipe(
- map(entry => {
- const mapped = {};
- for (const key of Object.keys(entry.result)) {
- const newKey = key.replace(new RegExp('_', 'g'), ' ');
- (entry.result[key]).originalKey = key;
- mapped[newKey] = entry.result[key];
- }
- return {
- filaName: entry.filaName,
- result: mapped,
- };
- }),
- ),
- );
+ const rssData = await firstValueFrom(this._rssService.getRSSData(this.data.file.dossierId, this.data.file.fileId));
this.rssData$.next(rssData);
this._loadingService.stop();
}
diff --git a/apps/red-ui/src/app/services/files/rss.service.ts b/apps/red-ui/src/app/services/files/rss.service.ts
index 25f60ea1d..835f2c36c 100644
--- a/apps/red-ui/src/app/services/files/rss.service.ts
+++ b/apps/red-ui/src/app/services/files/rss.service.ts
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { GenericService, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
-import { IRssData, IRssEntry } from '@red/domain';
+import { IRssData, IRssEntry, RssEntry } from '@red/domain';
import { catchError, map, tap } from 'rxjs/operators';
-import { of } from 'rxjs';
+import { Observable, of } from 'rxjs';
import { HttpHeaders } from '@angular/common/http';
import { saveAs } from 'file-saver';
@@ -11,19 +11,55 @@ export class RssService extends GenericService {
protected readonly _defaultModelPath = 'import-redactions';
@Validate()
- getRSSData(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
+ getRSSData(@RequiredParam() dossierId: string, @RequiredParam() fileId: string): Observable {
const queryParams: QueryParam[] = [];
queryParams.push({ key: 'fileId', value: fileId });
- const rssData$ = this._getOne([dossierId], 'rss/detailed', queryParams);
- return rssData$.pipe(
+ return this._getOne([dossierId], 'rss/detailed', queryParams).pipe(
map(data => data.files[0]),
catchError(() => of({} as IRssEntry)),
+ map(data => new RssEntry(data)),
);
}
@Validate()
- getRSSDataAsXML(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
+ override(
+ @RequiredParam() dossierId: string,
+ @RequiredParam() fileId: string,
+ @RequiredParam() componentOverrides: Record,
+ ): Observable {
+ return this._post({ componentOverrides }, `rss/override/${dossierId}/${fileId}`);
+ }
+
+ @Validate()
+ revertOverride(
+ @RequiredParam() dossierId: string,
+ @RequiredParam() fileId: string,
+ @RequiredParam() components: string[],
+ ): Observable {
+ return this._post({ components }, `rss/override/revert/${dossierId}/${fileId}`);
+ }
+
+ exportJSON(dossierId: string, fileId: string, name: string): Observable {
+ return this.getRSSData(dossierId, fileId).pipe(
+ tap(data => {
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
+ saveAs(blob, name + '.rss.json');
+ }),
+ );
+ }
+
+ exportXML(dossierId: string, fileId: string, name: string): Observable {
+ return this._getRSSDataAsXML(dossierId, fileId).pipe(
+ tap(data => {
+ const blob = new Blob([data], { type: 'application/xml' });
+ saveAs(blob, name + '.rss.xml');
+ }),
+ );
+ }
+
+ @Validate()
+ private _getRSSDataAsXML(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
const queryParams: QueryParam[] = [];
queryParams.push({ key: 'fileId', value: fileId });
@@ -39,36 +75,4 @@ export class RssService extends GenericService {
observe: 'body',
});
}
-
- @Validate()
- override(
- @RequiredParam() dossierId: string,
- @RequiredParam() fileId: string,
- @RequiredParam() componentOverrides: Record,
- ) {
- return this._post({ componentOverrides }, `rss/override/${dossierId}/${fileId}`);
- }
-
- @Validate()
- revertOverride(@RequiredParam() dossierId: string, @RequiredParam() fileId: string, @RequiredParam() components: string[]) {
- return this._post({ components }, `rss/override/revert/${dossierId}/${fileId}`);
- }
-
- exportJSON(dossierId: string, fileId: string, name: string) {
- return this.getRSSData(dossierId, fileId).pipe(
- tap(data => {
- const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
- saveAs(blob, name + '.rss.json');
- }),
- );
- }
-
- exportXML(dossierId: string, fileId: string, name: string) {
- return this.getRSSDataAsXML(dossierId, fileId).pipe(
- tap(data => {
- const blob = new Blob([data], { type: 'application/xml' });
- saveAs(blob, name + '.rss.xml');
- }),
- );
- }
}
diff --git a/libs/red-domain/src/lib/rss/index.ts b/libs/red-domain/src/lib/rss/index.ts
index 3ca054201..b39f0579d 100644
--- a/libs/red-domain/src/lib/rss/index.ts
+++ b/libs/red-domain/src/lib/rss/index.ts
@@ -1,2 +1,3 @@
export * from './rss-data';
export * from './rss-entry';
+export * from './rss-result';
diff --git a/libs/red-domain/src/lib/rss/rss-entry.ts b/libs/red-domain/src/lib/rss/rss-entry.ts
index 845a4202e..0a8bff434 100644
--- a/libs/red-domain/src/lib/rss/rss-entry.ts
+++ b/libs/red-domain/src/lib/rss/rss-entry.ts
@@ -1,4 +1,23 @@
+import { IRssResult, RssResult } from './rss-result';
+
export interface IRssEntry {
- filaName: string;
- result: { [key: string]: string };
+ filename: string;
+ result: Record;
+}
+
+export class RssEntry implements IRssEntry {
+ readonly filename: string;
+ readonly result: Record;
+
+ constructor(entry: IRssEntry) {
+ this.filename = entry.filename;
+
+ const mappedResult: Record = {};
+ for (const key of Object.keys(entry.result)) {
+ const newKey = key.replace(new RegExp('_', 'g'), ' ');
+ console.log([key, newKey]);
+ mappedResult[newKey] = new RssResult(entry.result[key], key);
+ }
+ this.result = mappedResult;
+ }
}
diff --git a/libs/red-domain/src/lib/rss/rss-result.ts b/libs/red-domain/src/lib/rss/rss-result.ts
new file mode 100644
index 000000000..5b82bb769
--- /dev/null
+++ b/libs/red-domain/src/lib/rss/rss-result.ts
@@ -0,0 +1,27 @@
+export interface IScmAnnotation {
+ readonly type: string;
+ readonly pages: number[];
+ readonly ruleNumber: number;
+ readonly reason: string;
+}
+
+export interface IRssResult {
+ readonly value: string;
+ readonly originalValue: string;
+ readonly scmAnnotations: IScmAnnotation[];
+ readonly transformation: string;
+}
+
+export class RssResult implements IRssResult {
+ readonly value: string;
+ readonly originalValue: string;
+ readonly scmAnnotations: IScmAnnotation[];
+ readonly transformation: string;
+
+ constructor(result: IRssResult, readonly originalKey: string) {
+ this.value = result.value;
+ this.originalValue = result.originalValue;
+ this.scmAnnotations = result.scmAnnotations;
+ this.transformation = result.transformation;
+ }
+}