Skip to content

Commit 02cd6ea

Browse files
committed
Delete Progress
1 parent 516cc24 commit 02cd6ea

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,41 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
231231
taskUI.setTask(task);
232232
osparc.task.TasksContainer.getInstance().addTaskUI(taskUI);
233233

234+
const progressWindow = new osparc.ui.window.Progress(
235+
this.tr("Deleting files"),
236+
"@FontAwesome5Solid/trash/14",
237+
this.tr("Deleting files..."),
238+
);
239+
progressWindow.open();
240+
241+
const finished = (msg, msgLevel) => {
242+
if (msg) {
243+
osparc.FlashMessenger.logAs(msg, msgLevel);
244+
}
245+
progressWindow.close();
246+
};
247+
248+
task.addListener("updateReceived", e => {
249+
const data = e.getData();
250+
console.log("updateReceived", data);
251+
if (data["task_progress"]) {
252+
if ("message" in data["task_progress"] && data["task_progress"]["message"]) {
253+
progressWindow.setMessage(data["task_progress"]["message"]);
254+
}
255+
if ("percent" in data["task_progress"]) {
256+
progressWindow.setProgress(data["task_progress"]["percent"]*100);
257+
}
258+
}
259+
}, this);
234260
task.addListener("resultReceived", e => {
235261
this.fireDataEvent("pathsDeleted", paths);
236-
osparc.FlashMessenger.logAs(this.tr("Items successfully deleted"), "INFO");
262+
finished(this.tr("Items successfully deleted"), "INFO");
263+
});
264+
task.addListener("taskAborted", () => finished(this.tr("Deletion aborted"), "WARNING"));
265+
task.addListener("pollingError", e => {
266+
const err = e.getData();
267+
const msg = this.tr("Something went wrong while deleting the files<br>") + err.message;
268+
finished(msg, "ERROR");
237269
});
238270
})
239271
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files deletion")));
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* oSPARC - The SIMCORE frontend - https://osparc.io
3+
* Copyright: 2025 IT'IS Foundation - https://itis.swiss
4+
* License: MIT - https://opensource.org/licenses/MIT
5+
* Authors: Odei Maiz (odeimaiz)
6+
*/
7+
8+
/**
9+
* Generic progress window.
10+
*/
11+
qx.Class.define("osparc.ui.window.Progress", {
12+
extend: osparc.ui.window.Dialog,
13+
14+
construct: function(title, icon, message) {
15+
this.base(arguments, title, icon, message);
16+
17+
const progressBar = this.getChildControl("progress-bar");
18+
this.bind("progress", progressBar, "value");
19+
},
20+
21+
properties: {
22+
progress: {
23+
check: "Number",
24+
init: 0,
25+
nullable: false,
26+
event: "changeProgress"
27+
},
28+
},
29+
30+
members: {
31+
_createChildControlImpl: function(id) {
32+
let control;
33+
switch (id) {
34+
case "progress-bar":
35+
control = new qx.ui.indicator.ProgressBar().set({
36+
maximum: 100,
37+
maxHeight: 12,
38+
alignX: "center",
39+
alignY: "middle",
40+
allowGrowY: false,
41+
allowGrowX: true,
42+
margin: 0,
43+
});
44+
control.getChildControl("progress").set({
45+
backgroundColor: "strong-main"
46+
});
47+
this.add(control);
48+
break;
49+
}
50+
return control || this.base(arguments, id);
51+
},
52+
}
53+
});

0 commit comments

Comments
 (0)