Skip to content

Commit 1a9b912

Browse files
✨ [Frontend] Allow users access not-running latest runs (#7723)
Co-authored-by: matusdrobuliak66 <[email protected]> Co-authored-by: Matus Drobuliak <[email protected]>
1 parent 1147ace commit 1a9b912

File tree

6 files changed

+83
-20
lines changed

6 files changed

+83
-20
lines changed

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ qx.Class.define("osparc.data.Resources", {
350350
"runs": {
351351
useCache: false, // handled in osparc.store.Jobs
352352
endpoints: {
353-
getPageLatestActive: {
353+
getPageLatest: {
354354
method: "GET",
355-
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D&filter_only_running=true"
355+
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D&filter_only_running={runningOnly}"
356356
},
357357
getPageHistory: {
358358
method: "GET",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
5555

5656
const projectUuid = projectData["uuid"];
5757
const includeChildren = true;
58-
const runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren);
58+
const runningOnly = false;
59+
const runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
5960
const columnModel = runsTable.getTableColumnModel();
6061
// Hide project name column
6162
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.PROJECT_NAME.column, false);

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
2525
this._setLayout(new qx.ui.layout.VBox(10));
2626

2727
const jobsFilter = this.getChildControl("jobs-filter");
28-
const jobsTable = this.getChildControl("runs-table");
28+
const runningCB = this.getChildControl("running-only-cb");
29+
const runsTable = this.getChildControl("runs-table");
2930

3031
jobsFilter.getChildControl("textfield").addListener("input", e => {
3132
const filterText = e.getData();
32-
jobsTable.getTableModel().setFilters({
33-
text: filterText,
34-
});
33+
runsTable.getTableModel().setFilterString(filterText);
3534
});
3635

37-
this.__reloadInterval = setInterval(() => this.getChildControl("runs-table").reloadRuns(), 10*1000);
36+
runningCB.bind("value", runsTable, "runningOnly");
37+
38+
this.__reloadInterval = setInterval(() => this.reloadRuns(), 10*1000);
3839
},
3940

4041
events: {
@@ -60,10 +61,18 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
6061
flex: 1
6162
});
6263
break;
64+
case "running-only-cb":
65+
control = new qx.ui.form.CheckBox().set({
66+
value: true,
67+
label: qx.locale.Manager.tr("Active only"),
68+
});
69+
this.getChildControl("header-filter").add(control);
70+
break;
6371
case "runs-table": {
6472
const projectUuid = null;
6573
const includeChildren = false;
66-
control = new osparc.jobs.RunsTable(projectUuid, includeChildren);
74+
const runningOnly = true;
75+
control = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
6776
control.addListener("runSelected", e => this.fireDataEvent("runSelected", e.getData()));
6877
this._add(control);
6978
break;

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

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

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

25+
this.set({
26+
projectUuid,
27+
runningOnly,
28+
});
29+
2530
const model = new osparc.jobs.RunsTableModel(projectUuid, includeChildren);
31+
this.bind("projectUuid", model, "projectUuid");
32+
this.bind("runningOnly", model, "runningOnly");
2633
this.setTableModel(model);
2734

2835
this.set({
@@ -47,6 +54,22 @@ qx.Class.define("osparc.jobs.RunsTable", {
4754
this.__attachHandlers();
4855
},
4956

57+
properties: {
58+
projectUuid: {
59+
check: "String",
60+
init: null,
61+
nullable: true,
62+
event: "changeProjectUuid",
63+
},
64+
65+
runningOnly: {
66+
check: "Boolean",
67+
init: true,
68+
nullable: false,
69+
event: "changeRunningOnly",
70+
},
71+
},
72+
5073
events: {
5174
"runSelected": "qx.event.type.Data",
5275
},

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

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
2222
construct: function(projectUuid = null, includeChildren = false) {
2323
this.base(arguments);
2424

25-
this.__projectUuid = projectUuid;
2625
this.__includeChildren = includeChildren;
2726

27+
this.set({
28+
projectUuid,
29+
});
30+
2831
const jobsCols = osparc.jobs.RunsTable.COLS;
2932
const colLabels = Object.values(jobsCols).map(col => col.label);
3033
const colIDs = Object.values(jobsCols).map(col => col.id);
@@ -38,6 +41,22 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
3841
},
3942

4043
properties: {
44+
projectUuid: {
45+
check: "String",
46+
init: null,
47+
nullable: true,
48+
event: "changeProjectUuid",
49+
apply: "reloadData",
50+
},
51+
52+
runningOnly: {
53+
check: "Boolean",
54+
init: true,
55+
nullable: false,
56+
event: "changeRunningOnly",
57+
apply: "reloadData",
58+
},
59+
4160
isFetching: {
4261
check: "Boolean",
4362
init: false,
@@ -51,26 +70,32 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
5170
direction: "desc"
5271
}
5372
},
73+
74+
filterString: {
75+
nullable: true,
76+
check : "String",
77+
init: "",
78+
},
5479
},
5580

5681
statics: {
5782
SERVER_MAX_LIMIT: 49,
5883
},
5984

6085
members: {
61-
__projectUuid: null,
6286
__includeChildren: false,
6387

6488
// overridden
6589
_loadRowCount() {
6690
const offset = 0;
6791
const limit = 1;
92+
const orderBy = this.getOrderBy();
6893
const resolveWResponse = true;
6994
let promise;
70-
if (this.__projectUuid) {
71-
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, this.__includeChildren, offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
95+
if (this.getProjectUuid()) {
96+
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.getProjectUuid(), this.__includeChildren, offset, limit, orderBy, resolveWResponse);
7297
} else {
73-
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
98+
promise = osparc.store.Jobs.getInstance().fetchJobsActive(this.getRunningOnly(), offset, limit, orderBy, resolveWResponse);
7499
}
75100
promise
76101
.then(resp => {
@@ -88,11 +113,12 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
88113
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
89114
// Returns a request promise with given offset and limit
90115
const getFetchPromise = (offset, limit) => {
116+
const orderBy = this.getOrderBy();
91117
let promise;
92-
if (this.__projectUuid) {
93-
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, this.__includeChildren, offset, limit, JSON.stringify(this.getOrderBy()));
118+
if (this.getProjectUuid()) {
119+
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.getProjectUuid(), this.__includeChildren, offset, limit, orderBy);
94120
} else {
95-
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()));
121+
promise = osparc.store.Jobs.getInstance().fetchJobsActive(this.getRunningOnly(), offset, limit, orderBy);
96122
}
97123
return promise
98124
.then(jobs => {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ qx.Class.define("osparc.store.Jobs", {
3838

3939
members: {
4040
fetchJobsActive: function(
41+
runningOnly = true,
4142
offset = 0,
4243
limit = this.self().SERVER_MAX_LIMIT,
4344
orderBy = {
@@ -48,6 +49,7 @@ qx.Class.define("osparc.store.Jobs", {
4849
) {
4950
const params = {
5051
url: {
52+
runningOnly,
5153
offset,
5254
limit,
5355
orderBy: JSON.stringify(orderBy),
@@ -56,9 +58,11 @@ qx.Class.define("osparc.store.Jobs", {
5658
const options = {
5759
resolveWResponse: true
5860
};
59-
return osparc.data.Resources.fetch("runs", "getPageLatestActive", params, options)
61+
return osparc.data.Resources.fetch("runs", "getPageLatest", params, options)
6062
.then(jobsResp => {
61-
this.fireDataEvent("changeJobsActive", jobsResp["_meta"]["total"]);
63+
if (runningOnly) {
64+
this.fireDataEvent("changeJobsActive", jobsResp["_meta"]["total"]);
65+
}
6266
const jobsActive = [];
6367
if ("data" in jobsResp) {
6468
jobsResp["data"].forEach(jobActiveData => {

0 commit comments

Comments
 (0)