diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html
index cd67148ea..86b651106 100644
--- a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html
+++ b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html
@@ -42,9 +42,9 @@
{{ entry.componentValues[0].valueDescription }}
-
+
- {
this._loadingService.start();
const componentLogData = await firstValueFrom(
- this._componentLogService.getComponentLogData(this.data.file.dossierId, this.data.file.fileId),
+ this._componentLogService.getComponentLogData(
+ this.data.file.dossierTemplateId,
+ this.data.file.dossierId,
+ this.data.file.fileId,
+ ),
);
this.componentLogData.set(componentLogData);
this._loadingService.stop();
diff --git a/apps/red-ui/src/app/services/files/component-log.service.ts b/apps/red-ui/src/app/services/files/component-log.service.ts
index bd5c9eec4..9299c9373 100644
--- a/apps/red-ui/src/app/services/files/component-log.service.ts
+++ b/apps/red-ui/src/app/services/files/component-log.service.ts
@@ -4,20 +4,24 @@ import { catchError, map, tap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { HttpHeaders } from '@angular/common/http';
import { saveAs } from 'file-saver';
-import { ComponentLogEntry, IComponentLogData, IComponentLogEntry } from '@red/domain';
-import { filterEach, mapEach } from '@common-ui/utils';
+import { ComponentDetails, ComponentLogEntry, IComponentLogData, IComponentLogEntry } from '@red/domain';
+import { mapEach } from '@common-ui/utils';
@Injectable({ providedIn: 'root' })
export class ComponentLogService extends GenericService {
- protected readonly _defaultModelPath = 'import-redactions';
+ protected readonly _defaultModelPath = '';
- getComponentLogData(dossierId: string, fileId: string): Observable {
- return this._getOne([dossierId, fileId], 'componentLog').pipe(
- map(data => data.componentLogEntries),
- catchError(() => of({} as IComponentLogEntry[])),
- filterEach(log => !!log.componentValues[0].componentLogEntityReferences.length),
- mapEach(log => new ComponentLogEntry(log)),
- );
+ getComponentLogData(dossierTemplateId: string, dossierId: string, fileId: string): Observable {
+ return this._http
+ .get(`/api/dossier-templates/${dossierTemplateId}/dossiers/${dossierId}/files/${fileId}/components`, {
+ params: { includeDetails: true },
+ })
+ .pipe(
+ map(data => data.componentDetails),
+ catchError(() => of({} as ComponentDetails)),
+ map(componentDetails => this.#filterComponentDetails(componentDetails)),
+ mapEach(log => new ComponentLogEntry(log)),
+ );
}
override(dossierId: string, fileId: string, componentOverrides: Record): Observable {
@@ -28,8 +32,8 @@ export class ComponentLogService extends GenericService {
return this._post({ components }, `componentLog/override/revert/${dossierId}/${fileId}`);
}
- exportJSON(dossierId: string, fileId: string, name: string): Observable {
- return this.getComponentLogData(dossierId, fileId).pipe(
+ exportJSON(dossierTemplateId: string, dossierId: string, fileId: string, name: string): Observable {
+ return this.getComponentLogData(dossierTemplateId, dossierId, fileId).pipe(
tap(data => {
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
saveAs(blob, name + '.component_log.json');
@@ -37,8 +41,8 @@ export class ComponentLogService extends GenericService {
);
}
- exportXML(dossierId: string, fileId: string, name: string): Observable {
- return this._getComponentLogDataAsXML(dossierId, fileId).pipe(
+ exportXML(dossierTemplateId, dossierId: string, fileId: string, name: string): Observable {
+ return this.#getComponentLogDataAsXML(dossierTemplateId, dossierId, fileId).pipe(
tap(data => {
const blob = new Blob([data], { type: 'application/xml' });
saveAs(blob, name + '.component_log.xml');
@@ -46,16 +50,23 @@ export class ComponentLogService extends GenericService {
);
}
- private _getComponentLogDataAsXML(dossierId: string, fileId: string) {
- const entityPath = [dossierId, fileId].map(item => encodeURIComponent(item)).join('/');
-
+ #getComponentLogDataAsXML(dossierTemplateId: string, dossierId: string, fileId: string) {
let headers = new HttpHeaders();
headers = headers.set('accept', 'application/xml');
- return this._http.get(`/${this._serviceName}/${encodeURI('componentLog')}/${entityPath}`, {
+ return this._http.get(`/api/dossier-templates/${dossierTemplateId}/dossiers/${dossierId}/files/${fileId}/components`, {
headers: headers,
responseType: 'text',
observe: 'body',
});
}
+
+ #filterComponentDetails(componentDetails: ComponentDetails): IComponentLogEntry[] {
+ return Object.keys(componentDetails)
+ .filter(function (key) {
+ const component = componentDetails[key];
+ return !!component.componentValues[0].entityReferences.length;
+ })
+ .reduce((res, key) => (res.push(componentDetails[key]), res), []);
+ }
}
diff --git a/libs/red-domain/src/lib/component-log/component-log-data.ts b/libs/red-domain/src/lib/component-log/component-log-data.ts
index 005bc3a71..691b4e742 100644
--- a/libs/red-domain/src/lib/component-log/component-log-data.ts
+++ b/libs/red-domain/src/lib/component-log/component-log-data.ts
@@ -1,7 +1,10 @@
-import { IComponentLogEntry } from './component-log-entry';
+import { ComponentDetails } from './component-log-entry';
export interface IComponentLogData {
- analysisNumber: number;
- componentRulesVersion: number;
- componentLogEntries: Array;
+ filename: string | null;
+ fileId: string;
+ dossierId: string;
+ dossierTemplateId: string;
+ components: Record>;
+ componentDetails: ComponentDetails;
}
diff --git a/libs/red-domain/src/lib/component-log/component-log-entry.ts b/libs/red-domain/src/lib/component-log/component-log-entry.ts
index 223b9b647..1504948e3 100644
--- a/libs/red-domain/src/lib/component-log/component-log-entry.ts
+++ b/libs/red-domain/src/lib/component-log/component-log-entry.ts
@@ -1,5 +1,7 @@
import { ComponentValue, IComponentValue } from './component-value';
+export type ComponentDetails = Record>;
+
export interface IComponentLogEntry {
name: string;
componentValues: IComponentValue[];
diff --git a/libs/red-domain/src/lib/component-log/component-value.ts b/libs/red-domain/src/lib/component-log/component-value.ts
index efad62032..ec00cf67f 100644
--- a/libs/red-domain/src/lib/component-log/component-value.ts
+++ b/libs/red-domain/src/lib/component-log/component-value.ts
@@ -1,4 +1,4 @@
-export interface ComponentLogEntityReference {
+export interface EntityReference {
readonly id: string;
readonly type: string;
readonly entityRuleId: string;
@@ -10,7 +10,7 @@ export interface IComponentValue {
readonly originalValue: string;
readonly valueDescription: string;
readonly componentRuleId: string;
- readonly componentLogEntityReferences: ComponentLogEntityReference[];
+ readonly entityReferences: EntityReference[];
}
export class ComponentValue implements IComponentValue {
@@ -18,13 +18,13 @@ export class ComponentValue implements IComponentValue {
readonly originalValue: string;
readonly valueDescription: string;
readonly componentRuleId: string;
- readonly componentLogEntityReferences: ComponentLogEntityReference[];
+ readonly entityReferences: EntityReference[];
constructor(value: IComponentValue) {
this.value = value.value;
this.originalValue = value.originalValue;
this.valueDescription = value.valueDescription;
this.componentRuleId = value.componentRuleId;
- this.componentLogEntityReferences = value.componentLogEntityReferences ?? [];
+ this.entityReferences = value.entityReferences ?? [];
}
}