123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Forms;
- (function (Forms) {
- let Components;
- (function (Components) {
- class DocumentFiles extends Platform.Core.BaseComponent {
- previewDocument(documentFileId, previewicon) {
- if (previewicon == "disabled") {
- return false;
- }
- else {
- var instance = this;
- instance.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
- if (isMobileApp()) {
- Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentFile(documentFileId).then(function (response) {
- var filePath = response.result.DocumentFilePath;
- if (filePath != null && filePath != undefined && filePath != "") {
- filePath = filePath.replace("file://" + '/', '');
- filePath = filePath.replace(window.location.origin + '/', '');
- Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(response, filePath, Unibase.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathPreviewCallBack);
- }
- });
- }
- else {
- Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(documentFileId).then(function (response) {
- var result = response.result;
- 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);
- var fileName = result.DocumentFileName + "." + result.FileType;
- window.open(fileURL, fileName, "width=600,height=600,scrollbars=yes");
- });
- }
- });
- }
- }
- downloadDocument(documentFileId) {
- var instance = this;
- instance.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
- if (isMobileApp()) {
- Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentFile(documentFileId).then(function (response) {
- var filePath = response.result.DocumentFilePath;
- if (filePath != null && filePath != undefined && filePath != "") {
- filePath = filePath.replace("file://" + '/', '');
- filePath = filePath.replace(window.location.origin + '/', '');
- Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(response, filePath, Unibase.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathDownloadCallBack);
- }
- });
- }
- else {
- Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(documentFileId).then(function (response) {
- var a = document.createElement("a");
- a.href = "data:" + response.result.FileType + ";base64," + response.result.FileData;
- a.download = response.result.DocumentFileName + "." + response.result.FileType;
- a.click();
- });
- }
- });
- }
- MobileFilePathDownloadCallBack(response, filePath, mobileFilePath) {
- mobileFilePath.replace(/^\//, '');
- filePath = filePath.replace(mobileFilePath + '/', '');
- var tempPath = filePath.split("~/");
- var checkPath = tempPath[tempPath.length - 1];
- filePath = checkPath;
- var server_url = _appsettings.server_url();
- if (!filePath.includes(server_url)) {
- filePath = server_url + "/" + filePath;
- }
- var a = document.createElement("a");
- a.href = filePath;
- a.download = response.result.DocumentFileName + "." + response.result.FileType;
- a.click();
- }
- MobileFilePathPreviewCallBack(response, filePath, mobileFilePath) {
- mobileFilePath.replace(/^\//, '');
- filePath = filePath.replace(mobileFilePath + '/', '');
- var tempPath = filePath.split("~/");
- var checkPath = tempPath[tempPath.length - 1];
- filePath = checkPath;
- var server_url = _appsettings.server_url();
- if (!filePath.includes(server_url)) {
- filePath = server_url + "/" + filePath;
- }
- Unibase.Platform.Helpers.MobileHelper.Instance().openNewWindow(filePath);
- }
- deleteDocumentFile(DocumentFileId) {
- var instance = this;
- bootbox.confirm("Do you want to Delete this File ?", function (result) {
- if (result == true) {
- instance.fileCacheHelper.loadJsFile("platform/files/managers/filemanager.js", function () {
- Unibase.Platform.Files.Managers.FileManager.Instance().deleteDocumentFile(DocumentFileId).then(function (response) {
- MessageHelper.Instance().showSuccess("Document File Deleted Successfully.", "");
- var ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
- if (ContainerId != null && ContainerId != undefined && ContainerId != '') {
- var viewall = ContainerId.toString().includes("_viewall");
- if (viewall) {
- var refreshButton = $("#" + ContainerId).find(".report-refresh-btn");
- if (refreshButton.length > 0) {
- refreshButton.click();
- }
- }
- else {
- instance.reloadPortlet();
- }
- }
- else {
- instance.reloadPortlet();
- }
- });
- });
- }
- });
- }
- reloadPortlet() {
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
- var portletId = 0;
- var activePortletIndex = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets.findIndex(x => x.InstalledAppId == installedAppId);
- if (activePortletIndex > -1) {
- portletId = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets[activePortletIndex].ActivePortletId;
- }
- if (portletId == 0) {
- portletId = Number($("#hf_PortletId").val());
- }
- Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(installedAppId, portletId, containerId);
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new DocumentFiles();
- }
- return this.instance;
- }
- }
- Components.DocumentFiles = DocumentFiles;
- })(Components = Forms.Components || (Forms.Components = {}));
- })(Forms = Platform.Forms || (Platform.Forms = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|