Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading