Skip to content

Commit 6105d2e

Browse files
🎨 [Frontend] Fetch tasks from the given projectUuid (#7743)
Co-authored-by: Matus Drobuliak <60785969+matusdrobuliak66@users.noreply.github.com>
1 parent e5ef303 commit 6105d2e

File tree

8 files changed

+94
-39
lines changed

8 files changed

+94
-39
lines changed

services/static-webserver/client/source/class/osparc/jobs/ActivityCenterWindow.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ qx.Class.define("osparc.jobs.ActivityCenterWindow", {
5858
stack.add(subRunsBrowser);
5959

6060
runsBrowser.addListener("runSelected", e => {
61-
const project = e.getData();
61+
const data = e.getData();
62+
const project = data["rowData"];
6263
subRunsBrowser.setProject(project);
6364
this.getChildControl("title").setValue(this.tr("Tasks"));
6465
stack.setSelection([subRunsBrowser]);

services/static-webserver/client/source/class/osparc/jobs/ActivityOverview.js

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
2121
construct: function(projectData) {
2222
this.base(arguments);
2323

24-
this._setLayout(new qx.ui.layout.VBox(10));
24+
this._setLayout(new qx.ui.layout.VBox());
2525

2626
this.__buildLayout(projectData);
2727
},
@@ -39,7 +39,54 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
3939
},
4040

4141
members: {
42+
__runsTable: null,
43+
__subRunsTable: null,
44+
4245
__buildLayout: function(projectData) {
46+
const stack = new qx.ui.container.Stack();
47+
this._add(stack, {
48+
flex: 1
49+
});
50+
51+
const runsHistoryLayout = this.__createRunsHistoryView(projectData);
52+
stack.add(runsHistoryLayout);
53+
54+
const tasksLayout = this.__createTasksView();
55+
stack.add(tasksLayout);
56+
57+
this.__runsTable.addListener("runSelected", e => {
58+
const data = e.getData();
59+
const project = data["rowData"];
60+
const projectUuid = project["projectUuid"];
61+
// Hacky-hacky
62+
for (let i=0; i<this.__runsTable.getTableModel().getRowCount(); i++) {
63+
const rowData = this.__runsTable.getTableModel().getRowData(i);
64+
if (rowData["projectUuid"] === projectUuid && data["rowIdx"] > i) {
65+
const msg = this.tr("Only the latest run's tasks are available");
66+
osparc.FlashMessenger.logAs(msg, "WARNING");
67+
return;
68+
}
69+
}
70+
71+
if (this.__subRunsTable) {
72+
tasksLayout.remove(this.__subRunsTable);
73+
this.__subRunsTable = null;
74+
}
75+
const subRunsTable = this.__subRunsTable = new osparc.jobs.SubRunsTable(project["projectUuid"]);
76+
tasksLayout.add(subRunsTable, {
77+
flex: 1
78+
});
79+
stack.setSelection([tasksLayout]);
80+
81+
tasksLayout.addListener("backToRuns", () => {
82+
stack.setSelection([runsHistoryLayout]);
83+
});
84+
}, this);
85+
},
86+
87+
__createRunsHistoryView: function(projectData) {
88+
const runsHistoryLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
89+
4390
const runsHistoryTitleLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
4491
alignY: "middle",
4592
})).set({
@@ -49,47 +96,52 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
4996
font: "text-14"
5097
});
5198
runsHistoryTitleLayout.add(runsHistoryTitle);
52-
const runsHistoryTitleHelper = new osparc.ui.hint.InfoHint(this.tr("In this table, the history of the project runs is shown."))
99+
const runsHistoryTitleHelper = new osparc.ui.hint.InfoHint(this.tr("In this table, the history of the project runs is shown. Select a run to see its tasks."))
53100
runsHistoryTitleLayout.add(runsHistoryTitleHelper);
54-
this._add(runsHistoryTitleLayout);
101+
runsHistoryLayout.add(runsHistoryTitleLayout);
55102

56103
const projectUuid = projectData["uuid"];
57104
const includeChildren = true;
58105
const runningOnly = false;
59-
const runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
106+
const runsTable = this.__runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
60107
const columnModel = runsTable.getTableColumnModel();
61108
// Hide project name column
62109
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.PROJECT_NAME.column, false);
63110
// Hide cancel column
64111
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.ACTION_CANCEL.column, false);
65-
runsTable.set({
66-
maxHeight: 250,
67-
})
68-
this._add(runsTable, {
112+
runsHistoryLayout.add(runsTable, {
69113
flex: 1
70114
});
71115

116+
return runsHistoryLayout;
117+
},
118+
119+
__createTasksView: function() {
120+
const tasksLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
72121

73122
const latestTasksTitleLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
74123
alignY: "middle",
75124
})).set({
76125
paddingLeft: 10,
77126
});
78-
const latestTasksTitle = new qx.ui.basic.Label(this.tr("Latest Tasks")).set({
127+
128+
const prevBtn = new qx.ui.form.Button().set({
129+
toolTipText: this.tr("Return to Runs"),
130+
icon: "@FontAwesome5Solid/arrow-left/20",
131+
backgroundColor: "transparent"
132+
});
133+
prevBtn.addListener("execute", () => tasksLayout.fireEvent("backToRuns"));
134+
latestTasksTitleLayout.add(prevBtn);
135+
136+
const latestTasksTitle = new qx.ui.basic.Label(this.tr("Tasks")).set({
79137
font: "text-14"
80138
});
81139
latestTasksTitleLayout.add(latestTasksTitle);
82-
const latestTasksTitleHelper = new osparc.ui.hint.InfoHint(this.tr("In this table, only the latest tasks or simulations are shown. If available, the logs can be downloaded."))
140+
const latestTasksTitleHelper = new osparc.ui.hint.InfoHint(this.tr("In this table, the tasks or simulations of the selected run are shown. If available, the logs can be downloaded."))
83141
latestTasksTitleLayout.add(latestTasksTitleHelper);
84-
this._add(latestTasksTitleLayout);
85-
86-
const subRunsTable = new osparc.jobs.SubRunsTable(projectUuid, includeChildren);
87-
subRunsTable.set({
88-
maxHeight: 250,
89-
})
90-
this._add(subRunsTable, {
91-
flex: 1,
92-
});
142+
tasksLayout.add(latestTasksTitleLayout);
143+
144+
return tasksLayout;
93145
},
94146
}
95147
});

services/static-webserver/client/source/class/osparc/jobs/RunsTable.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,19 @@ qx.Class.define("osparc.jobs.RunsTable", {
139139

140140
__attachHandlers: function() {
141141
this.addListener("cellTap", e => {
142-
const row = e.getRow();
142+
const rowIdx = e.getRow();
143143
const target = e.getOriginalTarget();
144144
if (target.closest(".qx-material-button") && (target.tagName === "IMG" || target.tagName === "DIV")) {
145145
const action = target.closest(".qx-material-button").getAttribute("data-action");
146146
if (action) {
147-
this.__handleButtonClick(action, row);
147+
this.__handleButtonClick(action, rowIdx);
148148
}
149149
} else {
150-
const rowData = this.getTableModel().getRowData(row);
151-
this.fireDataEvent("runSelected", rowData);
150+
const rowData = this.getTableModel().getRowData(rowIdx);
151+
this.fireDataEvent("runSelected", {
152+
rowData,
153+
rowIdx,
154+
});
152155
this.resetSelection();
153156
}
154157
});

services/static-webserver/client/source/class/osparc/jobs/RunsTableModel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
143143

144144
// Divides the model row request into several server requests to comply with the number of rows server limit
145145
const reqLimit = lastRow - firstRow + 1; // Number of requested rows
146-
const nRequests = Math.ceil(reqLimit / this.self().SERVER_MAX_LIMIT);
146+
let nRequests = Math.ceil(reqLimit / this.self().SERVER_MAX_LIMIT);
147147
if (nRequests > 1) {
148148
const requests = [];
149149
for (let i=firstRow; i <= lastRow; i += this.self().SERVER_MAX_LIMIT) {
150-
requests.push(getFetchPromise(i, i > lastRow - this.self().SERVER_MAX_LIMIT + 1 ? reqLimit % this.self().SERVER_MAX_LIMIT : this.self().SERVER_MAX_LIMIT))
150+
// fetch the first page only
151+
if (i < 1) {
152+
requests.push(getFetchPromise(i, i > lastRow - this.self().SERVER_MAX_LIMIT + 1 ? reqLimit % this.self().SERVER_MAX_LIMIT : this.self().SERVER_MAX_LIMIT))
153+
}
151154
}
152155
Promise.all(requests)
153156
.then(responses => this._onRowDataLoaded(responses.flat()))

services/static-webserver/client/source/class/osparc/jobs/SubRunsBrowser.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ qx.Class.define("osparc.jobs.SubRunsBrowser", {
4949
}));
5050

5151
const prevBtn = new qx.ui.form.Button().set({
52-
toolTipText: this.tr("Return to Runs and Clusters"),
52+
toolTipText: this.tr("Return to Runs"),
5353
icon: "@FontAwesome5Solid/arrow-left/20",
5454
backgroundColor: "transparent"
5555
});
@@ -74,8 +74,7 @@ qx.Class.define("osparc.jobs.SubRunsBrowser", {
7474

7575
this.__titleLabel.setValue(project["projectName"])
7676

77-
const includeChildren = false;
78-
const subRunsTable = this.__subRunsTable = new osparc.jobs.SubRunsTable(project["projectUuid"], includeChildren);
77+
const subRunsTable = this.__subRunsTable = new osparc.jobs.SubRunsTable(project["projectUuid"]);
7978
this._add(subRunsTable, {
8079
flex: 1
8180
});

services/static-webserver/client/source/class/osparc/jobs/SubRunsTable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
qx.Class.define("osparc.jobs.SubRunsTable", {
2020
extend: qx.ui.table.Table,
2121

22-
construct: function(projectUuid, includeChildren = false) {
22+
construct: function(projectUuid) {
2323
this.base(arguments);
2424

25-
const model = new osparc.jobs.SubRunsTableModel(projectUuid, includeChildren);
25+
const model = new osparc.jobs.SubRunsTableModel(projectUuid);
2626
this.setTableModel(model);
2727

2828
this.set({

services/static-webserver/client/source/class/osparc/jobs/SubRunsTableModel.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
qx.Class.define("osparc.jobs.SubRunsTableModel", {
2020
extend: qx.ui.table.model.Remote,
2121

22-
construct: function(projectUuid, includeChildren = false) {
22+
construct: function(projectUuid) {
2323
this.base(arguments);
2424

2525
const subJobsCols = osparc.jobs.SubRunsTable.COLS;
@@ -34,7 +34,6 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
3434
});
3535

3636
this.setProjectUuid(projectUuid);
37-
this.__includeChildren = includeChildren;
3837
},
3938

4039
properties: {
@@ -51,11 +50,9 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
5150
},
5251

5352
members: {
54-
__includeChildren: null,
55-
5653
// overridden
5754
_loadRowCount() {
58-
osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid(), this.__includeChildren)
55+
osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid())
5956
.then(subJobs => {
6057
this._onRowCountLoaded(subJobs.length)
6158
})
@@ -71,7 +68,7 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
7168
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
7269
// Returns a request promise with given offset and limit
7370
const getFetchPromise = () => {
74-
return osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid(), this.__includeChildren)
71+
return osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid())
7572
.then(subJobs => {
7673
const data = [];
7774
const subJobsCols = osparc.jobs.SubRunsTable.COLS;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ qx.Class.define("osparc.store.Jobs", {
119119
.catch(err => console.error(err));
120120
},
121121

122-
fetchSubJobs: function(projectUuid, includeChildren = false) {
122+
fetchSubJobs: function(projectUuid) {
123123
const params = {
124124
url: {
125125
studyId: projectUuid,
126-
includeChildren,
126+
includeChildren: false,
127127
}
128128
};
129129
return osparc.data.Resources.getInstance().getAllPages("subRuns", params, "getPageLatest")

0 commit comments

Comments
 (0)