diff --git a/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.html b/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.html index 4df11bd2dedb72162adf2cdfb423d8cee6fcfb45..6363422b112024586d6a3383e98dccbca7adac95 100644 --- a/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.html +++ b/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.html @@ -1,4 +1,6 @@ -<h1 mat-dialog-title>{{data.attachment.identifier}} - {{data.attachment.title}}</h1> +<h1 mat-dialog-title>{{data.attachment.identifier}} - {{data.attachment.title}} <button [title]="lang.close" mat-icon-button (click)="dialogRef.close();"> + <mat-icon class="fa fa-times"></mat-icon> + </button></h1> <mat-dialog-content class="modal-container"> <app-document-viewer #appDocumentViewer style="height:100%;width:100%;" [editMode]="false"> </app-document-viewer> diff --git a/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.ts b/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.ts index 45f0acfd27352de5c85b8893d2e14b081b45d266..3c1d740c3d762b1084798094db95e0980622186a 100644 --- a/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.ts +++ b/src/frontend/app/attachments/attachment-show-modal/attachment-show-modal.component.ts @@ -2,8 +2,6 @@ import { Component, Inject, ViewChild } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { LANG } from '../../translate.component'; import { HttpClient } from '@angular/common/http'; -import { tap, catchError } from 'rxjs/operators'; -import { of } from 'rxjs'; import { NotificationService } from '../../notification.service'; import { DocumentViewerComponent } from '../../viewer/document-viewer.component'; @@ -26,6 +24,6 @@ export class AttachmentShowModalComponent { } ngOnInit(): void { - this.appDocumentViewer.loadRessource(100); + this.appDocumentViewer.loadRessource(this.data.attachment.res_id, 'attachment'); } } diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index c829e1a5c76ac745257bc69d4c9a50623b8cbed2..c0e27a62f70e486279bf9e87c226d82e25e07241 100644 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -414,29 +414,58 @@ export class DocumentViewerComponent implements OnInit { loadRessource(resId: any, target: string = 'mainDocument') { this.loading = true; - this.requestWithLoader(`../../rest/resources/${resId}/content?mode=base64`).subscribe( - (data: any) => { - if (data.encodedDocument) { - this.file.contentMode = 'route'; - this.file.content = `../../rest/resources/${resId}/originalContent`; - this.file.src = this.base64ToArrayBuffer(data.encodedDocument); + if (target === 'attachment') { + this.requestWithLoader(`../../rest/attachments/${resId}/content?mode=base64`).subscribe( + (data: any) => { + if (data.encodedDocument) { + this.file.contentMode = 'route'; + this.file.content = `../../rest/attachments/${resId}/originalContent`; + this.file.src = this.base64ToArrayBuffer(data.encodedDocument); + this.loading = false; + } + }, + (err: any) => { + if (err.error.errors === 'Document has no file') { + this.noFile = true; + } else if (err.error.errors === 'Converted Document not found') { + this.file.contentMode = 'route'; + this.file.content = `../../rest/attachments/${resId}/originalContent`; + this.noConvertedFound = true; + } else { + this.notify.error(err.error.errors); + this.noFile = true; + } this.loading = false; + return of(false); } - }, - (err: any) => { - if (err.error.errors === 'Document has no file') { - this.noFile = true; - } else if (err.error.errors === 'Converted Document not found') { - this.file.contentMode = 'route'; - this.file.content = `../../rest/resources/${resId}/originalContent`; - this.noConvertedFound = true; - } else { - this.notify.handleErrors(err); + ); + } else { + this.requestWithLoader(`../../rest/resources/${resId}/content?mode=base64`).subscribe( + (data: any) => { + if (data.encodedDocument) { + this.file.contentMode = 'route'; + this.file.content = `../../rest/resources/${resId}/originalContent`; + this.file.src = this.base64ToArrayBuffer(data.encodedDocument); + this.loading = false; + } + }, + (err: any) => { + if (err.error.errors === 'Document has no file') { + this.noFile = true; + } else if (err.error.errors === 'Converted Document not found') { + this.file.contentMode = 'route'; + this.file.content = `../../rest/resources/${resId}/originalContent`; + this.noConvertedFound = true; + } else { + this.notify.error(err.error.errors); + this.noFile = true; + } + this.loading = false; + return of(false); } - this.loading = false; - return of(false); - } - ); + ); + } + } editTemplate(templateId: number) { diff --git a/src/frontend/service/privileges.service.ts b/src/frontend/service/privileges.service.ts index bf3a70134054e2c3c6c0a8c9e3f192ad1b202311..2a463c0f2a22db87a45219f6374652fc1ad15460 100644 --- a/src/frontend/service/privileges.service.ts +++ b/src/frontend/service/privileges.service.ts @@ -482,7 +482,6 @@ export class PrivilegeService { } getCurrentUserMenus() { - console.log(this.headerService.user); let menus = this.menus.filter(elem => this.headerService.user.privileges.indexOf(elem.id) > -1); if (this.headerService.user.groups.filter((group: any) => group.can_index === true).length > 0) {