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>
<alfresco-viewer [(showViewer)]="fileShowed"
[urlFile]="urlFile"
[fileName]="fileName"
[mimeType]="mimeType"
[fileNodeId]="fileNodeId"
[overlayMode]="true">
<div class="mdl-spinner mdl-js-spinner is-active"></div>
</alfresco-viewer>

View File

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

View File

@ -1,6 +1,8 @@
<alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false"
(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>
</alfresco-viewer>

View File

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

View File

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

View File

@ -43,7 +43,7 @@
<!--</button>-->
<!--</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" >
<!-- Start View Switch-->

View File

@ -36,15 +36,9 @@ export class ViewerComponent {
@Input()
urlFile: string;
@Input()
fileName: string = null;
@Input()
fileNodeId: string = null;
@Input()
mimeType: string = null;
@Input()
overlayMode: boolean = false;
@ -60,6 +54,10 @@ export class ViewerComponent {
extension: string;
mimeType: string;
loaded: boolean = false;
constructor(private authService: AlfrescoAuthenticationService, private element: ElementRef, @Inject(DOCUMENT) private document) {
}
@ -67,18 +65,20 @@ export class ViewerComponent {
if (this.showViewer) {
this.hideOtherHeaderBar();
this.blockOtherScrollBar();
if (!this.urlFile) {
throw new Error('Attribute urlFile is required');
if (!this.urlFile && !this.fileNodeId) {
throw new Error('Attribute urlFile or fileNodeId is required');
}
return new Promise((resolve) => {
if (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);
} else if (this.fileNodeId) {
console.log('call api');
this.authService.getAlfrescoApi().getNodeInfo(this.fileNodeId).then(function (data) {
console.log('This is the name' + JSON.stringify(data) );
this.authService.getAlfrescoApi().nodes.getNodeInfo(this.fileNodeId).then((data) => {
this.mimeType = data.content.mimeType;
this.displayName = data.name;
this.urlFile = this.authService.getAlfrescoApi().content.getContentUrl(data.id);
this.loaded = true;
}, function (error) {
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;
}
}