mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
support for explicit viewer type for URL (#2688)
This commit is contained in:
committed by
Eugenio Romano
parent
dc213adf55
commit
6c8ed9eae0
@@ -54,6 +54,9 @@ export class ViewerComponent implements OnChanges {
|
||||
@Input()
|
||||
urlFile = '';
|
||||
|
||||
@Input()
|
||||
urlFileViewer: string = null;
|
||||
|
||||
@Input()
|
||||
blobFile: Blob;
|
||||
|
||||
@@ -176,7 +179,7 @@ export class ViewerComponent implements OnChanges {
|
||||
this.downloadUrl = this.urlFile;
|
||||
this.fileName = this.displayName;
|
||||
|
||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
||||
this.viewerType = this.urlFileViewer || this.getViewerTypeByExtension(this.extension);
|
||||
if (this.viewerType === 'unknown') {
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
}
|
||||
@@ -328,13 +331,20 @@ export class ViewerComponent implements OnChanges {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token from the local storage
|
||||
* Get file extension from the string.
|
||||
* Supports the URL formats like:
|
||||
* http://localhost/test.jpg?cache=1000
|
||||
* http://localhost/test.jpg#cache=1000
|
||||
*
|
||||
* @param {string} fileName - file name
|
||||
* @returns {string} file name extension
|
||||
*/
|
||||
getFileExtension(fileName: string): string {
|
||||
return fileName.split('.').pop().toLowerCase();
|
||||
if (fileName) {
|
||||
const match = fileName.match(/\.([^\./\?\#]+)($|\?|\#)/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
isCustomViewerExtension(extension: string): boolean {
|
||||
|
Reference in New Issue
Block a user