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 9dbb176ebaf4..ad9506fd5857 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -580,6 +580,10 @@ qx.Class.define("osparc.data.Resources", { get: { method: "GET", url: statics.API + "/tasks" + }, + delete: { + method: "DELETE", + url: statics.API + "/tasks/{taskId}" } } }, 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 531f133b0038..0b1bedb0aeb4 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -109,9 +109,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { setItemSelected: function(selectedItem) { if (selectedItem) { this.__selection = [selectedItem]; - 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("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 { @@ -143,11 +141,10 @@ 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 && isMultiDownloadEnabled) { + } else if (this.__selection.length > 1) { const paths = this.__selection.map(item => item.getPath()); this.__retrieveURLAndExportData(paths); } @@ -156,7 +153,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { if (selection) { if (osparc.file.FilesTree.isFile(selection)) { this.__retrieveURLAndDownloadFile(selection); - } else if (isMultiDownloadEnabled) { + } else { const paths = [selection.getPath()]; this.__retrieveURLAndExportData(paths); } diff --git a/services/static-webserver/client/source/class/osparc/task/ExportData.js b/services/static-webserver/client/source/class/osparc/task/ExportData.js index 85c00d75801c..542b3eca7e48 100644 --- a/services/static-webserver/client/source/class/osparc/task/ExportData.js +++ b/services/static-webserver/client/source/class/osparc/task/ExportData.js @@ -85,7 +85,16 @@ qx.Class.define("osparc.task.ExportData", { .then(data => { if (data && data.link) { const fileName = taskData["result"].split("/").pop(); - osparc.utils.Utils.downloadLink(data.link, "GET", fileName); + const progressCb = null; + const loadedCb = () => { + const deleteParams = { + url: { + taskId: task.getTaskId(), + } + }; + osparc.data.Resources.fetch("tasks", "delete", deleteParams); + } + osparc.utils.Utils.downloadLink(data.link, "GET", fileName, progressCb, loadedCb); } }) } 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 b814306e3096..20bd1416678a 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -56,10 +56,6 @@ qx.Class.define("osparc.utils.DisabledPlugins", { return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); }, - isMultiDownloadEnabled: function() { - return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); - }, - isJobsEnabled: function() { return osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled(); }, diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index ba09c48dc979..ea48b14120f1 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -858,24 +858,25 @@ qx.Class.define("osparc.utils.Utils", { } }); xhr.addEventListener("progress", e => { - if (xhr.readyState === XMLHttpRequest.LOADING) { - if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 400)) { - if (e["type"] === "progress" && progressCb) { - progressCb(e.loaded / e.total); - } - } + if ( + progressCb && + xhr.readyState === XMLHttpRequest.LOADING && + (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 400)) && + e["type"] === "progress" + ) { + progressCb(e.loaded / e.total); } }); xhr.addEventListener("load", () => { if (xhr.status == 200) { - if (loadedCb) { - loadedCb(); - } const blob = new Blob([xhr.response]); if (!fileName) { fileName = this.self().filenameFromContentDisposition(xhr); } this.self().downloadBlobContent(blob, fileName); + if (loadedCb) { + loadedCb(); + } resolve(); } else { reject(xhr);