Skip to content

Commit 0ab3c40

Browse files
committed
JobsButton
1 parent 9907c38 commit 0ab3c40

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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.jobs.JobsButton", {
19+
extend: qx.ui.core.Widget,
20+
21+
construct: function() {
22+
this.base(arguments);
23+
24+
this._setLayout(new qx.ui.layout.Canvas());
25+
26+
this.set({
27+
width: 30,
28+
alignX: "center",
29+
cursor: "pointer",
30+
visibility: "excluded",
31+
toolTipText: this.tr("Jobs"),
32+
});
33+
34+
const jobsStore = osparc.store.Jobs.getInstance();
35+
jobsStore.getJobs().addListener("change", e => this.__updateJobsButton(), this);
36+
this.addListener("tap", () => console.log("Pop up jobs table"), this);
37+
},
38+
39+
members: {
40+
_createChildControlImpl: function(id) {
41+
let control;
42+
switch (id) {
43+
case "icon": {
44+
control = new qx.ui.basic.Image("@FontAwesome5Solid/cog/24");
45+
osparc.utils.Utils.addClass(control.getContentElement(), "rotate");
46+
47+
const logoContainer = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({
48+
alignY: "middle"
49+
}));
50+
logoContainer.add(control);
51+
52+
this._add(logoContainer, {
53+
height: "100%"
54+
});
55+
break;
56+
}
57+
case "number":
58+
control = new qx.ui.basic.Label().set({
59+
backgroundColor: "background-main-1",
60+
font: "text-12"
61+
});
62+
control.getContentElement().setStyles({
63+
"border-radius": "4px"
64+
});
65+
this._add(control, {
66+
bottom: 8,
67+
right: 4
68+
});
69+
break;
70+
}
71+
return control || this.base(arguments, id);
72+
},
73+
74+
__updateJobsButton: function() {
75+
this._createChildControlImpl("icon");
76+
const number = this.getChildControl("number");
77+
78+
const jobsStore = osparc.store.Jobs.getInstance();
79+
const nJobs = jobsStore.getJobs().length;
80+
number.setValue(nJobs.toString());
81+
nJobs ? this.show() : this.exclude();
82+
},
83+
}
84+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ qx.Class.define("osparc.task.TasksButton", {
2828
alignX: "center",
2929
cursor: "pointer",
3030
visibility: "excluded",
31-
tooltipText: this.tr("Tasks"),
31+
toolTipText: this.tr("Tasks"),
3232
});
3333

3434
const tasks = osparc.task.TasksContainer.getInstance();

services/static-webserver/client/source/resource/osparc/mock_jobs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"status": "STARTED",
3030
"progress": 50,
3131
"submitted_at": "2024-11-27 14:03:17.357523",
32-
"started_at": "2024-11-27 14:03:17.357523",
32+
"started_at": "2025-03-19 14:03:17.357523",
3333
"instance": "p5.8xlarge"
3434
}],
3535
"jobs_info": {

0 commit comments

Comments
 (0)