diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html index 458878e0fb59fa0d22809250008ccbcd70840a46..5407d3bd6edd1373861ca7b68a5f6497d72d2ddc 100644 --- a/src/frontend/app/process/process.component.html +++ b/src/frontend/app/process/process.component.html @@ -169,7 +169,7 @@ </div> <div class="document-container" [class.fullContainer]="appService.getViewMode()"> <div class="content"> - <app-document-viewer #appDocumentViewer style="height:100%;width:100%;" [editMode]="false"> + <app-document-viewer #appDocumentViewer *ngIf="!loading" style="height:100%;width:100%;" [editMode]="false" [resId]="currentResourceInformations.resId"> </app-document-viewer> </div> </div> diff --git a/src/frontend/app/viewer/document-viewer.component.html b/src/frontend/app/viewer/document-viewer.component.html index e0c87e0a78a6adf469b872493533d62ad7baf6c8..66a71d2ec86090443672d413f691f35e1b328c78 100644 --- a/src/frontend/app/viewer/document-viewer.component.html +++ b/src/frontend/app/viewer/document-viewer.component.html @@ -19,6 +19,7 @@ <ng-template #elseHaveFile> <div class="example-loading-shade" *ngIf="loading"> <mat-progress-spinner [mode]="loadingInfo.mode" [value]="loadingInfo.percent"></mat-progress-spinner> + <div class="percent">{{loadingInfo.percent}} %</div> <div style="padding-top: 10px;">{{loadingInfo.message}}</div> </div> <div *ngIf="file.content === null && !loading" class="view-doc-container" appUploadFileDragDrop diff --git a/src/frontend/app/viewer/document-viewer.component.scss b/src/frontend/app/viewer/document-viewer.component.scss index 1f90bdf0a1fbdedf548371dc6a54ed40ec5c4765..e99c960e30e8483b706f67b09ca57271eb996c18 100644 --- a/src/frontend/app/viewer/document-viewer.component.scss +++ b/src/frontend/app/viewer/document-viewer.component.scss @@ -19,6 +19,12 @@ background: rgba(255, 255, 255, 0.7); display: flex; flex-direction: column; + + .percent { + position: absolute; + margin-top: -5px; + color: $primary; + } } .viewer-tools { diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index 945ba955b3165e5fbd57e094573b7636c6d7b686..d142ca4eb3dc1331b9c9d30671d278250973807f 100644 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -28,7 +28,7 @@ export class DocumentViewerComponent implements OnInit { lang: any = LANG; - loading: boolean = false; + loading: boolean = true; noConvertedFound: boolean = false; noFile: boolean = false; @@ -51,10 +51,11 @@ export class DocumentViewerComponent implements OnInit { listTemplates: any[] = []; + @Input('resId') resId: number = null; @Input('editMode') editMode: boolean = false; loadingInfo: any = { - mode: 'determinate', + mode: 'indeterminate', percent: 0, message: '', }; @@ -86,6 +87,12 @@ export class DocumentViewerComponent implements OnInit { this.maxFileSize = data.informations.maximumSize; this.maxFileSizeLabel = data.informations.maximumSizeLabel; + + if (this.resId !== null) { + this.loadRessource(this.resId); + } else { + this.loading = false; + } }), catchError((err: any) => { this.notify.handleErrors(err); @@ -390,21 +397,25 @@ export class DocumentViewerComponent implements OnInit { } loadRessource(resId: any, target: string = 'mainDocument') { - this.http.get(`../../rest/resources/${resId}/content`, { params: { mode: 'base64'}}).pipe( - tap((data: any) => { - this.file.content = data.encodedDocument; - this.file.src = this.base64ToArrayBuffer(this.file.content); - - }), - catchError((err: any) => { + this.loading = true; + this.requestWithLoader(`../../rest/resources/${resId}/content?mode=base64`).subscribe( + (data: any) => { + if (data.encodedDocument) { + this.file.content = data.encodedDocument; + this.file.src = this.base64ToArrayBuffer(this.file.content); + this.loading = false; + } + }, + (err: any) => { if (err.error.errors === 'Document has no file') { this.noFile = true; } else { this.notify.handleErrors(err); } + this.loading = false; return of(false); - }) - ).subscribe(); + } + ); } editTemplate(template: any) {