start spinner when getting tables

This commit is contained in:
Dan Percic 2023-08-04 11:24:08 +03:00
parent 086ccb6f95
commit 09bb4be199

View File

@ -88,14 +88,13 @@ const textActions = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD
})
export class FilePreviewScreenComponent
extends AutoUnsubscribe
implements AfterViewInit, OnInit, OnDestroy, OnAttach, OnDetach, ComponentCanDeactivate
{
implements AfterViewInit, OnInit, OnDestroy, OnAttach, OnDetach, ComponentCanDeactivate {
@ViewChild('annotationFilterTemplate', {
read: TemplateRef,
static: false,
})
private readonly _filterTemplate: TemplateRef<unknown>;
@ViewChild('actionsWrapper', { static: false }) private readonly _actionsWrapper: ElementRef;
@ViewChild('actionsWrapper', {static: false}) private readonly _actionsWrapper: ElementRef;
readonly #isDocumine = getConfig().IS_DOCUMINE;
readonly circleButtonTypes = CircleButtonTypes;
readonly roles = Roles;
@ -162,7 +161,7 @@ export class FilePreviewScreenComponent
this.viewerReady().then();
}
},
{ allowSignalWrites: true },
{allowSignalWrites: true},
);
effect(() => {
@ -209,7 +208,7 @@ export class FilePreviewScreenComponent
}
getLastAssignee() {
const { isApproved, lastReviewer, lastApprover } = this.state.file();
const {isApproved, lastReviewer, lastApprover} = this.state.file();
const isRss = this._iqserPermissionsService.has(this.roles.getRss);
return isApproved ? (isRss ? lastReviewer : lastApprover) : lastReviewer;
}
@ -330,7 +329,7 @@ export class FilePreviewScreenComponent
this.#subscribeToFileUpdates();
if (file?.analysisRequired && !file.excludedFromAutomaticAnalysis) {
await this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, { force: true });
await this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, {force: true});
}
this.pdfProxyService.configureElements();
@ -352,7 +351,7 @@ export class FilePreviewScreenComponent
this._dialogService.openDialog(
'manualAnnotation',
{ manualRedactionEntryWrapper, dossierId: this.dossierId, file },
{manualRedactionEntryWrapper, dossierId: this.dossierId, file},
(result: { annotations: ManualRedactionEntryWrapper[]; dictionary?: Dictionary }) => {
const selectedAnnotations = this._annotationManager.selected;
if (selectedAnnotations.length > 0) {
@ -363,7 +362,7 @@ export class FilePreviewScreenComponent
result.annotations.map(w => w.manualRedactionEntry).filter(e => e.positions[0].page <= file.numberOfPages),
this.dossierId,
this.fileId,
{ dictionaryLabel: result.dictionary?.label },
{dictionaryLabel: result.dictionary?.label},
);
const addAndReload$ = add$.pipe(switchMap(() => this._filesService.reload(this.dossierId, file)));
@ -446,13 +445,13 @@ export class FilePreviewScreenComponent
}
}
async downloadOriginalFile({ cacheIdentifier, dossierId, fileId, filename }: File) {
async downloadOriginalFile({cacheIdentifier, dossierId, fileId, filename}: File) {
const originalFile = this._fileManagementService.downloadOriginal(dossierId, fileId, 'response', cacheIdentifier);
download(await firstValueFrom(originalFile), filename);
}
openRSSView() {
this._dialogService.openDialog('rss', { file: this.state.file() });
this._dialogService.openDialog('rss', {file: this.state.file()});
}
loadAnnotations() {
@ -502,6 +501,8 @@ export class FilePreviewScreenComponent
}
async getTables() {
this._loadingService.start();
const currentPage = this.pdf.currentPage();
const tables = await this._tablesService.get(this.state.dossierId, this.state.fileId, this.pdf.currentPage());
await this._annotationDrawService.drawTables(tables, currentPage, this.state.dossierTemplateId);
@ -516,7 +517,9 @@ export class FilePreviewScreenComponent
zip.file(filename + '_page' + currentPage + '_table' + (index + 1) + '.csv', blob);
});
saveAs(await zip.generateAsync({ type: 'blob' }), filename + '_tables.zip');
saveAs(await zip.generateAsync({type: 'blob'}), filename + '_tables.zip');
this._loadingService.stop();
}
async #openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
@ -594,7 +597,7 @@ export class FilePreviewScreenComponent
async #updateQueryParamsPage(page: number): Promise<void> {
const extras: NavigationExtras = {
queryParams: { page },
queryParams: {page},
queryParamsHandling: 'merge',
replaceUrl: true,
};
@ -871,12 +874,12 @@ export class FilePreviewScreenComponent
#getRedactTextDialog(hint: boolean, data: RedactTextData) {
if (this.#isDocumine) {
return this._iqserDialog.openDefault(AddAnnotationDialogComponent, { data });
return this._iqserDialog.openDefault(AddAnnotationDialogComponent, {data});
}
if (hint) {
return this._iqserDialog.openDefault(AddHintDialogComponent, { data });
return this._iqserDialog.openDefault(AddHintDialogComponent, {data});
}
return this._iqserDialog.openDefault(RedactTextDialogComponent, { data });
return this._iqserDialog.openDefault(RedactTextDialogComponent, {data});
}
#getRedactTextDialogData(manualRedactionEntryWrapper: ManualRedactionEntryWrapper, file: File): RedactTextData {