#68 move add ticket in the viewer main

This commit is contained in:
Eugenio Romano
2016-06-03 17:36:48 +01:00
parent 1b2ff612ab
commit 9698268708
2 changed files with 20 additions and 20 deletions

View File

@@ -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}

View File

@@ -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');
}
}