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
@@ -45,6 +45,7 @@ Using with file url:
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| fileNodeId | string | | Node Id of the file to load |
|
| fileNodeId | string | | Node Id of the file to load |
|
||||||
| urlFile | string | | If you want to load an external file that does not come from ECM you can use this Url where to load the file |
|
| urlFile | string | | If you want to load an external file that does not come from ECM you can use this Url where to load the file |
|
||||||
|
| urlFileViewer | string | null | Viewer to use with the `urlFile` address (`pdf`, `image`, `media`, `text`). Used when `urlFile` has no filename and extension. |
|
||||||
| urlBlob | Blob | | If you want to load a Blob File |
|
| urlBlob | Blob | | If you want to load a Blob File |
|
||||||
| overlayMode | boolean | false | If `true` show the Viewer full page over the present content otherwise will fit the parent div |
|
| overlayMode | boolean | false | If `true` show the Viewer full page over the present content otherwise will fit the parent div |
|
||||||
| showViewer | boolean | true | Hide or show the viewer |
|
| showViewer | boolean | true | Hide or show the viewer |
|
||||||
|
@@ -54,6 +54,9 @@ export class ViewerComponent implements OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
urlFile = '';
|
urlFile = '';
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
urlFileViewer: string = null;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
blobFile: Blob;
|
blobFile: Blob;
|
||||||
|
|
||||||
@@ -176,7 +179,7 @@ export class ViewerComponent implements OnChanges {
|
|||||||
this.downloadUrl = this.urlFile;
|
this.downloadUrl = this.urlFile;
|
||||||
this.fileName = this.displayName;
|
this.fileName = this.displayName;
|
||||||
|
|
||||||
this.viewerType = this.getViewerTypeByExtension(this.extension);
|
this.viewerType = this.urlFileViewer || this.getViewerTypeByExtension(this.extension);
|
||||||
if (this.viewerType === 'unknown') {
|
if (this.viewerType === 'unknown') {
|
||||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
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
|
* @param {string} fileName - file name
|
||||||
* @returns {string} file name extension
|
* @returns {string} file name extension
|
||||||
*/
|
*/
|
||||||
getFileExtension(fileName: string): string {
|
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 {
|
isCustomViewerExtension(extension: string): boolean {
|
||||||
|
Reference in New Issue
Block a user