Skip to content

Commit 669df41

Browse files
committed
more refactoring
1 parent 8d79a29 commit 669df41

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,8 +1924,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19241924
.catch(err => {
19251925
const msg = osparc.data.Resources.getErrorMsg(JSON.parse(err.response)) || this.tr("Something went wrong while exporting the study");
19261926
osparc.FlashMessenger.logError(err, msg);
1927-
})
1928-
.finally(() => osparc.task.TasksContainer.getInstance().removeTaskUI(exportTaskUI));
1927+
});
19291928
},
19301929

19311930
__importStudy: function(file) {
@@ -1983,26 +1982,22 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19831982
.then(studyData => this._updateStudyData(studyData))
19841983
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while fetching the study")))
19851984
.finally(() => {
1986-
osparc.task.TasksContainer.getInstance().removeTaskUI(importTaskUI);
19871985
this._resourcesContainer.removeNonResourceCard(importingStudyCard);
19881986
});
19891987
} else if (req.status == 400) {
1990-
osparc.task.TasksContainer.getInstance().removeTaskUI(importTaskUI);
19911988
this._resourcesContainer.removeNonResourceCard(importingStudyCard);
19921989
const msg = osparc.data.Resources.getErrorMsg(JSON.parse(req.response)) || this.tr("Something went wrong while importing the study");
19931990
osparc.FlashMessenger.logError(msg);
19941991
}
19951992
});
19961993
req.addEventListener("error", e => {
19971994
// transferFailed
1998-
osparc.task.TasksContainer.getInstance().removeTaskUI(importTaskUI);
19991995
this._resourcesContainer.removeNonResourceCard(importingStudyCard);
20001996
const msg = osparc.data.Resources.getErrorMsg(e) || this.tr("Something went wrong while importing the study");
20011997
osparc.FlashMessenger.logError(msg);
20021998
});
20031999
req.addEventListener("abort", e => {
20042000
// transferAborted
2005-
osparc.task.TasksContainer.getInstance().removeTaskUI(importTaskUI);
20062001
this._resourcesContainer.removeNonResourceCard(importingStudyCard);
20072002
const msg = osparc.data.Resources.getErrorMsg(e) || this.tr("Something went wrong while importing the study");
20082003
osparc.FlashMessenger.logError(msg);
@@ -2143,8 +2138,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21432138
if (msg) {
21442139
osparc.FlashMessenger.logAs(msg, msgLevel);
21452140
}
2146-
osparc.store.PollTasks.getInstance().removeTask(task);
2147-
osparc.task.TasksContainer.getInstance().removeTaskUI(taskUI);
21482141
this._removeTaskCard(task);
21492142
};
21502143

services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
372372
if (msg) {
373373
osparc.FlashMessenger.logAs(msg, msgLevel);
374374
}
375-
osparc.store.PollTasks.getInstance().removeTask(task);
376-
osparc.task.TasksContainer.getInstance().removeTaskUI(taskUI);
377375
this._resourcesContainer.removeNonResourceCard(toTemplateCard);
378376
};
379377

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
225225
const interval = 1000;
226226
pollTasks.createPollingTask(fetchPromise, interval)
227227
.then(task => {
228+
const taskUI = new osparc.task.TaskUI();
229+
taskUI.setTitle(this.tr("Deleting files"));
230+
taskUI.setTask(task);
231+
osparc.task.TasksContainer.getInstance().addTaskUI(taskUI);
232+
228233
task.addListener("resultReceived", e => {
229234
this.fireDataEvent("pathsDeleted", paths);
230235
osparc.FlashMessenger.logAs(this.tr("Items successfully deleted"), "INFO");

services/static-webserver/client/source/class/osparc/store/PollTasks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ qx.Class.define("osparc.store.PollTasks", {
5555
});
5656
},
5757

58-
removeTask: function(task) {
58+
__removeTask: function(task) {
5959
const tasks = this.getTasks();
6060
const index = tasks.findIndex(t => t.getTaskId() === task.getTaskId());
6161
if (index > -1) {
@@ -68,6 +68,7 @@ qx.Class.define("osparc.store.PollTasks", {
6868
const index = tasks.findIndex(t => t.getTaskId() === taskData["task_id"]);
6969
if (index === -1) {
7070
const task = new osparc.data.PollTask(taskData, interval);
71+
task.addListener("resultReceived", () => this.__removeTask(task), this);
7172
tasks.push(task);
7273
return task;
7374
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ qx.Class.define("osparc.task.TasksContainer", {
4646
}
4747
this.__tasks.push(taskUI);
4848
this.__tasksContainer.addAt(taskUI, 0);
49+
50+
taskUI.getTask().addListener("resultReceived", () => this.__removeTaskUI(taskUI), this);
4951
},
5052

51-
removeTaskUI: function(taskUI) {
53+
__removeTaskUI: function(taskUI) {
5254
if (this.__tasks.indexOf(taskUI) > -1) {
5355
this.__tasks.remove(taskUI);
5456
}

0 commit comments

Comments
 (0)