diff --git a/.travis.yml b/.travis.yml index eab8b041cc..f3c377b2ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ env: - MODULE=ng2-activiti-tasklist before_script: - - if ([ "$MODULE" != "ng2-alfresco-core" ] && [ "$MODULE" != "ng2-alfresco-viewer" ]); then + - if ([ "$MODULE" != "ng2-alfresco-core" ]); then (cd ng2-components/ng2-alfresco-core; npm install; npm link); fi - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ] || [ "$MODULE" == "ng2-activiti-processlist" ] || [ "$MODULE" == "ng2-activiti-tasklist" ]); then @@ -42,7 +42,7 @@ before_script: (cd ng2-components/ng2-activiti-form; npm link ng2-alfresco-core; npm install; npm link); fi - cd ng2-components/$MODULE; - - if ([ "$MODULE" != "ng2-alfresco-core" ] && [ "$MODULE" != "ng2-alfresco-viewer" ]); then + - if ([ "$MODULE" != "ng2-alfresco-core" ]); then npm link ng2-alfresco-core; fi - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ] || [ "$MODULE" == "ng2-activiti-processlist" ] || [ "$MODULE" == "ng2-activiti-tasklist" ]); then diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index c5dca88622..3cf95cd013 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -177,9 +177,7 @@
diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index 2d430e20ea..371536eb78 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -58,9 +58,7 @@ declare let __moduleName: string; export class FilesComponent implements OnInit { currentPath: string = '/Sites/swsdp/documentLibrary'; - urlFile: string; - fileName: string; - mimeType: string; + fileNodeId: any; fileShowed: boolean = false; multipleFileUpload: boolean = false; folderUpload: boolean = false; @@ -92,9 +90,7 @@ export class FilesComponent implements OnInit { showFile(event) { if (event.value.entry.isFile) { - this.fileName = event.value.entry.name; - this.mimeType = event.value.entry.content.mimeType; - this.urlFile = this.contentService.getContentUrl(event.value); + this.fileNodeId = event.value.entry.id; this.fileShowed = true; } else { this.fileShowed = false; diff --git a/demo-shell-ng2/app/components/search/search-bar.component.html b/demo-shell-ng2/app/components/search/search-bar.component.html index 0d144a574b..4d89fd0d8b 100644 --- a/demo-shell-ng2/app/components/search/search-bar.component.html +++ b/demo-shell-ng2/app/components/search/search-bar.component.html @@ -1,6 +1,8 @@ - +
diff --git a/demo-shell-ng2/app/components/search/search.component.ts b/demo-shell-ng2/app/components/search/search.component.ts index c3d57964d8..bf836b7783 100644 --- a/demo-shell-ng2/app/components/search/search.component.ts +++ b/demo-shell-ng2/app/components/search/search.component.ts @@ -56,15 +56,14 @@ export class SearchComponent { previewName: string; previewMimeType: string; previewActive: boolean = false; + fileNodeId: string; constructor(public contentService: AlfrescoContentService) { } onFileClicked(event) { if (event.value.entry.isFile) { - this.previewName = event.value.entry.name; - this.previewMimeType = event.value.entry.content.mimeType; - this.previewContentUrl = this.contentService.getContentUrl(event.value); + this.fileNodeId = event.value.entry.id; this.previewActive = true; } } diff --git a/ng2-components/ng2-alfresco-viewer/README.md b/ng2-components/ng2-alfresco-viewer/README.md index dfb187f706..b80011b856 100644 --- a/ng2-components/ng2-alfresco-viewer/README.md +++ b/ng2-components/ng2-alfresco-viewer/README.md @@ -48,11 +48,13 @@ Add the following dependency to your index.html: + ``` -Make sure your systemjs.config has the following configuration: +The following component needs to be added to your systemjs.config: -https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-viewer/demo/systemjs.config.js +- ng2-translate +- ng2-alfresco-core #### Style The style of this component is based on material design, so if you want to visualize it correctly you have to add the material @@ -71,7 +73,40 @@ Also make sure you include these dependencies in your .html page: ``` -#### Basic usage +#### Basic usage with node id + +```html + +``` + +Example of an App that declares the file viewer component : + +```ts +import { Component } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer'; + +@Component({ + selector: 'my-app', + template: ` +
+
`, + directives: [VIEWERCOMPONENT] +}) +class MyDemoApp { + + fileNodeId: any; + + constructor() { + this.fileNodeId = '09469a81-1ed9-4caa-a5df-8362fc3d096f'; + } +} +bootstrap(MyDemoApp, [ + VIEWERCOMPONENT +]); +``` + +#### Basic usage with urlFile ```html @@ -105,11 +140,10 @@ bootstrap(MyDemoApp, [ Attribute | Options | Default | Description | Mandatory --- | --- | --- | --- | --- -`urlFile` | *string* | | Url where to load the file | mandatory -`fileName` | *string* | Parsed from `urlFile` | Name of the file to display in the title bar. If not specified will take the last part of the URL | -`overlayMode` | *boolean* | `false` | if true Show the Viewer full page over the present content | +`fileNodeId` | *string* | | node Id of the file to load the file | +`urlFile` | *string* | | If you want laod an external file that not comes from the ECM you can use this Url where to load the file | +`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 | -`mimeType` | *string* | `true` | MimeType of the file, used to detect if the browser can display the content. If not supplied the component will attempt to guess based on file extension of the `urlFile` | ## Build from sources Alternatively you can build component from sources with the following commands: diff --git a/ng2-components/ng2-alfresco-viewer/demo/index.html b/ng2-components/ng2-alfresco-viewer/demo/index.html index ce2709adcc..5e571042d4 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/index.html +++ b/ng2-components/ng2-alfresco-viewer/demo/index.html @@ -22,6 +22,9 @@ + + +