Skip to content

Commit eeabdb0

Browse files
committed
DownloadPaths
1 parent 79b472d commit eeabdb0

File tree

3 files changed

+61
-29
lines changed

3 files changed

+61
-29
lines changed

services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,9 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
245245
},
246246

247247
__multiDownloadTaskReceived: function(task) {
248-
const taskUI = new osparc.task.TaskUI();
249-
taskUI.setIcon("@FontAwesome5Solid/download/14");
250-
taskUI.setTitle(this.tr("Downloading files"));
251-
taskUI.setTask(task);
252-
osparc.task.TasksContainer.getInstance().addTaskUI(taskUI);
248+
const downloadPathsTaskUI = new osparc.task.osparc.task.DownloadPaths();
249+
downloadPathsTaskUI.setTask(task);
250+
osparc.task.TasksContainer.getInstance().addTaskUI(downloadPathsTaskUI);
253251

254252
const progressWindow = new osparc.ui.window.Progress(
255253
this.tr("Downloading files"),
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.task.DownloadPaths", {
19+
extend: osparc.task.TaskUI,
20+
21+
construct: function() {
22+
this.base(arguments);
23+
24+
this.setIcon(this.self().ICON+"/14");
25+
this.setTitle(this.tr("Downloading files:"));
26+
},
27+
28+
statics: {
29+
ICON: "@FontAwesome5Solid/download"
30+
},
31+
});

services/static-webserver/client/source/class/osparc/task/TaskUI.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,35 +121,38 @@ qx.Class.define("osparc.task.TaskUI", {
121121
},
122122

123123
__applyTask: function(task) {
124-
task.addListener("updateReceived", e => {
125-
const data = e.getData();
126-
if (data["task_progress"]) {
127-
if ("message" in data["task_progress"] && !this.getChildControl("subtitle").getValue()) {
128-
this.getChildControl("subtitle").setValue(data["task_progress"]["message"]);
129-
}
130-
this.getChildControl("progress").setValue((osparc.data.PollTask.extractProgress(data) * 100) + "%");
131-
}
132-
}, this);
124+
task.addListener("updateReceived", e => this._updateHandler(e.getData()), this);
133125

134126
const stopButton = this.getChildControl("stop");
135127
task.bind("abortHref", stopButton, "visibility", {
136128
converter: abortHref => abortHref ? "visible" : "excluded"
137129
});
138-
stopButton.addListener("tap", () => {
139-
const msg = this.tr("Are you sure you want to cancel the task?");
140-
const win = new osparc.ui.window.Confirmation(msg).set({
141-
caption: this.tr("Cancel Task"),
142-
confirmText: this.tr("Cancel"),
143-
confirmAction: "delete"
144-
});
145-
win.getCancelButton().setLabel(this.tr("Ignore"));
146-
win.center();
147-
win.open();
148-
win.addListener("close", () => {
149-
if (win.getConfirmed()) {
150-
task.abortRequested();
151-
}
152-
}, this);
130+
stopButton.addListener("tap", () => this._abortHandler(), this);
131+
},
132+
133+
_updateHandler: function(data) {
134+
if (data["task_progress"]) {
135+
if ("message" in data["task_progress"] && !this.getChildControl("subtitle").getValue()) {
136+
this.getChildControl("subtitle").setValue(data["task_progress"]["message"]);
137+
}
138+
this.getChildControl("progress").setValue((osparc.data.PollTask.extractProgress(data) * 100) + "%");
139+
}
140+
},
141+
142+
_abortHandler: function() {
143+
const msg = this.tr("Are you sure you want to cancel the task?");
144+
const win = new osparc.ui.window.Confirmation(msg).set({
145+
caption: this.tr("Cancel Task"),
146+
confirmText: this.tr("Cancel"),
147+
confirmAction: "delete"
148+
});
149+
win.getCancelButton().setLabel(this.tr("Ignore"));
150+
win.center();
151+
win.open();
152+
win.addListener("close", () => {
153+
if (win.getConfirmed()) {
154+
this.getTask().abortRequested();
155+
}
153156
}, this);
154157
},
155158

0 commit comments

Comments
 (0)