import * as widgets from "oasi-widgets"; import { FolderInfo, FileRestService, FileOldSystemRestService } from 'isogd-file-rest'; import { DocumentIsogd } from "isogd-document-rest"; import { NsiRestService } from "oasi-nsi-rest"; class FilesViewController { static $inject = ['fileRestService', 'fileOldSystemRestService', 'nsiRestService']; private loadingStatus: widgets.LoadingStatus = widgets.LoadingStatus.LOADING; private document: DocumentIsogd; private folder: FolderInfo; private code: string; private isOld: boolean; private registry: any; private extensions = ['pdf', 'tiff', 'jpg', 'jpeg', 'doc', 'docx']; constructor(private fileRestService: FileRestService, private fileOldSystemRestService: FileOldSystemRestService, private nsiRestService: NsiRestService) { } $onInit() { this.loadingStatus = widgets.LoadingStatus.LOADING; this.nsiRestService.getBy("OldChapters", { nickAttr: "chapterCode", values: [this.document.reestr ] }).then(response => { this.registry = response[0]; if (this.document.folderID) { this.isOld = false; } else { if (this.document.oldFolderID) { this.isOld = true; } else { this.isOld = undefined; } } let promise: ng.IPromise; if (this.isOld !== undefined) { if (!this.isOld) { promise = this.fileRestService.filesTree(this.document.folderID, "1level"); } else { promise = this.fileOldSystemRestService.filesTreeOld(this.document.oldFolderID, "1levels"); } promise.then(response => { this.folder = response; this.loadingStatus = widgets.LoadingStatus.SUCCESS; }).catch(error => { this.loadingStatus = widgets.LoadingStatus.ERROR; console.log(error); }); } else { this.loadingStatus = widgets.LoadingStatus.SUCCESS; } }); } } export const FilesViewComponent: angular.IComponentOptions = { controller: FilesViewController, template: require('./files-view.html'), bindings: { document: '<' } };