From d1002096147fe099d389b2d53fedb9f946d7b7ed Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 11:52:28 +0200 Subject: [PATCH 01/13] multiDownload --- .../client/source/class/osparc/data/Resources.js | 4 ++++ .../client/source/class/osparc/store/Data.js | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 369c1de7fa4d..1719c8187dd4 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -1209,6 +1209,10 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/storage/locations/{locationId}/paths?file_filter={path}&cursor={cursor}&size=1000" }, + multiDownload: { + method: "POST", + url: statics.API + "/storage/locations/{locationId}/export-data" + }, batchDelete: { method: "POST", url: statics.API + "/storage/locations/{locationId}/-/paths:batchDelete" diff --git a/services/static-webserver/client/source/class/osparc/store/Data.js b/services/static-webserver/client/source/class/osparc/store/Data.js index 8353c24ab028..f85a9f91e864 100644 --- a/services/static-webserver/client/source/class/osparc/store/Data.js +++ b/services/static-webserver/client/source/class/osparc/store/Data.js @@ -234,6 +234,22 @@ qx.Class.define("osparc.store.Data", { return true; }, + downloadFiles: function(paths) { + if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) { + return null; + } + + const params = { + url: { + locationId: 0, + }, + data: { + paths, + } + }; + return osparc.data.Resources.fetch("storagePaths", "multiDownload", params); + }, + deleteFiles: function(paths) { if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) { return null; From ce3685ce87106466c7ccc68b8798213c595626d1 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 13:07:00 +0200 Subject: [PATCH 02/13] downloadPaths --- .../class/osparc/file/FileLabelWithActions.js | 30 ++++++++++++++----- .../client/source/class/osparc/store/Data.js | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 86bd7eced16d..7fc7a9ff709d 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -143,15 +143,21 @@ qx.Class.define("osparc.file.FileLabelWithActions", { __retrieveURLAndDownloadSelected: function() { if (this.isMultiSelect()) { - this.__selection.forEach(selection => { - if (selection && osparc.file.FilesTree.isFile(selection)) { - this.__retrieveURLAndDownloadFile(selection); - } - }); + if (this.__selection.length === 1 && osparc.file.FilesTree.isFile(this.__selection[0])) { + this.__retrieveURLAndDownloadFile(this.__selection[0]); + } else if (this.__selection.length > 1) { + const paths = this.__selection.map(item => item.getPath()); + this.__retrieveURLAndDownloadPaths(paths); + } } else if (this.__selection.length) { const selection = this.__selection[0]; - if (selection && osparc.file.FilesTree.isFile(selection)) { - this.__retrieveURLAndDownloadFile(selection); + if (selection) { + if (osparc.file.FilesTree.isFile(selection)) { + this.__retrieveURLAndDownloadFile(selection); + } else { + const paths = [selection.getPath()]; + this.__retrieveURLAndDownloadPaths(paths); + } } } }, @@ -159,7 +165,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { __retrieveURLAndDownloadFile: function(file) { const fileId = file.getFileId(); const locationId = file.getLocation(); - osparc.utils.Utils.retrieveURLAndDownload(locationId, fileId) + osparc.utils.Utils.downloadPaths(locationId, fileId) .then(data => { if (data) { osparc.DownloadLinkTracker.getInstance().downloadLinkUnattended(data.link, data.fileName); @@ -167,6 +173,14 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }); }, + __retrieveURLAndDownloadPaths: function(paths) { + const locationId = 0; + osparc.store.Data.getInstance().retrieveURLAndDownload(locationId, paths) + .then(data => { + console.log("data", data); + }); + }, + __deleteSelected: function() { const toBeDeleted = []; let isFolderSelected = false; diff --git a/services/static-webserver/client/source/class/osparc/store/Data.js b/services/static-webserver/client/source/class/osparc/store/Data.js index f85a9f91e864..a1fc78050d87 100644 --- a/services/static-webserver/client/source/class/osparc/store/Data.js +++ b/services/static-webserver/client/source/class/osparc/store/Data.js @@ -234,7 +234,7 @@ qx.Class.define("osparc.store.Data", { return true; }, - downloadFiles: function(paths) { + downloadPaths: function(paths) { if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) { return null; } From 4237a1d4f8fe9d533d3268e2551e08fa8a3eff98 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 13:23:14 +0200 Subject: [PATCH 03/13] multiDownloadTaskReceived --- .../class/osparc/file/FileLabelWithActions.js | 172 ++++++++++++------ 1 file changed, 112 insertions(+), 60 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 7fc7a9ff709d..2f48dd253878 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -174,11 +174,12 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }, __retrieveURLAndDownloadPaths: function(paths) { - const locationId = 0; - osparc.store.Data.getInstance().retrieveURLAndDownload(locationId, paths) - .then(data => { - console.log("data", data); - }); + const dataStore = osparc.store.Data.getInstance(); + const fetchPromise = dataStore.downloadPaths(paths); + const pollTasks = osparc.store.PollTasks.getInstance(); + pollTasks.createPollingTask(fetchPromise) + .then(task => this.__multiDownloadTaskReceived(task)) + .catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files download"))); }, __deleteSelected: function() { @@ -237,63 +238,114 @@ qx.Class.define("osparc.file.FileLabelWithActions", { const fetchPromise = dataStore.deleteFiles(paths); const pollTasks = osparc.store.PollTasks.getInstance(); pollTasks.createPollingTask(fetchPromise) - .then(task => { - const taskUI = new osparc.task.TaskUI(); - taskUI.setIcon("@FontAwesome5Solid/trash/14"); - taskUI.setTitle(this.tr("Deleting files")); - taskUI.setTask(task); - osparc.task.TasksContainer.getInstance().addTaskUI(taskUI); - - const progressWindow = new osparc.ui.window.Progress( - this.tr("Delete files"), - "@FontAwesome5Solid/trash/14", - this.tr("Deleting files..."), - ); - if (task.getAbortHref()) { - const cancelButton = progressWindow.addCancelButton(); - cancelButton.setLabel(this.tr("Ignore")); - const abortButton = new qx.ui.form.Button().set({ - label: this.tr("Cancel"), - center: true, - minWidth: 100, - }); - abortButton.addListener("execute", () => task.abortRequested()); - progressWindow.addButton(abortButton); - abortButton.set({ - appearance: "danger-button", - }); - } - progressWindow.open(); - - const finished = () => { - progressWindow.close(); - }; - - task.addListener("updateReceived", e => { - const data = e.getData(); - if (data["task_progress"]) { - if ("message" in data["task_progress"] && data["task_progress"]["message"]) { - progressWindow.setMessage(data["task_progress"]["message"]); - } - progressWindow.setProgress(osparc.data.PollTask.extractProgress(data) * 100); - } - }, this); - task.addListener("resultReceived", e => { - finished(); - osparc.FlashMessenger.logAs(this.tr("Items successfully deleted"), "INFO"); - this.fireDataEvent("pathsDeleted", paths); - }); - task.addListener("taskAborted", () => { - finished(); - osparc.FlashMessenger.logAs(this.tr("Deletion aborted"), "WARNING"); - }); - task.addListener("pollingError", e => { - const err = e.getData(); - osparc.FlashMessenger.logError(err); - }); - }) + .then(task => this.__deleteTaskReceived(task, paths)) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files deletion"))); } }, + + __multiDownloadTaskReceived: function(task) { + const taskUI = new osparc.task.TaskUI(); + taskUI.setIcon("@FontAwesome5Solid/download/14"); + taskUI.setTitle(this.tr("Downloading files")); + taskUI.setTask(task); + osparc.task.TasksContainer.getInstance().addTaskUI(taskUI); + + const progressWindow = new osparc.ui.window.Progress( + this.tr("Downloading files"), + "@FontAwesome5Solid/download/14", + this.tr("Downloading files..."), + ); + if (task.getAbortHref()) { + const cancelButton = progressWindow.addCancelButton(); + cancelButton.setLabel(this.tr("Ignore")); + const abortButton = new qx.ui.form.Button().set({ + label: this.tr("Cancel"), + center: true, + minWidth: 100, + }); + abortButton.addListener("execute", () => task.abortRequested()); + progressWindow.addButton(abortButton); + abortButton.set({ + appearance: "danger-button", + }); + } + progressWindow.open(); + + task.addListener("updateReceived", e => { + const data = e.getData(); + if (data["task_progress"]) { + if ("message" in data["task_progress"] && data["task_progress"]["message"]) { + progressWindow.setMessage(data["task_progress"]["message"]); + } + progressWindow.setProgress(osparc.data.PollTask.extractProgress(data) * 100); + } + }, this); + task.addListener("resultReceived", e => { + console.log(e.getData()); + progressWindow.close(); + }); + task.addListener("taskAborted", () => { + osparc.FlashMessenger.logAs(this.tr("Download aborted"), "WARNING"); + progressWindow.close(); + }); + task.addListener("pollingError", e => { + const err = e.getData(); + osparc.FlashMessenger.logError(err); + progressWindow.close(); + }); + }, + + __deleteTaskReceived: function(task, paths) { + const taskUI = new osparc.task.TaskUI(); + taskUI.setIcon("@FontAwesome5Solid/trash/14"); + taskUI.setTitle(this.tr("Deleting files")); + taskUI.setTask(task); + osparc.task.TasksContainer.getInstance().addTaskUI(taskUI); + + const progressWindow = new osparc.ui.window.Progress( + this.tr("Delete files"), + "@FontAwesome5Solid/trash/14", + this.tr("Deleting files..."), + ); + if (task.getAbortHref()) { + const cancelButton = progressWindow.addCancelButton(); + cancelButton.setLabel(this.tr("Ignore")); + const abortButton = new qx.ui.form.Button().set({ + label: this.tr("Cancel"), + center: true, + minWidth: 100, + }); + abortButton.addListener("execute", () => task.abortRequested()); + progressWindow.addButton(abortButton); + abortButton.set({ + appearance: "danger-button", + }); + } + progressWindow.open(); + + task.addListener("updateReceived", e => { + const data = e.getData(); + if (data["task_progress"]) { + if ("message" in data["task_progress"] && data["task_progress"]["message"]) { + progressWindow.setMessage(data["task_progress"]["message"]); + } + progressWindow.setProgress(osparc.data.PollTask.extractProgress(data) * 100); + } + }, this); + task.addListener("resultReceived", e => { + osparc.FlashMessenger.logAs(this.tr("Items successfully deleted"), "INFO"); + this.fireDataEvent("pathsDeleted", paths); + progressWindow.close(); + }); + task.addListener("taskAborted", () => { + osparc.FlashMessenger.logAs(this.tr("Deletion aborted"), "WARNING"); + progressWindow.close(); + }); + task.addListener("pollingError", e => { + const err = e.getData(); + osparc.FlashMessenger.logError(err); + progressWindow.close(); + }); + }, } }); From e98c48208b19cd59b03b4f0874177f42d3433ffa Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 13:41:05 +0200 Subject: [PATCH 04/13] download result --- .../class/osparc/file/FileLabelWithActions.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 2f48dd253878..2640d3f1054b 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -281,7 +281,21 @@ qx.Class.define("osparc.file.FileLabelWithActions", { } }, this); task.addListener("resultReceived", e => { - console.log(e.getData()); + const data = e.getData(); + if (data["result"]) { + const link = data["result"]; + + const params = { + url: { + locationId: 0, + fileUuid: link + } + }; + osparc.data.Resources.fetch("storageLink", "getOne", params) + .then(data2 => { + console.log(data2); + }) + } progressWindow.close(); }); task.addListener("taskAborted", () => { From 55e14bc36d97e59150e0b70e38b3f057ae709054 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 13:58:51 +0200 Subject: [PATCH 05/13] encodeURIComponent --- .../source/class/osparc/file/FileLabelWithActions.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 2640d3f1054b..0b95b61ccdd2 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -109,8 +109,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { setItemSelected: function(selectedItem) { if (selectedItem) { this.__selection = [selectedItem]; - const isFile = osparc.file.FilesTree.isFile(selectedItem); - this.getChildControl("download-button").setEnabled(isFile); + this.getChildControl("download-button").setEnabled(true); // folders can also be downloaded this.getChildControl("delete-button").setEnabled(true); // folders can also be deleted this.getChildControl("selected-label").setValue(selectedItem.getLabel()); } else { @@ -165,7 +164,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { __retrieveURLAndDownloadFile: function(file) { const fileId = file.getFileId(); const locationId = file.getLocation(); - osparc.utils.Utils.downloadPaths(locationId, fileId) + osparc.utils.Utils.retrieveURLAndDownload(locationId, fileId) .then(data => { if (data) { osparc.DownloadLinkTracker.getInstance().downloadLinkUnattended(data.link, data.fileName); @@ -283,17 +282,15 @@ qx.Class.define("osparc.file.FileLabelWithActions", { task.addListener("resultReceived", e => { const data = e.getData(); if (data["result"]) { - const link = data["result"]; - const params = { url: { locationId: 0, - fileUuid: link + fileUuid: encodeURIComponent(data["result"]), } }; osparc.data.Resources.fetch("storageLink", "getOne", params) .then(data2 => { - console.log(data2); + osparc.utils.Utils.downloadLink(data2.link, "GET", "hey"); }) } progressWindow.close(); From 64e4c8f5d43de2819d495621944deb572ad66130 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 14:14:14 +0200 Subject: [PATCH 06/13] v --- .../class/osparc/file/FileLabelWithActions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 0b95b61ccdd2..663845acd7a6 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -280,17 +280,20 @@ qx.Class.define("osparc.file.FileLabelWithActions", { } }, this); task.addListener("resultReceived", e => { - const data = e.getData(); - if (data["result"]) { + const taskData = e.getData(); + if (taskData["result"]) { const params = { url: { locationId: 0, - fileUuid: encodeURIComponent(data["result"]), + fileUuid: encodeURIComponent(taskData["result"]), } }; osparc.data.Resources.fetch("storageLink", "getOne", params) - .then(data2 => { - osparc.utils.Utils.downloadLink(data2.link, "GET", "hey"); + .then(data => { + if (data && data.link) { + const fileName = taskData["result"].split("/").pop(); + osparc.utils.Utils.downloadLink(data.link, "GET", fileName); + } }) } progressWindow.close(); From f95592c934fa653fee9dca8f83c9abe2a4af8a96 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 14:25:59 +0200 Subject: [PATCH 07/13] isDevFeaturesEnabled --- .../client/source/class/osparc/store/StaticInfo.js | 6 +++++- .../client/source/class/osparc/utils/DisabledPlugins.js | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js index 341827779eb6..92c4b42bbd04 100644 --- a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js +++ b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js @@ -121,6 +121,10 @@ qx.Class.define("osparc.store.StaticInfo", { return wsStaticData[key]; } return null; - } + }, + + isDevFeaturesEnabled: function() { + return this.getValue("webserverDevFeaturesEnabled"); + }, } }); diff --git a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js index 233ba211e05d..7715ec9640e6 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -29,7 +29,6 @@ qx.Class.define("osparc.utils.DisabledPlugins", { VERSION_CONTROL: "WEBSERVER_VERSION_CONTROL", META_MODELING: "WEBSERVER_META_MODELING", LICENSES: "WEBSERVER_LICENSES", - SHARE_WITH_EMAIL: "WEBSERVER_SHARE_WITH_EMAIL", isExportDisabled: function() { return this.__isPluginDisabled(this.EXPORT); @@ -54,10 +53,14 @@ qx.Class.define("osparc.utils.DisabledPlugins", { }, isShareWithEmailEnabled: function() { - // return !this.__isPluginDisabled(this.SHARE_WITH_EMAIL); - return new Promise(resolve => resolve(osparc.utils.Utils.isDevelopmentPlatform())); + return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); }, + isMultiDownloadEnabled: function() { + return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); + }, + + isJobsEnabled: function() { if (osparc.utils.Utils.isDevelopmentPlatform() && osparc.product.Utils.isProduct("s4lacad")) { return true; From 79b472df933b351a37eb9ad8148bf3b0dc3bb74d Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 14:28:05 +0200 Subject: [PATCH 08/13] isMultiDownloadEnabled --- .../client/source/class/osparc/file/FileLabelWithActions.js | 4 +++- .../client/source/class/osparc/utils/DisabledPlugins.js | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 663845acd7a6..bb1ba61291e7 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -109,7 +109,9 @@ qx.Class.define("osparc.file.FileLabelWithActions", { setItemSelected: function(selectedItem) { if (selectedItem) { this.__selection = [selectedItem]; - this.getChildControl("download-button").setEnabled(true); // folders can also be downloaded + const isFile = osparc.file.FilesTree.isFile(selectedItem); + const isMultiDownloadEnabled = osparc.utils.DisabledPlugins.isMultiDownloadEnabled(); + this.getChildControl("download-button").setEnabled(isFile || isMultiDownloadEnabled); // folders can also be downloaded this.getChildControl("delete-button").setEnabled(true); // folders can also be deleted this.getChildControl("selected-label").setValue(selectedItem.getLabel()); } else { diff --git a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js index 7715ec9640e6..37fcce0187bb 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -60,7 +60,6 @@ qx.Class.define("osparc.utils.DisabledPlugins", { return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); }, - isJobsEnabled: function() { if (osparc.utils.Utils.isDevelopmentPlatform() && osparc.product.Utils.isProduct("s4lacad")) { return true; From eeabdb0bda45e322aba8e623f53ef3d32140b564 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 14:35:46 +0200 Subject: [PATCH 09/13] DownloadPaths --- .../class/osparc/file/FileLabelWithActions.js | 8 ++- .../source/class/osparc/task/DownloadPaths.js | 31 +++++++++++ .../client/source/class/osparc/task/TaskUI.js | 51 ++++++++++--------- 3 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 services/static-webserver/client/source/class/osparc/task/DownloadPaths.js diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index bb1ba61291e7..66a5f42a1a51 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -245,11 +245,9 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }, __multiDownloadTaskReceived: function(task) { - const taskUI = new osparc.task.TaskUI(); - taskUI.setIcon("@FontAwesome5Solid/download/14"); - taskUI.setTitle(this.tr("Downloading files")); - taskUI.setTask(task); - osparc.task.TasksContainer.getInstance().addTaskUI(taskUI); + const downloadPathsTaskUI = new osparc.task.osparc.task.DownloadPaths(); + downloadPathsTaskUI.setTask(task); + osparc.task.TasksContainer.getInstance().addTaskUI(downloadPathsTaskUI); const progressWindow = new osparc.ui.window.Progress( this.tr("Downloading files"), diff --git a/services/static-webserver/client/source/class/osparc/task/DownloadPaths.js b/services/static-webserver/client/source/class/osparc/task/DownloadPaths.js new file mode 100644 index 000000000000..b1391d886ff2 --- /dev/null +++ b/services/static-webserver/client/source/class/osparc/task/DownloadPaths.js @@ -0,0 +1,31 @@ +/* ************************************************************************ + + osparc - the simcore frontend + + https://osparc.io + + Copyright: + 2025 IT'IS Foundation, https://itis.swiss + + License: + MIT: https://opensource.org/licenses/MIT + + Authors: + * Odei Maiz (odeimaiz) + +************************************************************************ */ + +qx.Class.define("osparc.task.DownloadPaths", { + extend: osparc.task.TaskUI, + + construct: function() { + this.base(arguments); + + this.setIcon(this.self().ICON+"/14"); + this.setTitle(this.tr("Downloading files:")); + }, + + statics: { + ICON: "@FontAwesome5Solid/download" + }, +}); diff --git a/services/static-webserver/client/source/class/osparc/task/TaskUI.js b/services/static-webserver/client/source/class/osparc/task/TaskUI.js index bbfbc5c9b0d4..f19322c17864 100644 --- a/services/static-webserver/client/source/class/osparc/task/TaskUI.js +++ b/services/static-webserver/client/source/class/osparc/task/TaskUI.js @@ -121,35 +121,38 @@ qx.Class.define("osparc.task.TaskUI", { }, __applyTask: function(task) { - task.addListener("updateReceived", e => { - const data = e.getData(); - if (data["task_progress"]) { - if ("message" in data["task_progress"] && !this.getChildControl("subtitle").getValue()) { - this.getChildControl("subtitle").setValue(data["task_progress"]["message"]); - } - this.getChildControl("progress").setValue((osparc.data.PollTask.extractProgress(data) * 100) + "%"); - } - }, this); + task.addListener("updateReceived", e => this._updateHandler(e.getData()), this); const stopButton = this.getChildControl("stop"); task.bind("abortHref", stopButton, "visibility", { converter: abortHref => abortHref ? "visible" : "excluded" }); - stopButton.addListener("tap", () => { - const msg = this.tr("Are you sure you want to cancel the task?"); - const win = new osparc.ui.window.Confirmation(msg).set({ - caption: this.tr("Cancel Task"), - confirmText: this.tr("Cancel"), - confirmAction: "delete" - }); - win.getCancelButton().setLabel(this.tr("Ignore")); - win.center(); - win.open(); - win.addListener("close", () => { - if (win.getConfirmed()) { - task.abortRequested(); - } - }, this); + stopButton.addListener("tap", () => this._abortHandler(), this); + }, + + _updateHandler: function(data) { + if (data["task_progress"]) { + if ("message" in data["task_progress"] && !this.getChildControl("subtitle").getValue()) { + this.getChildControl("subtitle").setValue(data["task_progress"]["message"]); + } + this.getChildControl("progress").setValue((osparc.data.PollTask.extractProgress(data) * 100) + "%"); + } + }, + + _abortHandler: function() { + const msg = this.tr("Are you sure you want to cancel the task?"); + const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Cancel Task"), + confirmText: this.tr("Cancel"), + confirmAction: "delete" + }); + win.getCancelButton().setLabel(this.tr("Ignore")); + win.center(); + win.open(); + win.addListener("close", () => { + if (win.getConfirmed()) { + this.getTask().abortRequested(); + } }, this); }, From 960d0d59fa262c5d0fa12dcbc7e1ae85cb6d45f9 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 14:49:33 +0200 Subject: [PATCH 10/13] renaming --- .../class/osparc/file/FileLabelWithActions.js | 14 +++++++------- .../client/source/class/osparc/store/Data.js | 2 +- .../client/source/class/osparc/store/PollTasks.js | 4 ++++ .../task/{DownloadPaths.js => ExportData.js} | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) rename services/static-webserver/client/source/class/osparc/task/{DownloadPaths.js => ExportData.js} (92%) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 66a5f42a1a51..9f6ac6c03ae3 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -148,7 +148,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { this.__retrieveURLAndDownloadFile(this.__selection[0]); } else if (this.__selection.length > 1) { const paths = this.__selection.map(item => item.getPath()); - this.__retrieveURLAndDownloadPaths(paths); + this.__retrieveURLAndExportData(paths); } } else if (this.__selection.length) { const selection = this.__selection[0]; @@ -157,7 +157,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { this.__retrieveURLAndDownloadFile(selection); } else { const paths = [selection.getPath()]; - this.__retrieveURLAndDownloadPaths(paths); + this.__retrieveURLAndExportData(paths); } } } @@ -174,9 +174,9 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }); }, - __retrieveURLAndDownloadPaths: function(paths) { + __retrieveURLAndExportData: function(paths) { const dataStore = osparc.store.Data.getInstance(); - const fetchPromise = dataStore.downloadPaths(paths); + const fetchPromise = dataStore.exportData(paths); const pollTasks = osparc.store.PollTasks.getInstance(); pollTasks.createPollingTask(fetchPromise) .then(task => this.__multiDownloadTaskReceived(task)) @@ -245,9 +245,9 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }, __multiDownloadTaskReceived: function(task) { - const downloadPathsTaskUI = new osparc.task.osparc.task.DownloadPaths(); - downloadPathsTaskUI.setTask(task); - osparc.task.TasksContainer.getInstance().addTaskUI(downloadPathsTaskUI); + const exportDataTaskUI = new osparc.task.osparc.task.ExportData(); + exportDataTaskUI.setTask(task); + osparc.task.TasksContainer.getInstance().addTaskUI(exportDataTaskUI); const progressWindow = new osparc.ui.window.Progress( this.tr("Downloading files"), diff --git a/services/static-webserver/client/source/class/osparc/store/Data.js b/services/static-webserver/client/source/class/osparc/store/Data.js index a1fc78050d87..a1fd4f47add1 100644 --- a/services/static-webserver/client/source/class/osparc/store/Data.js +++ b/services/static-webserver/client/source/class/osparc/store/Data.js @@ -234,7 +234,7 @@ qx.Class.define("osparc.store.Data", { return true; }, - downloadPaths: function(paths) { + exportData: function(paths) { if (!osparc.data.Permissions.getInstance().canDo("study.node.data.delete", true)) { return null; } diff --git a/services/static-webserver/client/source/class/osparc/store/PollTasks.js b/services/static-webserver/client/source/class/osparc/store/PollTasks.js index 9adbb29f196b..5ae6af9a5902 100644 --- a/services/static-webserver/client/source/class/osparc/store/PollTasks.js +++ b/services/static-webserver/client/source/class/osparc/store/PollTasks.js @@ -83,6 +83,10 @@ qx.Class.define("osparc.store.PollTasks", { return this.getTasks().filter(task => task.getTaskId().includes("from_study") && task.getTaskId().includes("as_template")); }, + getExportDataTasks: function() { + return this.getTasks().filter(task => task.getTaskId().includes("from_study") && task.getTaskId().includes("as_template")); + }, + removeTasks: function() { const tasks = this.getTasks(); tasks.forEach(task => task.dispose()); diff --git a/services/static-webserver/client/source/class/osparc/task/DownloadPaths.js b/services/static-webserver/client/source/class/osparc/task/ExportData.js similarity index 92% rename from services/static-webserver/client/source/class/osparc/task/DownloadPaths.js rename to services/static-webserver/client/source/class/osparc/task/ExportData.js index b1391d886ff2..a8c46a34f0ed 100644 --- a/services/static-webserver/client/source/class/osparc/task/DownloadPaths.js +++ b/services/static-webserver/client/source/class/osparc/task/ExportData.js @@ -15,7 +15,7 @@ ************************************************************************ */ -qx.Class.define("osparc.task.DownloadPaths", { +qx.Class.define("osparc.task.ExportData", { extend: osparc.task.TaskUI, construct: function() { From 9a87d781a1511b0ba941ea6ff153675caaeb9543 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 15:25:06 +0200 Subject: [PATCH 11/13] minor --- .../client/source/class/osparc/file/FileLabelWithActions.js | 2 +- .../client/source/class/osparc/store/PollTasks.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 9f6ac6c03ae3..29fe4bdfd8be 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -245,7 +245,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }, __multiDownloadTaskReceived: function(task) { - const exportDataTaskUI = new osparc.task.osparc.task.ExportData(); + const exportDataTaskUI = new osparc.task.ExportData(); exportDataTaskUI.setTask(task); osparc.task.TasksContainer.getInstance().addTaskUI(exportDataTaskUI); diff --git a/services/static-webserver/client/source/class/osparc/store/PollTasks.js b/services/static-webserver/client/source/class/osparc/store/PollTasks.js index 5ae6af9a5902..9adbb29f196b 100644 --- a/services/static-webserver/client/source/class/osparc/store/PollTasks.js +++ b/services/static-webserver/client/source/class/osparc/store/PollTasks.js @@ -83,10 +83,6 @@ qx.Class.define("osparc.store.PollTasks", { return this.getTasks().filter(task => task.getTaskId().includes("from_study") && task.getTaskId().includes("as_template")); }, - getExportDataTasks: function() { - return this.getTasks().filter(task => task.getTaskId().includes("from_study") && task.getTaskId().includes("as_template")); - }, - removeTasks: function() { const tasks = this.getTasks(); tasks.forEach(task => task.dispose()); From cbd15dcc95373c0e0fa7b098652320de0040ddfd Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 16:03:37 +0200 Subject: [PATCH 12/13] isMultiDownloadEnabled --- .../client/source/class/osparc/file/FileLabelWithActions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 29fe4bdfd8be..970eed8d88fc 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -143,10 +143,11 @@ qx.Class.define("osparc.file.FileLabelWithActions", { }, __retrieveURLAndDownloadSelected: function() { + const isMultiDownloadEnabled = osparc.utils.DisabledPlugins.isMultiDownloadEnabled(); if (this.isMultiSelect()) { if (this.__selection.length === 1 && osparc.file.FilesTree.isFile(this.__selection[0])) { this.__retrieveURLAndDownloadFile(this.__selection[0]); - } else if (this.__selection.length > 1) { + } else if (this.__selection.length > 1 && isMultiDownloadEnabled) { const paths = this.__selection.map(item => item.getPath()); this.__retrieveURLAndExportData(paths); } @@ -155,7 +156,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { if (selection) { if (osparc.file.FilesTree.isFile(selection)) { this.__retrieveURLAndDownloadFile(selection); - } else { + } else if (isMultiDownloadEnabled) { const paths = [selection.getPath()]; this.__retrieveURLAndExportData(paths); } From fcd35a5598ae01dc87f322d6bc4a1618d5fd038b Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 9 Apr 2025 16:04:16 +0200 Subject: [PATCH 13/13] renaming --- .../client/source/class/osparc/file/FileLabelWithActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 970eed8d88fc..21fb0d39cad4 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -180,7 +180,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { const fetchPromise = dataStore.exportData(paths); const pollTasks = osparc.store.PollTasks.getInstance(); pollTasks.createPollingTask(fetchPromise) - .then(task => this.__multiDownloadTaskReceived(task)) + .then(task => this.__exportDataTaskReceived(task)) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files download"))); }, @@ -245,7 +245,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { } }, - __multiDownloadTaskReceived: function(task) { + __exportDataTaskReceived: function(task) { const exportDataTaskUI = new osparc.task.ExportData(); exportDataTaskUI.setTask(task); osparc.task.TasksContainer.getInstance().addTaskUI(exportDataTaskUI);