Skip to content

Commit 28e8a63

Browse files
committed
changeJobsActive
1 parent 1ee59e9 commit 28e8a63

File tree

4 files changed

+82
-14
lines changed

4 files changed

+82
-14
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
337337
[
338338
this.__getInfoPage,
339339
this.__getBillingPage,
340+
this.__getActivityOverviewPage,
340341
this.__getServicesUpdatePage,
341342
this.__getServicesBootOptionsPage,
342343
this.__getConversationsPage,
@@ -494,6 +495,31 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
494495
return null;
495496
},
496497

498+
__getActivityOverviewPage: function() {
499+
const resourceData = this.__resourceData;
500+
if (
501+
!osparc.desktop.credits.Utils.areWalletsEnabled() ||
502+
!osparc.utils.Resources.isStudy(resourceData)
503+
) {
504+
return null;
505+
}
506+
507+
const id = "ActivityOverview";
508+
const title = this.tr("Activity Overview");
509+
const iconSrc = "@FontAwesome5Solid/tasks/22";
510+
const page = this.__billingSettings = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
511+
this.__addOpenButton(page);
512+
513+
const lazyLoadContent = () => {
514+
const activityOverview = new osparc.jobs.ActivityOverview(resourceData);
515+
const billingScroll = new qx.ui.container.Scroll(activityOverview);
516+
page.addToContent(billingScroll);
517+
}
518+
page.addListenerOnce("appear", lazyLoadContent, this);
519+
520+
return page;
521+
},
522+
497523
__getPreviewPage: function() {
498524
const resourceData = this.__resourceData;
499525
if (
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.ActivityOverview", {
19+
extend: qx.ui.core.Widget,
20+
21+
construct: function(projectData) {
22+
this.base(arguments);
23+
24+
this._setLayout(new qx.ui.layout.VBox(15));
25+
26+
this.__buildLayout(projectData);
27+
},
28+
29+
members: {
30+
__buildLayout: function(projectData) {
31+
const subRunsTable = new osparc.jobs.SubRunsTable(projectData["uuid"]);
32+
this._add(subRunsTable);
33+
34+
this.addListener("close", () => {
35+
subRunsTable.stopInterval();
36+
});
37+
},
38+
}
39+
});

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ qx.Class.define("osparc.jobs.JobsButton", {
3333
this.addListener("tap", () => osparc.jobs.ActivityCenterWindow.openWindow(), this);
3434

3535
const jobsStore = osparc.store.Jobs.getInstance();
36-
jobsStore.addListener("changeJobsActive", () => this.__updateJobsButton(), this);
37-
this.__updateJobsButton();
36+
jobsStore.addListener("changeJobsActive", e => this.__updateJobsButton(e.getData()), this);
37+
jobsStore.fetchJobsActive();
3838
},
3939

4040
members: {
@@ -71,12 +71,11 @@ qx.Class.define("osparc.jobs.JobsButton", {
7171
return control || this.base(arguments, id);
7272
},
7373

74-
__updateJobsButton: function() {
74+
__updateJobsButton: function(nActiveJobs) {
7575
this.getChildControl("icon");
7676
const number = this.getChildControl("number");
7777

78-
const jobsStore = osparc.store.Jobs.getInstance();
79-
const nJobs = jobsStore.getJobsActive().length > osparc.store.Jobs.SERVER_MAX_LIMIT ? (osparc.store.Jobs.SERVER_MAX_LIMIT + "+") : jobsStore.getJobsActive().length;
78+
const nJobs = nActiveJobs > osparc.store.Jobs.SERVER_MAX_LIMIT ? (osparc.store.Jobs.SERVER_MAX_LIMIT + "+") : nActiveJobs;
8079
number.setValue(nJobs.toString());
8180
},
8281
}

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ qx.Class.define("osparc.store.Jobs", {
2020
type: "singleton",
2121

2222
properties: {
23-
jobsActive: {
23+
jobs: {
2424
check: "Array",
2525
init: [],
2626
nullable: true,
27-
event: "changeJobsActive"
28-
}
27+
event: "changeJobs"
28+
},
29+
},
30+
31+
events: {
32+
"changeJobsActive": "qx.event.type.Data",
2933
},
3034

3135
statics: {
@@ -54,10 +58,11 @@ qx.Class.define("osparc.store.Jobs", {
5458
};
5559
return osparc.data.Resources.fetch("jobsActive", "getPage", params, options)
5660
.then(jobsResp => {
61+
this.fireDataEvent("changeJobsActive", jobsResp["_meta"]["total"]);
5762
const jobsActive = [];
5863
if ("data" in jobsResp) {
5964
jobsResp["data"].forEach(jobActiveData => {
60-
jobsActive.push(this.__addJobActive(jobActiveData));
65+
jobsActive.push(this.__addJob(jobActiveData));
6166
});
6267
}
6368
if (resolveWResponse) {
@@ -85,16 +90,15 @@ qx.Class.define("osparc.store.Jobs", {
8590
.catch(err => console.error(err));
8691
},
8792

88-
__addJobActive: function(jobData) {
89-
const jobsActive = this.getJobsActive();
90-
const jobFound = jobsActive.find(job => job.getProjectUuid() === jobData["projectUuid"]);
93+
__addJob: function(jobData) {
94+
const jobs = this.getJobs();
95+
const jobFound = jobs.find(job => job.getProjectUuid() === jobData["projectUuid"]);
9196
if (jobFound) {
9297
jobFound.updateJob(jobData);
9398
return jobFound;
9499
}
95100
const job = new osparc.data.Job(jobData);
96-
jobsActive.push(job);
97-
this.fireDataEvent("changeJobsActive");
101+
jobs.push(job);
98102
return job;
99103
},
100104

0 commit comments

Comments
 (0)