insert new logic in the demo Shell

This commit is contained in:
Eugenio Romano 2016-08-04 10:24:50 +01:00
parent efa39eefe8
commit eb68bd5f48
7 changed files with 29 additions and 29 deletions

View File

@ -177,9 +177,7 @@
</div> </div>
<alfresco-viewer [(showViewer)]="fileShowed" <alfresco-viewer [(showViewer)]="fileShowed"
[urlFile]="urlFile" [fileNodeId]="fileNodeId"
[fileName]="fileName"
[mimeType]="mimeType"
[overlayMode]="true"> [overlayMode]="true">
<div class="mdl-spinner mdl-js-spinner is-active"></div> <div class="mdl-spinner mdl-js-spinner is-active"></div>
</alfresco-viewer> </alfresco-viewer>

View File

@ -58,9 +58,7 @@ declare let __moduleName: string;
export class FilesComponent implements OnInit { export class FilesComponent implements OnInit {
currentPath: string = '/Sites/swsdp/documentLibrary'; currentPath: string = '/Sites/swsdp/documentLibrary';
urlFile: string; fileNodeId: any;
fileName: string;
mimeType: string;
fileShowed: boolean = false; fileShowed: boolean = false;
multipleFileUpload: boolean = false; multipleFileUpload: boolean = false;
folderUpload: boolean = false; folderUpload: boolean = false;
@ -92,9 +90,7 @@ export class FilesComponent implements OnInit {
showFile(event) { showFile(event) {
if (event.value.entry.isFile) { if (event.value.entry.isFile) {
this.fileName = event.value.entry.name; this.fileNodeId = event.value.entry.id;
this.mimeType = event.value.entry.content.mimeType;
this.urlFile = this.contentService.getContentUrl(event.value);
this.fileShowed = true; this.fileShowed = true;
} else { } else {
this.fileShowed = false; this.fileShowed = false;

View File

@ -1,6 +1,8 @@
<alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false" <alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false"
(searchChange)="searchTermChange($event);" (expand)="onExpandToggle($event);" (preview)="onFileClicked($event)"></alfresco-search-control> (searchChange)="searchTermChange($event);" (expand)="onExpandToggle($event);" (preview)="onFileClicked($event)"></alfresco-search-control>
<alfresco-viewer [(showViewer)]="fileShowed" [urlFile]="urlFile" [fileName]="fileName" [mimeType]="mimeType" [overlayMode]="true"> <alfresco-viewer [(showViewer)]="fileShowed"
[fileNodeId]="fileNodeId"
[overlayMode]="true">
<div class="mdl-spinner mdl-js-spinner is-active"></div> <div class="mdl-spinner mdl-js-spinner is-active"></div>
</alfresco-viewer> </alfresco-viewer>

View File

@ -56,15 +56,14 @@ export class SearchComponent {
previewName: string; previewName: string;
previewMimeType: string; previewMimeType: string;
previewActive: boolean = false; previewActive: boolean = false;
fileNodeId: string;
constructor(public contentService: AlfrescoContentService) { constructor(public contentService: AlfrescoContentService) {
} }
onFileClicked(event) { onFileClicked(event) {
if (event.value.entry.isFile) { if (event.value.entry.isFile) {
this.previewName = event.value.entry.name; this.fileNodeId = event.value.entry.id;
this.previewMimeType = event.value.entry.content.mimeType;
this.previewContentUrl = this.contentService.getContentUrl(event.value);
this.previewActive = true; this.previewActive = true;
} }
} }

View File

@ -49,15 +49,13 @@ import {
<alfresco-viewer <alfresco-viewer
[fileNodeId]="'09469a81-1ed9-4caa-a5df-8362fc3d096f'" [fileNodeId]="'09469a81-1ed9-4caa-a5df-8362fc3d096f'"
[showViewer]="true" [showViewer]="true"
[overlayMode]="true" [overlayMode]="true">
[urlFile]="'localTestFile.pdf'">
<div class="mdl-spinner mdl-js-spinner is-active"></div> <div class="mdl-spinner mdl-js-spinner is-active"></div>
</alfresco-viewer> </alfresco-viewer>
</div>`, </div>`,
directives: [VIEWERCOMPONENT] directives: [VIEWERCOMPONENT]
}) })
class MyDemoApp { class MyDemoApp {
authenticated: boolean; authenticated: boolean;
ecmHost: string = 'http://127.0.0.1:8080'; ecmHost: string = 'http://127.0.0.1:8080';

View File

@ -43,7 +43,7 @@
<!--</button>--> <!--</button>-->
<!--</div>--> <!--</div>-->
<div class="center-element mdl-cell mdl-cell--12-col" > <div *ngIf="isLoaded()" class="center-element mdl-cell mdl-cell--12-col" >
<div id="viewer-content-container" class="viewer-content-container mdl-cell" > <div id="viewer-content-container" class="viewer-content-container mdl-cell" >
<!-- Start View Switch--> <!-- Start View Switch-->

View File

@ -36,15 +36,9 @@ export class ViewerComponent {
@Input() @Input()
urlFile: string; urlFile: string;
@Input()
fileName: string = null;
@Input() @Input()
fileNodeId: string = null; fileNodeId: string = null;
@Input()
mimeType: string = null;
@Input() @Input()
overlayMode: boolean = false; overlayMode: boolean = false;
@ -60,6 +54,10 @@ export class ViewerComponent {
extension: string; extension: string;
mimeType: string;
loaded: boolean = false;
constructor(private authService: AlfrescoAuthenticationService, private element: ElementRef, @Inject(DOCUMENT) private document) { constructor(private authService: AlfrescoAuthenticationService, private element: ElementRef, @Inject(DOCUMENT) private document) {
} }
@ -67,18 +65,20 @@ export class ViewerComponent {
if (this.showViewer) { if (this.showViewer) {
this.hideOtherHeaderBar(); this.hideOtherHeaderBar();
this.blockOtherScrollBar(); this.blockOtherScrollBar();
if (!this.urlFile) { if (!this.urlFile && !this.fileNodeId) {
throw new Error('Attribute urlFile is required'); throw new Error('Attribute urlFile or fileNodeId is required');
} }
return new Promise((resolve) => { return new Promise((resolve) => {
if (this.urlFile) { if (this.urlFile) {
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile); let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
this.displayName = this.fileName !== null ? this.fileName : filenameFromUrl; this.displayName = filenameFromUrl ? filenameFromUrl : '';
this.extension = this.getFileExtension(filenameFromUrl); this.extension = this.getFileExtension(filenameFromUrl);
} else if (this.fileNodeId) { } else if (this.fileNodeId) {
console.log('call api'); this.authService.getAlfrescoApi().nodes.getNodeInfo(this.fileNodeId).then((data) => {
this.authService.getAlfrescoApi().getNodeInfo(this.fileNodeId).then(function (data) { this.mimeType = data.content.mimeType;
console.log('This is the name' + JSON.stringify(data) ); this.displayName = data.name;
this.urlFile = this.authService.getAlfrescoApi().content.getContentUrl(data.id);
this.loaded = true;
}, function (error) { }, function (error) {
console.log('This node does not exist'); console.log('This node does not exist');
}); });
@ -249,4 +249,11 @@ export class ViewerComponent {
} }
} }
} }
/**
* return true if the data about the node in the ecm are loaded
*/
isLoaded() {
return this.fileNodeId ? this.loaded : true;
}
} }