Skip to content

Commit 2d15bb8

Browse files
committed
Activity Overview with two tables
1 parent 90c7268 commit 2d15bb8

File tree

5 files changed

+83
-7
lines changed

5 files changed

+83
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ qx.Class.define("osparc.data.Resources", {
356356
},
357357
getPageHistory: {
358358
method: "GET",
359-
url: statics.API + "/computations/{studyId}/iterations?offset={offset}&limit={limit}"
359+
url: statics.API + "/computations/{studyId}/iterations?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D"
360360
},
361361
}
362362
},

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

Lines changed: 25 additions & 2 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(15));
24+
this._setLayout(new qx.ui.layout.VBox(10));
2525

2626
this.__buildLayout(projectData);
2727
},
@@ -30,18 +30,41 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
3030
popUpInWindow: function(projectData) {
3131
const activityOverview = new osparc.jobs.ActivityOverview(projectData);
3232
const title = qx.locale.Manager.tr("Activity Overview");
33-
return osparc.ui.window.Window.popUpInWindow(activityOverview, title, osparc.jobs.ActivityCenterWindow.WIDTH, osparc.jobs.ActivityCenterWindow.HEIGHT);
33+
const win = osparc.ui.window.Window.popUpInWindow(activityOverview, title, osparc.jobs.ActivityCenterWindow.WIDTH, osparc.jobs.ActivityCenterWindow.HEIGHT);
34+
win.set({
35+
maxHeight: 700,
36+
});
37+
return win;
3438
},
3539
},
3640

3741
members: {
3842
__buildLayout: function(projectData) {
43+
this._add(new qx.ui.basic.Label(this.tr("Runs History")).set({
44+
font: "text-14"
45+
}));
46+
3947
const latestOnly = false;
4048
const projectUuid = projectData["uuid"];
4149
const runsTable = new osparc.jobs.RunsTable(latestOnly, projectUuid);
50+
const columnModel = runsTable.getTableColumnModel();
51+
// Hide project name column
52+
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.PROJECT_NAME.column, false);
53+
// Hide cancel column
54+
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.ACTION_CANCEL.column, false);
55+
runsTable.set({
56+
maxHeight: 250,
57+
})
4258
this._add(runsTable);
4359

60+
this._add(new qx.ui.basic.Label(this.tr("Latest Tasks")).set({
61+
font: "text-14"
62+
}));
63+
4464
const subRunsTable = new osparc.jobs.SubRunsTable(projectData["uuid"]);
65+
subRunsTable.set({
66+
maxHeight: 250,
67+
})
4568
this._add(subRunsTable);
4669
},
4770
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ qx.Class.define("osparc.jobs.RunsTable", {
2222
construct: function(latestOnly = true, projectUuid = null) {
2323
this.base(arguments);
2424

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

2828
this.set({

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

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

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

25+
this.__latestOnly = latestOnly;
26+
this.__projectUuid = projectUuid;
27+
2528
const jobsCols = osparc.jobs.RunsTable.COLS;
2629
const colLabels = Object.values(jobsCols).map(col => col.label);
2730
const colIDs = Object.values(jobsCols).map(col => col.id);
@@ -60,7 +63,13 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
6063
const offset = 0;
6164
const limit = 1;
6265
const resolveWResponse = true;
63-
osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse)
66+
let promise;
67+
if (this.__latestOnly && this.__projectUuid === null) {
68+
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
69+
} else {
70+
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
71+
}
72+
promise
6473
.then(resp => {
6574
this._onRowCountLoaded(resp["_meta"].total)
6675
})
@@ -76,7 +85,13 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
7685
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
7786
// Returns a request promise with given offset and limit
7887
const getFetchPromise = (offset, limit) => {
79-
return osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()))
88+
let promise;
89+
if (this.__latestOnly && this.__projectUuid === null) {
90+
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()));
91+
} else {
92+
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, offset, limit, JSON.stringify(this.getOrderBy()));
93+
}
94+
promise
8095
.then(jobs => {
8196
const data = [];
8297
const jobsCols = osparc.jobs.RunsTable.COLS;

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,44 @@ qx.Class.define("osparc.store.Jobs", {
7373
.catch(err => console.error(err));
7474
},
7575

76+
fetchJobsHistory: function(
77+
studyId,
78+
offset = 0,
79+
limit = this.self().SERVER_MAX_LIMIT,
80+
orderBy = {
81+
field: "submitted_at",
82+
direction: "desc"
83+
},
84+
resolveWResponse = false
85+
) {
86+
const params = {
87+
url: {
88+
studyId,
89+
offset,
90+
limit,
91+
orderBy: JSON.stringify(orderBy),
92+
}
93+
};
94+
const options = {
95+
resolveWResponse: true
96+
};
97+
return osparc.data.Resources.fetch("jobs", "getPageHistory", params, options)
98+
.then(jobsResp => {
99+
if (resolveWResponse) {
100+
return jobsResp;
101+
}
102+
const jobs = [];
103+
if ("data" in jobsResp) {
104+
jobsResp["data"].forEach(jobData => {
105+
const job = new osparc.data.Job(jobData);
106+
jobs.push(job);
107+
});
108+
}
109+
return jobs;
110+
})
111+
.catch(err => console.error(err));
112+
},
113+
76114
fetchSubJobs: function(projectUuid) {
77115
const params = {
78116
url: {

0 commit comments

Comments
 (0)