Commit d68798dc authored by Alex ORLUC's avatar Alex ORLUC

FEAT #12074 TIME 0:15 fix res attach viewer

parent f76cac6c
<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>
......
......@@ -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');
}
}
......@@ -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) {
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment