mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#68 move add ticket in the viewer main
This commit is contained in:
@@ -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}
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user