var Unibase; (function (Unibase) { let Apps; (function (Apps) { let Collaboration; (function (Collaboration) { let Components; (function (Components) { class Documents extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.ej2Source = { Excel: ['libs/syncfusion/excel/ej2-excel.min.js'], Pdf: ['libs/syncfusion/pdf/ej2-pdf.min.js'], Word: ['libs/syncfusion/word/ej2-word.min.js'], }; } jsFiles() { return ["apps/collaboration/managers/documentmanager.js"]; } cssFiles() { return []; } loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) { var instance = this; instance.navigationHelper.popup(Pk_Value, '', Unibase.Apps.Collaboration.Components.Documents.Instance(), function (container) { var documentGroup = ElementId; if (Callback != null) { Callback(); } }, Unibase.Platform.Helpers.Size.ExtraLarge); } html(id, containerid) { var html = `
`; return html; } load(formId, containerid, callback) { var instance = this; instance._containerid = containerid; } convertDocsToPdfDownload(documentFileId) { Unibase.Apps.Collaboration.DocumentManager.Instance().ConvertDocstoPdfDownload(documentFileId).then(function (response) { Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(response.result); }); } previewSpreadSheet(fileurl, userid) { let docManger = Unibase.Apps.Collaboration.DocumentManager.Instance(); docManger.getDocumentFileInfo(fileurl).then((response) => { docManger.getJsonData(response.result.FileId).then((res) => { docManger.getCustomJsonData(response.result.FileId).then((customresponse) => { Unibase.Apps.Collaboration.Components.Documents.Instance()._documentId = response.result.FileId; Unibase.Apps.Collaboration.Components.DocConnector.Instance().init(response.result.FileId, response.result.DocumentGroup); this.fileCacheHelper.loadJsFiles(["apps/collaboration/components/sheets/formatpainter.js", "apps/collaboration/components/unicloud.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/autofill.js", "apps/collaboration/components/sheets/ribbon.js", "apps/collaboration/components/sheets/dialogue.js", "apps/collaboration/components/sheets/base.js", 'apps/collaboration/components/common/download.js', 'apps/collaboration/enums/enum.js'], () => { let sheets = Unibase.Apps.Collaboration.Components.Sheets.Base.Instance(); console.log(response); if (res.result != null && res.result != "") { sheets.init(response, res, customresponse); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); } else { } }); }); }); }); } ; previewWordDocument(Fileurl) { Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(Fileurl).then((response) => { Unibase.Apps.Collaboration.DocumentManager.Instance().getJsonData(response.result.FileId).then((res) => { this.fileCacheHelper.loadJsFiles(['apps/collaboration/components/doceditor/base.js', 'platform/core/helpers/file/filehelper.js', 'apps/collaboration/components/sheets/base.js', 'apps/collaboration/components/unicloud.js', 'apps/collaboration/components/doceditor/ribbon.js', 'apps/collaboration/components/common/download.js'], () => { let bizDoc = Unibase.Apps.Collaboration.Components.DocEditor.Base.Instance(); bizDoc.init(response, res); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); }); }); } previewPdf(FileId) { Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then((response) => { this.fileCacheHelper.loadJsFiles(['apps/collaboration/components/pdfviewer/base.js'], () => { let bizPfd = Unibase.Apps.Collaboration.Components.PdfViewer.Base.Instance(); bizPfd.init(response); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); }); } previewImage(documentFileId) { Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(documentFileId).then(function (response) { var result = response.result; var fileName = result.DocumentFileName + "." + result.FileType; var byteCharacters = atob(result.FileData); var byteNumbers = new Array(byteCharacters.length); for (var i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } var byteArray = new Uint8Array(byteNumbers); var file = new Blob([byteArray], { type: result.DocumentGroup + '/' + result.FileType + ';base64' }); var fileURL = URL.createObjectURL(file); window.open(fileURL, fileName, "width=600,height=600,scrollbars=yes"); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); } previewDocument(documentFileId, documentGroup, userid) { this.documentfileid = documentFileId; this.documentGroup = documentGroup; $(".unibase_modal_backdrop").removeAttr('style'); $(".preloader-it").fadeIn(); this.fileCacheHelper.loadJsFiles(["apps/collaboration/managers/documentmanager.js", "apps/collaboration/managers/filemanager.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/docconnector.js", "apps/collaboration/components/unidochub.js", "apps/collaboration/components/common/util.js", 'libs/syncfusion/ej2.min.js', 'apps/collaboration/components/fullscreen.js'], () => { this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => { if (documentGroup == "Image") { this.previewImage(documentFileId); } else if (documentGroup == "Excel") { this.previewSpreadSheet(documentFileId, userid); } else if (documentGroup == "Word") { this.previewWordDocument(documentFileId); } else if (documentGroup == "Pdf") { this.previewPdf(documentFileId); } }); }); } downloadDocument(FileId, documentGroup) { if (documentGroup == "Excel") { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () { var data = { FileId: FileId }; Unibase.Apps.Collaboration.DocumentManager.Instance().spreadSheetDownload(data).then(function (response) { var filepath = response.result; filepath = encodeURIComponent(filepath); Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(filepath); }); }); } else if (documentGroup == "Word") { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () { Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then(function (response) { var filepath = response.result.DocumentFilePath; filepath = encodeURIComponent(filepath); Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(filepath); }); }); } else { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () { Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then(function (response) { var a = document.createElement("a"); a.href = "data:" + response.result.FileType + ";base64," + response.result.FileData; a.download = response.result.FileTitle + "." + response.result.FileType; a.click(); }); }); } } deleteDocumentFile(DocumentFileId) { bootbox.confirm("Do you want to Delete this File ?", function (result) { if (result == true) { Unibase.Platform.Files.Managers.FileManager.Instance().deleteDocumentFile(DocumentFileId).then(function (response) { MessageHelper.Instance().showSuccess("Document File Deleted Successfully.", ""); var detailobj = Unibase.Themes.Compact.Components.Details.Instance(); detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId; detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; detailobj._containerId = $("._bizgaze_detail_container:visible").attr("id"); var idetailObj = detailobj; detailobj.loadPortlets(idetailObj); }); } }); } newWordDoc(callback) { Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); this.fileCacheHelper.loadJsFiles(this.ej2Source["Word"].concat(["apps/collaboration/managers/documentmanager.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/docconnector.js", "apps/collaboration/components/unidochub.js", "apps/collaboration/components/common/util.js", 'apps/collaboration/components/fullscreen.js', 'apps/collaboration/components/sheets/base.js', 'apps/collaboration/components/doceditor/base.js', 'apps/collaboration/components/doceditor/ribbon.js', 'apps/collaboration/components/common/download.js', 'apps/collaboration/enums/enum.js']), () => { this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => { var response = { result: { FileTitle: "Untitled Document", NewDocument: true, NewUpload: true } }; var res = { result: "" }; let bizDoc = Unibase.Apps.Collaboration.Components.DocEditor.Base.Instance(); bizDoc.init(response, res, callback); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); }); } newExcel(type, callback) { Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); this.fileCacheHelper.loadJsFiles(["apps/collaboration/components/sheets/formatpainter.js", "apps/collaboration/components/unicloud.js", "apps/collaboration/components/docconnector.js", 'libs/syncfusion/ej2.min.js', "apps/collaboration/components/fullscreen.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/autofill.js", "apps/collaboration/components/sheets/ribbon.js", "apps/collaboration/components/sheets/dialogue.js", "apps/collaboration/components/sheets/base.js", 'apps/collaboration/components/common/download.js', 'apps/collaboration/components/common/util.js', 'apps/collaboration/enums/enum.js'], () => { this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => { var folderId; var res = { result: "" }; var customres = { result: "" }; var response = { result: { FileTitle: "Untitled Spreadsheet", NewDocument: true, NewUpload: true, folderId: folderId } }; if (type != 0 && type != undefined) { folderId = parseInt(atob(type)); } else { folderId = 0; } var sheets = Unibase.Apps.Collaboration.Components.Sheets.Base.Instance(); sheets.init(response, res, customres, callback); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); }); } static Instance() { if (this.instance === undefined) { this.instance = new Documents(); } return this.instance; } } Components.Documents = Documents; class sfdtexport { } Components.sfdtexport = sfdtexport; })(Components = Collaboration.Components || (Collaboration.Components = {})); })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {})); })(Apps = Unibase.Apps || (Unibase.Apps = {})); })(Unibase || (Unibase = {}));