DM-508 - Replace RSSResponse with new ComponentLog in UI

This commit is contained in:
Valentin Mihai 2023-10-02 16:02:04 +03:00
parent b970838d52
commit d260bba488
8 changed files with 43 additions and 50 deletions

View File

@ -3,32 +3,36 @@
<hr />
<div class="dialog-content" id="scm-edit">
<div *ngIf="scmData() as scmEntry" class="table output-data">
<div *ngIf="componentLogData() as componentLogEntries" class="table output-data">
<div class="table-header">{{ 'component-log-dialog.table-header.component' | translate }}</div>
<div class="table-header">{{ 'component-log-dialog.table-header.value' | translate }}</div>
<div class="table-header">{{ 'component-log-dialog.table-header.transformation-rule' | translate }}</div>
<div class="table-header">{{ 'component-log-dialog.table-header.annotation-references' | translate }}</div>
<ng-container *ngFor="let entry of scmEntry.componentValues; let index = index">
<div class="bold">{{ entry.value }}</div>
<ng-container *ngFor="let entry of componentLogEntries; let index = index">
<div class="bold">{{ entry.name.replaceAll('_', ' ').toLowerCase() }}</div>
<div [id]="getValueCellId(index)">
<iqser-editable-input
(save)="saveEdit($event, entry.value)"
(save)="saveEdit($event, entry.name)"
[canEdit]="canEdit"
[cancelTooltip]="'component-log-dialog.actions.cancel-edit' | translate"
[editTooltip]="'component-log-dialog.actions.edit' | translate"
[id]="'value-' + index"
[parentId]="getValueCellId(index)"
[saveTooltip]="'component-log-dialog.actions.save' | translate"
[value]="entry.value ?? entry.originalValue"
[value]="entry.componentValues[0].value ?? entry.componentValues[0].originalValue"
[attr.helpModeKey]="'scm_edit_DIALOG'"
>
<ng-container slot="editing">
<iqser-circle-button
(action)="undo(entry.value)"
*ngIf="entry.value && canEdit"
(action)="undo(entry.name)"
*ngIf="entry.componentValues[0].value !== entry.componentValues[0].originalValue && canEdit"
[showDot]="true"
[tooltip]="'component-log-dialog.actions.undo' | translate: { value: entry.originalValue } | replaceNbsp"
[tooltip]="
'component-log-dialog.actions.undo'
| translate: { value: entry.componentValues[0].originalValue }
| replaceNbsp
"
[attr.help-mode-key]="'scm_undo_DIALOG'"
class="ml-2"
icon="red:undo"
@ -36,17 +40,18 @@
</ng-container>
</iqser-editable-input>
</div>
<div>{{ entry.componentRuleId }}</div>
<div>{{ entry.componentValues[0].valueDescription }}</div>
<div>
<ul *ngIf="entry.componentLogEntityReferences; else noReferences" class="pl-0">
<ul *ngIf="entry.componentValues[0].componentLogEntityReferences; else noReferences" class="pl-0">
<li
*ngFor="let reference of entry.componentLogEntityReferences"
*ngFor="let reference of entry.componentValues[0].componentLogEntityReferences"
[innerHTML]="
'component-log-dialog.annotations'
| translate
: {
ruleNumber: reference.entityRuleId,
pageCount: reference.page
type: entry.name,
page: reference.page,
ruleNumber: reference.entityRuleId
}
"
class="mb-8"

View File

@ -34,7 +34,7 @@ interface ScmData {
],
})
export class StructuredComponentManagementDialogComponent extends BaseDialogComponent implements OnInit {
readonly scmData = signal<ComponentLogEntry | undefined>(undefined);
readonly componentLogData = signal<ComponentLogEntry[] | undefined>(undefined);
readonly openScmDialogByDefault = signal(this.userPreferences.getOpenScmDialogByDefault());
constructor(
@ -108,7 +108,7 @@ export class StructuredComponentManagementDialogComponent extends BaseDialogComp
const componentLogData = await firstValueFrom(
this._componentLogService.getComponentLogData(this.data.file.dossierId, this.data.file.fileId),
);
this.scmData.set(componentLogData);
this.componentLogData.set(componentLogData);
this._loadingService.stop();
}
}

View File

@ -1,49 +1,38 @@
import { Injectable } from '@angular/core';
import { GenericService, QueryParam } from '@iqser/common-ui';
import { GenericService } from '@iqser/common-ui';
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';
@Injectable({ providedIn: 'root' })
export class ComponentLogService extends GenericService<void> {
protected readonly _defaultModelPath = 'import-redactions';
getComponentLogData(dossierId: string, fileId: string): Observable<ComponentLogEntry> {
const queryParams: QueryParam[] = [];
queryParams.push({ key: 'fileId', value: fileId });
return this._getOne<IComponentLogData>([dossierId], 'componentLog', queryParams).pipe(
map(data => data.componentLogEntries[0]),
catchError(() => of({} as IComponentLogEntry)),
map(data => new ComponentLogEntry(data)),
);
}
getComponentLogExportData(dossierId: string, fileId: string): Observable<any> {
const queryParams: QueryParam[] = [];
queryParams.push({ key: 'fileId', value: fileId });
return this._getOne<any>([dossierId], 'rss', queryParams).pipe(
map(data => data.files[0]),
catchError(() => of({} as IComponentLogEntry)),
getComponentLogData(dossierId: string, fileId: string): Observable<ComponentLogEntry[]> {
return this._getOne<IComponentLogData>([dossierId, fileId], 'componentLog').pipe(
map(data => data.componentLogEntries),
catchError(() => of({} as IComponentLogEntry[])),
filterEach(log => !!log.componentValues[0].componentLogEntityReferences.length),
mapEach(log => new ComponentLogEntry(log)),
);
}
override(dossierId: string, fileId: string, componentOverrides: Record<string, string>): Observable<void> {
return this._post({ componentOverrides }, `rss/override/${dossierId}/${fileId}`);
return this._post({ componentOverrides }, `componentLog/override/${dossierId}/${fileId}`);
}
revertOverride(dossierId: string, fileId: string, components: string[]): Observable<void> {
return this._post({ components }, `rss/override/revert/${dossierId}/${fileId}`);
return this._post({ components }, `componentLog/override/revert/${dossierId}/${fileId}`);
}
exportJSON(dossierId: string, fileId: string, name: string): Observable<ComponentLogEntry> {
return this.getComponentLogExportData(dossierId, fileId).pipe(
exportJSON(dossierId: string, fileId: string, name: string): Observable<ComponentLogEntry[]> {
return this.getComponentLogData(dossierId, fileId).pipe(
tap(data => {
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
saveAs(blob, name + '.rss.json');
saveAs(blob, name + '.component_log.json');
}),
);
}
@ -52,23 +41,19 @@ export class ComponentLogService extends GenericService<void> {
return this._getComponentLogDataAsXML(dossierId, fileId).pipe(
tap(data => {
const blob = new Blob([data], { type: 'application/xml' });
saveAs(blob, name + '.rss.xml');
saveAs(blob, name + '.component_log.xml');
}),
);
}
private _getComponentLogDataAsXML(dossierId: string, fileId: string) {
const queryParams: QueryParam[] = [];
queryParams.push({ key: 'fileId', value: fileId });
const entityPath = [dossierId].map(item => encodeURIComponent(item)).join('/');
const entityPath = [dossierId, fileId].map(item => encodeURIComponent(item)).join('/');
let headers = new HttpHeaders();
headers = headers.set('accept', 'application/xml');
return this._http.get(`/${this._serviceName}/${encodeURI('rss')}/${entityPath}`, {
return this._http.get(`/${this._serviceName}/${encodeURI('componentLog')}/${entityPath}`, {
headers: headers,
params: this._queryParams(queryParams),
responseType: 'text',
observe: 'body',
});

View File

@ -569,7 +569,7 @@
"save": "Save",
"undo": "Undo"
},
"annotations": "<strong>{type}</strong> found on {pageCount, plural, one{page} other{pages}} {pages} by rule #{ruleNumber}",
"annotations": "<strong>{type}</strong> found on page {page} by rule #{ruleNumber}",
"table-header": {
"annotation-references": "Annotation references",
"component": "Component",

View File

@ -569,7 +569,7 @@
"save": "Save",
"undo": "Undo to: {value}"
},
"annotations": "<strong>{type}</strong> found on {pageCount, plural, one{page} other{pages}} {pages} by rule #{ruleNumber}",
"annotations": "<strong>{type}</strong> found on page {page} by rule #{ruleNumber}",
"table-header": {
"annotation-references": "Annotation references",
"component": "Component",

View File

@ -569,7 +569,7 @@
"save": "Save",
"undo": "Undo"
},
"annotations": "<strong>{type}</strong> found on {pageCount, plural, one{page} other{pages}} {pages} by rule #{ruleNumber}",
"annotations": "<strong>{type}</strong> found on page {page} by rule #{ruleNumber}",
"table-header": {
"annotation-references": "Annotation references",
"component": "Component",

View File

@ -569,7 +569,7 @@
"save": "Save",
"undo": "Undo to: {value}"
},
"annotations": "<strong>{type}</strong> found on {pageCount, plural, one{page} other{pages}} {pages} by rule #{ruleNumber}",
"annotations": "<strong>{type}</strong> found on page {page} by rule #{ruleNumber}",
"table-header": {
"annotation-references": "Annotation references",
"component": "Component",

View File

@ -8,6 +8,7 @@ export interface ComponentLogEntityReference {
export interface IComponentValue {
readonly value: string;
readonly originalValue: string;
readonly valueDescription: string;
readonly componentRuleId: string;
readonly componentLogEntityReferences: ComponentLogEntityReference[];
}
@ -15,12 +16,14 @@ export interface IComponentValue {
export class ComponentValue implements IComponentValue {
readonly value: string;
readonly originalValue: string;
readonly valueDescription: string;
readonly componentRuleId: string;
readonly componentLogEntityReferences: ComponentLogEntityReference[];
constructor(value: IComponentValue) {
this.value = value.value;
this.originalValue = value.originalValue;
this.valueDescription = value.valueDescription;
this.componentRuleId = value.componentRuleId;
this.componentLogEntityReferences = value.componentLogEntityReferences ?? [];
}