Skip to content

Commit 10c4a9d

Browse files
odeimaizmatusdrobuliak66mergify[bot]
authored
✨ [Frontend] Jobs: Connect to backend (#7550)
Co-authored-by: matusdrobuliak66 <[email protected]> Co-authored-by: Matus Drobuliak <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 69ccf1f commit 10c4a9d

File tree

21 files changed

+990
-468
lines changed

21 files changed

+990
-468
lines changed

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

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,40 @@ qx.Class.define("osparc.data.Job", {
2222
this.base(arguments);
2323

2424
this.set({
25-
jobId: jobData["job_id"],
26-
solver: jobData["solver"],
27-
status: jobData["status"],
28-
progress: jobData["progress"],
29-
submittedAt: jobData["submitted_at"] ? new Date(jobData["submitted_at"]) : null,
30-
startedAt: jobData["started_at"] ? new Date(jobData["started_at"]) : null,
31-
instance: jobData["instance"],
25+
projectUuid: jobData["projectUuid"],
26+
state: jobData["state"],
27+
submittedAt: jobData["submittedAt"] ? new Date(jobData["submittedAt"]) : null,
28+
startedAt: jobData["startedAt"] ? new Date(jobData["startedAt"]) : null,
29+
endedAt: jobData["endedAt"] ? new Date(jobData["endedAt"]) : null,
30+
info: jobData["info"] || null,
3231
});
32+
33+
if (jobData["info"] && jobData["info"]["project_name"]) {
34+
this.setProjectName(jobData["info"]["project_name"]);
35+
}
36+
37+
this.__subJobs = [];
3338
},
3439

3540
properties: {
36-
jobId: {
41+
projectUuid: {
3742
check: "String",
3843
nullable: false,
3944
init: null,
4045
},
4146

42-
solver: {
47+
projectName: {
4348
check: "String",
4449
nullable: false,
4550
init: null,
4651
},
4752

48-
status: {
53+
state: {
4954
check: "String",
5055
nullable: false,
5156
init: null,
5257
},
5358

54-
progress: {
55-
check: "Number",
56-
init: null,
57-
nullable: true,
58-
},
59-
6059
submittedAt: {
6160
check: "Date",
6261
init: null,
@@ -69,10 +68,10 @@ qx.Class.define("osparc.data.Job", {
6968
nullable: true,
7069
},
7170

72-
instance: {
73-
check: "String",
74-
nullable: false,
71+
endedAt: {
72+
check: "Date",
7573
init: null,
74+
nullable: true,
7675
},
7776

7877
info: {
@@ -81,4 +80,37 @@ qx.Class.define("osparc.data.Job", {
8180
init: null,
8281
},
8382
},
83+
84+
members: {
85+
__subJobs: null,
86+
87+
addSubJob: function(subJobData) {
88+
const subJobFound = this.__subJobs.find(subJb => subJb.getNodeId() === subJobData["nodeId"]);
89+
if (subJobFound) {
90+
subJobFound.updateSubJob(subJobData);
91+
return subJobFound;
92+
}
93+
94+
const subJob = new osparc.data.SubJob(subJobData);
95+
this.__subJobs.push(subJob);
96+
return subJob;
97+
},
98+
99+
updateJob: function(jobData) {
100+
this.set({
101+
state: jobData["state"],
102+
submittedAt: jobData["submittedAt"] ? new Date(jobData["submittedAt"]) : null,
103+
startedAt: jobData["startedAt"] ? new Date(jobData["startedAt"]) : null,
104+
endedAt: jobData["endedAt"] ? new Date(jobData["endedAt"]) : null,
105+
});
106+
},
107+
108+
getSubJobs: function() {
109+
return this.__subJobs;
110+
},
111+
112+
getSubJob: function(nodeId) {
113+
return this.__subJobs.find(subJb => subJb.getNodeId() === nodeId);
114+
},
115+
}
84116
});

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,25 @@ qx.Class.define("osparc.data.Resources", {
319319
}
320320
}
321321
},
322+
"jobs": {
323+
useCache: false, // handled in osparc.store.Jobs
324+
endpoints: {
325+
getPage: {
326+
method: "GET",
327+
// url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by={orderBy}"
328+
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D"
329+
},
330+
}
331+
},
332+
"subJobs": {
333+
useCache: false, // handled in osparc.store.Jobs
334+
endpoints: {
335+
getPage: {
336+
method: "GET",
337+
url: statics.API + "/computations/{studyId}/iterations/latest/tasks?offset={offset}&limit={limit}"
338+
},
339+
}
340+
},
322341
"folders": {
323342
useCache: true,
324343
idField: "uuid",
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.data.SubJob", {
19+
extend: qx.core.Object,
20+
21+
construct: function(subJobData) {
22+
this.base(arguments);
23+
24+
this.set({
25+
projectUuid: subJobData["projectUuid"],
26+
nodeId: subJobData["nodeId"],
27+
nodeName: subJobData["nodeId"],
28+
state: subJobData["state"],
29+
progress: subJobData["progress"],
30+
startedAt: subJobData["startedAt"] ? new Date(subJobData["startedAt"]) : null,
31+
endedAt: subJobData["endedAt"] ? new Date(subJobData["endedAt"]) : null,
32+
image: subJobData["image"] || {},
33+
});
34+
},
35+
36+
properties: {
37+
projectUuid: {
38+
check: "String",
39+
nullable: false,
40+
init: null,
41+
},
42+
43+
nodeId: {
44+
check: "String",
45+
nullable: false,
46+
init: null,
47+
},
48+
49+
nodeName: {
50+
check: "String",
51+
nullable: false,
52+
init: null,
53+
},
54+
55+
state: {
56+
check: "String",
57+
nullable: true,
58+
init: null,
59+
},
60+
61+
progress: {
62+
check: "Number",
63+
nullable: true,
64+
init: null,
65+
},
66+
67+
startedAt: {
68+
check: "Date",
69+
init: null,
70+
nullable: true,
71+
},
72+
73+
endedAt: {
74+
check: "Date",
75+
init: null,
76+
nullable: true,
77+
},
78+
79+
image: {
80+
check: "Object",
81+
nullable: false,
82+
init: null,
83+
},
84+
},
85+
86+
members: {
87+
updateSubJob: function(subJobData) {
88+
this.set({
89+
state: subJobData["state"],
90+
progress: subJobData["progress"],
91+
startedAt: subJobData["startedAt"] ? new Date(subJobData["startedAt"]) : null,
92+
endedAt: subJobData["endedAt"] ? new Date(subJobData["endedAt"]) : null,
93+
});
94+
},
95+
},
96+
});

services/static-webserver/client/source/class/osparc/jobs/JobInfo.js renamed to services/static-webserver/client/source/class/osparc/jobs/Info.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@
1616
************************************************************************ */
1717

1818

19-
qx.Class.define("osparc.jobs.JobInfo", {
19+
qx.Class.define("osparc.jobs.Info", {
2020
extend: qx.ui.core.Widget,
2121

22-
construct(jobId) {
22+
construct(info) {
2323
this.base(arguments);
2424

2525
this._setLayout(new qx.ui.layout.VBox());
2626

2727
const jobInfoViewer = this.getChildControl("job-info-viewer");
28-
osparc.store.Jobs.getInstance().fetchJobInfo(jobId)
29-
.then(info => {
30-
jobInfoViewer.setJson(info);
31-
});
28+
jobInfoViewer.setJson(info);
3229
},
3330

3431
statics: {

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

Lines changed: 0 additions & 60 deletions
This file was deleted.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ qx.Class.define("osparc.jobs.JobsButton", {
2828
alignX: "center",
2929
cursor: "pointer",
3030
visibility: "excluded",
31-
toolTipText: this.tr("Jobs and Clusters"),
31+
toolTipText: this.tr("Runs and Clusters"),
3232
});
3333

34+
this.addListener("tap", () => osparc.jobs.RunsWindow.openWindow(), this);
35+
3436
const jobsStore = osparc.store.Jobs.getInstance();
3537
jobsStore.addListener("changeJobs", e => this.__updateJobsButton(), this);
36-
this.addListener("tap", () => osparc.jobs.JobsAndClusters.popUpInWindow(), this);
3738
},
3839

3940
members: {
4041
_createChildControlImpl: function(id) {
4142
let control;
4243
switch (id) {
4344
case "icon": {
44-
control = new qx.ui.basic.Image("@FontAwesome5Solid/cog/22");
45-
osparc.utils.Utils.addClass(control.getContentElement(), "rotateSlow");
45+
control = new qx.ui.basic.Image("@FontAwesome5Solid/tasks/22");
4646

4747
const logoContainer = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({
4848
alignY: "middle"
@@ -76,7 +76,7 @@ qx.Class.define("osparc.jobs.JobsButton", {
7676
const number = this.getChildControl("number");
7777

7878
const jobsStore = osparc.store.Jobs.getInstance();
79-
const nJobs = jobsStore.getJobs().length;
79+
const nJobs = jobsStore.getJobs().length > 20 ? "20+" : jobsStore.getJobs().length;
8080
number.setValue(nJobs.toString());
8181
nJobs ? this.show() : this.exclude();
8282
},

0 commit comments

Comments
 (0)