DM-508 - update to use the new API
This commit is contained in:
parent
80fa240731
commit
eb266fc565
@ -42,9 +42,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>{{ entry.componentValues[0].valueDescription }}</div>
|
<div>{{ entry.componentValues[0].valueDescription }}</div>
|
||||||
<div>
|
<div>
|
||||||
<ul *ngIf="entry.componentValues[0].componentLogEntityReferences; else noReferences" class="pl-0">
|
<ul *ngIf="entry.componentValues[0].entityReferences; else noReferences" class="pl-0">
|
||||||
<li
|
<li
|
||||||
*ngFor="let reference of entry.componentValues[0].componentLogEntityReferences"
|
*ngFor="let reference of entry.componentValues[0].entityReferences"
|
||||||
[innerHTML]="
|
[innerHTML]="
|
||||||
'component-log-dialog.annotations'
|
'component-log-dialog.annotations'
|
||||||
| translate
|
| translate
|
||||||
|
|||||||
@ -63,21 +63,35 @@ export class StructuredComponentManagementDialogComponent extends BaseDialogComp
|
|||||||
|
|
||||||
exportJSON() {
|
exportJSON() {
|
||||||
return firstValueFrom(
|
return firstValueFrom(
|
||||||
this._componentLogService.exportJSON(this.data.file.dossierId, this.data.file.fileId, this.data.file.filename),
|
this._componentLogService.exportJSON(
|
||||||
|
this.data.file.dossierTemplateId,
|
||||||
|
this.data.file.dossierId,
|
||||||
|
this.data.file.fileId,
|
||||||
|
this.data.file.filename,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportXML() {
|
exportXML() {
|
||||||
return firstValueFrom(
|
return firstValueFrom(
|
||||||
this._componentLogService.exportXML(this.data.file.dossierId, this.data.file.fileId, this.data.file.filename),
|
this._componentLogService.exportXML(
|
||||||
|
this.data.file.dossierTemplateId,
|
||||||
|
this.data.file.dossierId,
|
||||||
|
this.data.file.fileId,
|
||||||
|
this.data.file.filename,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async exportAllInDossier() {
|
async exportAllInDossier() {
|
||||||
const allFilesInDossier = this._filesMapService.get(this.data.file.dossierId);
|
const allFilesInDossier = this._filesMapService.get(this.data.file.dossierId);
|
||||||
for (const file of allFilesInDossier) {
|
for (const file of allFilesInDossier) {
|
||||||
await firstValueFrom(this._componentLogService.exportJSON(file.dossierId, file.fileId, file.filename));
|
await firstValueFrom(
|
||||||
await firstValueFrom(this._componentLogService.exportXML(file.dossierId, file.fileId, file.filename));
|
this._componentLogService.exportJSON(this.data.file.dossierTemplateId, file.dossierId, file.fileId, file.filename),
|
||||||
|
);
|
||||||
|
await firstValueFrom(
|
||||||
|
this._componentLogService.exportXML(this.data.file.dossierTemplateId, file.dossierId, file.fileId, file.filename),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +120,11 @@ export class StructuredComponentManagementDialogComponent extends BaseDialogComp
|
|||||||
async #loadData(): Promise<void> {
|
async #loadData(): Promise<void> {
|
||||||
this._loadingService.start();
|
this._loadingService.start();
|
||||||
const componentLogData = await firstValueFrom(
|
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.componentLogData.set(componentLogData);
|
||||||
this._loadingService.stop();
|
this._loadingService.stop();
|
||||||
|
|||||||
@ -4,20 +4,24 @@ import { catchError, map, tap } from 'rxjs/operators';
|
|||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import { ComponentLogEntry, IComponentLogData, IComponentLogEntry } from '@red/domain';
|
import { ComponentDetails, ComponentLogEntry, IComponentLogData, IComponentLogEntry } from '@red/domain';
|
||||||
import { filterEach, mapEach } from '@common-ui/utils';
|
import { mapEach } from '@common-ui/utils';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class ComponentLogService extends GenericService<void> {
|
export class ComponentLogService extends GenericService<void> {
|
||||||
protected readonly _defaultModelPath = 'import-redactions';
|
protected readonly _defaultModelPath = '';
|
||||||
|
|
||||||
getComponentLogData(dossierId: string, fileId: string): Observable<ComponentLogEntry[]> {
|
getComponentLogData(dossierTemplateId: string, dossierId: string, fileId: string): Observable<ComponentLogEntry[]> {
|
||||||
return this._getOne<IComponentLogData>([dossierId, fileId], 'componentLog').pipe(
|
return this._http
|
||||||
map(data => data.componentLogEntries),
|
.get<IComponentLogData>(`/api/dossier-templates/${dossierTemplateId}/dossiers/${dossierId}/files/${fileId}/components`, {
|
||||||
catchError(() => of({} as IComponentLogEntry[])),
|
params: { includeDetails: true },
|
||||||
filterEach(log => !!log.componentValues[0].componentLogEntityReferences.length),
|
})
|
||||||
mapEach(log => new ComponentLogEntry(log)),
|
.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<string, string>): Observable<void> {
|
override(dossierId: string, fileId: string, componentOverrides: Record<string, string>): Observable<void> {
|
||||||
@ -28,8 +32,8 @@ export class ComponentLogService extends GenericService<void> {
|
|||||||
return this._post({ components }, `componentLog/override/revert/${dossierId}/${fileId}`);
|
return this._post({ components }, `componentLog/override/revert/${dossierId}/${fileId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportJSON(dossierId: string, fileId: string, name: string): Observable<ComponentLogEntry[]> {
|
exportJSON(dossierTemplateId: string, dossierId: string, fileId: string, name: string): Observable<ComponentLogEntry[]> {
|
||||||
return this.getComponentLogData(dossierId, fileId).pipe(
|
return this.getComponentLogData(dossierTemplateId, dossierId, fileId).pipe(
|
||||||
tap(data => {
|
tap(data => {
|
||||||
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
||||||
saveAs(blob, name + '.component_log.json');
|
saveAs(blob, name + '.component_log.json');
|
||||||
@ -37,8 +41,8 @@ export class ComponentLogService extends GenericService<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportXML(dossierId: string, fileId: string, name: string): Observable<string> {
|
exportXML(dossierTemplateId, dossierId: string, fileId: string, name: string): Observable<string> {
|
||||||
return this._getComponentLogDataAsXML(dossierId, fileId).pipe(
|
return this.#getComponentLogDataAsXML(dossierTemplateId, dossierId, fileId).pipe(
|
||||||
tap(data => {
|
tap(data => {
|
||||||
const blob = new Blob([data], { type: 'application/xml' });
|
const blob = new Blob([data], { type: 'application/xml' });
|
||||||
saveAs(blob, name + '.component_log.xml');
|
saveAs(blob, name + '.component_log.xml');
|
||||||
@ -46,16 +50,23 @@ export class ComponentLogService extends GenericService<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getComponentLogDataAsXML(dossierId: string, fileId: string) {
|
#getComponentLogDataAsXML(dossierTemplateId: string, dossierId: string, fileId: string) {
|
||||||
const entityPath = [dossierId, fileId].map(item => encodeURIComponent(item)).join('/');
|
|
||||||
|
|
||||||
let headers = new HttpHeaders();
|
let headers = new HttpHeaders();
|
||||||
headers = headers.set('accept', 'application/xml');
|
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,
|
headers: headers,
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
observe: 'body',
|
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), []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
import { IComponentLogEntry } from './component-log-entry';
|
import { ComponentDetails } from './component-log-entry';
|
||||||
|
|
||||||
export interface IComponentLogData {
|
export interface IComponentLogData {
|
||||||
analysisNumber: number;
|
filename: string | null;
|
||||||
componentRulesVersion: number;
|
fileId: string;
|
||||||
componentLogEntries: Array<IComponentLogEntry>;
|
dossierId: string;
|
||||||
|
dossierTemplateId: string;
|
||||||
|
components: Record<string, Array<string>>;
|
||||||
|
componentDetails: ComponentDetails;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { ComponentValue, IComponentValue } from './component-value';
|
import { ComponentValue, IComponentValue } from './component-value';
|
||||||
|
|
||||||
|
export type ComponentDetails = Record<string, Record<'componentValues', IComponentValue>>;
|
||||||
|
|
||||||
export interface IComponentLogEntry {
|
export interface IComponentLogEntry {
|
||||||
name: string;
|
name: string;
|
||||||
componentValues: IComponentValue[];
|
componentValues: IComponentValue[];
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export interface ComponentLogEntityReference {
|
export interface EntityReference {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly type: string;
|
readonly type: string;
|
||||||
readonly entityRuleId: string;
|
readonly entityRuleId: string;
|
||||||
@ -10,7 +10,7 @@ export interface IComponentValue {
|
|||||||
readonly originalValue: string;
|
readonly originalValue: string;
|
||||||
readonly valueDescription: string;
|
readonly valueDescription: string;
|
||||||
readonly componentRuleId: string;
|
readonly componentRuleId: string;
|
||||||
readonly componentLogEntityReferences: ComponentLogEntityReference[];
|
readonly entityReferences: EntityReference[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ComponentValue implements IComponentValue {
|
export class ComponentValue implements IComponentValue {
|
||||||
@ -18,13 +18,13 @@ export class ComponentValue implements IComponentValue {
|
|||||||
readonly originalValue: string;
|
readonly originalValue: string;
|
||||||
readonly valueDescription: string;
|
readonly valueDescription: string;
|
||||||
readonly componentRuleId: string;
|
readonly componentRuleId: string;
|
||||||
readonly componentLogEntityReferences: ComponentLogEntityReference[];
|
readonly entityReferences: EntityReference[];
|
||||||
|
|
||||||
constructor(value: IComponentValue) {
|
constructor(value: IComponentValue) {
|
||||||
this.value = value.value;
|
this.value = value.value;
|
||||||
this.originalValue = value.originalValue;
|
this.originalValue = value.originalValue;
|
||||||
this.valueDescription = value.valueDescription;
|
this.valueDescription = value.valueDescription;
|
||||||
this.componentRuleId = value.componentRuleId;
|
this.componentRuleId = value.componentRuleId;
|
||||||
this.componentLogEntityReferences = value.componentLogEntityReferences ?? [];
|
this.entityReferences = value.entityReferences ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user