Denys Vuika 93a87af4a5 [ADF-1623] routing integration for Viewer (#2404)
* routed viewer (demo app)

* toolbar support

* app menu component for demo shell

* navigate back button

* fix unit tests

* improve viewer type detection and rendering

* download button

* automatic pdf rendition, spinners, ui tweaks

* border for pdf pages

* scroll top support

* docs update

* info drawer placeholder
2017-10-03 11:57:23 +01:00

37 lines
1.0 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AlfrescoApiService } from 'ng2-alfresco-core';
@Component({
selector: 'adf-file-view',
templateUrl: 'file-view.component.html'
})
export class FileViewComponent implements OnInit {
nodeId: string = null;
constructor(
private router: Router,
private route: ActivatedRoute,
private apiService: AlfrescoApiService) {}
ngOnInit() {
this.route.params.subscribe(params => {
const id = params.nodeId;
if (id) {
this.apiService.getInstance().nodes.getNodeInfo(id).then(
(node) => {
if (node && node.isFile) {
this.nodeId = id;
return;
}
this.router.navigate(['/files', id]);
},
() => this.router.navigate(['/files', id])
);
}
});
}
}