diff --git a/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.ts b/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.ts index 3d15b4561e..e85008c978 100644 --- a/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.ts +++ b/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.ts @@ -48,10 +48,8 @@ export class PdfViewerComponent { } if (this.urlFile) { - let urlFileTicket = this.addAlfrescoTicket(this.urlFile); - return new Promise((resolve) => { - this.getPDFJS().getDocument(urlFileTicket, null, null).then((pdfDocument) => { + this.getPDFJS().getDocument(this.urlFile, null, null).then((pdfDocument) => { this.currentPdfDocument = pdfDocument; this.totalPages = pdfDocument.numPages; this.page = 1; @@ -63,22 +61,6 @@ export class PdfViewerComponent { } } - /** - * Add Ticket to the file request - * @returns {string} - */ - private addAlfrescoTicket(url: string) { - return url + '?alf_ticket=' + this.getAlfrescoTicket(); - } - - /** - * Get the token from the local storage - * @returns {string} - */ - private getAlfrescoTicket() { - return localStorage.getItem('token'); - } - /** * return the PDFJS global object (exist to facilitate the mock of PDFJS in the test) * @returns {PDFJS} diff --git a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts index 1bc3ea4c01..53efcd288d 100644 --- a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts +++ b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts @@ -59,11 +59,12 @@ export class ViewerComponent { if (this.urlFile) { this.nameFile = this.getFilenameFromUrl(this.urlFile); this.extension = this.getFileExtension(this.nameFile); + + this.urlFile = this.addAlfrescoTicket(this.urlFile); } resolve(); }); } - } /** @@ -133,4 +134,21 @@ export class ViewerComponent { //this.previousPage(); } } + + /** + * Add Ticket to the file request + * @returns {string} + */ + private addAlfrescoTicket(url: string) { + return url + '?alf_ticket=' + this.getAlfrescoTicket(); + } + + /** + * Get the token from the local storage + * @returns {string} + */ + private getAlfrescoTicket() { + return localStorage.getItem('token'); + } + }