Skip to content

Commit 0ff7180

Browse files
authored
Merge branch 'master' into functions_draft
2 parents bb80d20 + 0fb45a9 commit 0ff7180

30 files changed

+368
-268
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ qx.Class.define("osparc.dashboard.Dashboard", {
6969
appearance: {
7070
init: "dashboard",
7171
refine: true
72-
}
72+
},
7373
},
7474

7575
statics: {
7676
PADDING: 15
7777
},
7878

79+
events: {
80+
"preResourcesLoaded": "qx.event.type.Event",
81+
},
82+
7983
members: {
8084
__studyBrowser: null,
8185
__templateBrowser: null,
@@ -181,12 +185,15 @@ qx.Class.define("osparc.dashboard.Dashboard", {
181185
this.add(tabPage);
182186
}, this);
183187

188+
let preResourcesLoaded = false;
184189
const preResourcePromises = [];
185190
const groupsStore = osparc.store.Groups.getInstance();
186191
preResourcePromises.push(groupsStore.fetchGroupsAndMembers());
187192
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
188193
Promise.all(preResourcePromises)
189194
.then(() => {
195+
preResourcesLoaded = true;
196+
this.fireEvent("preResourcesLoaded");
190197
if (this.__studyBrowser) {
191198
this.__studyBrowser.initResources();
192199
}
@@ -196,15 +203,24 @@ qx.Class.define("osparc.dashboard.Dashboard", {
196203
if (this.__dataBrowser) {
197204
this.__dataBrowser.initResources();
198205
}
199-
200-
this.addListener("changeSelection", e => {
201-
const selectedTab = e.getData()[0];
202-
if (selectedTab && selectedTab.resourceBrowser) {
203-
selectedTab.resourceBrowser.initResources();
204-
}
205-
}, this);
206206
})
207207
.catch(err => console.error(err));
208+
209+
this.addListener("changeSelection", e => {
210+
const selectedTab = e.getData()[0];
211+
if (selectedTab && selectedTab.resourceBrowser) {
212+
// avoid changing the selection when the PreResources are not yet loaded
213+
if (preResourcesLoaded) {
214+
selectedTab.resourceBrowser.initResources();
215+
} else {
216+
const initTab = () => {
217+
selectedTab.resourceBrowser.initResources()
218+
this.removeListener("preResourcesLoaded", initTab);
219+
};
220+
this.addListener("preResourcesLoaded", initTab, this);
221+
}
222+
}
223+
}, this);
208224
},
209225

210226
__createStudyBrowser: function() {

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

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

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
483483
},
484484

485485
_addTaskCard: function(task, cardTitle, cardIcon) {
486+
if (!this._resourcesContainer) {
487+
return null;
488+
}
489+
486490
if (task) {
487491
const taskPlaceholders = this._resourcesContainer.getCards().filter(card => osparc.dashboard.ResourceBrowserBase.isCardTaskPlaceholder(card));
488492
if (taskPlaceholders.find(taskPlaceholder => taskPlaceholder.getTask() === task)) {
@@ -505,6 +509,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
505509
},
506510

507511
_removeTaskCard: function(task) {
512+
if (!this._resourcesContainer) {
513+
return;
514+
}
515+
508516
if (task) {
509517
const taskPlaceholders = this._resourcesContainer.getCards().filter(card => osparc.dashboard.ResourceBrowserBase.isCardTaskPlaceholder(card));
510518
const taskCard = taskPlaceholders.find(taskPlaceholder => taskPlaceholder.getTask() === task);

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

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -356,27 +356,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
356356
}
357357
});
358358

359-
const resourceData = this.__resourceData;
360-
if (!osparc.utils.Resources.isService(resourceData)) {
361-
const title = osparc.product.Utils.getStudyAlias({firstUpperCase: true}) + this.tr(" Files...");
362-
const iconSrc = "@FontAwesome5Solid/file/22";
363-
const dataAccess = new qx.ui.basic.Atom().set({
364-
label: title,
365-
icon: iconSrc,
366-
font: "text-14",
367-
padding: 8,
368-
paddingLeft: 12,
369-
gap: 14,
370-
cursor: "pointer",
371-
});
372-
dataAccess.addListener("tap", () => osparc.widget.StudyDataManager.popUpInWindow(resourceData["uuid"]));
373-
this.addWidgetToTabs(dataAccess);
374359

375-
if (resourceData["resourceType"] === "study") {
376-
const canShowData = osparc.study.Utils.canShowStudyData(resourceData);
377-
dataAccess.setEnabled(canShowData);
378-
}
379-
}
360+
this.__getActivityOverviewPopUp();
361+
this.__getProjectFilesPopUp();
380362

381363
if (selectedTabId) {
382364
const pageFound = tabsView.getChildren().find(page => page.tabId === selectedTabId);
@@ -814,6 +796,52 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
814796
page.addToHeader(toolbar);
815797
page.addToContent(createFunction);
816798
return page;
817-
}
799+
},
800+
801+
__getProjectFilesPopUp: function() {
802+
const resourceData = this.__resourceData;
803+
if (!osparc.utils.Resources.isService(resourceData)) {
804+
const title = osparc.product.Utils.getStudyAlias({firstUpperCase: true}) + this.tr(" Files...");
805+
const iconSrc = "@FontAwesome5Solid/file/22";
806+
const dataAccess = new qx.ui.basic.Atom().set({
807+
label: title,
808+
icon: iconSrc,
809+
font: "text-14",
810+
padding: 8,
811+
paddingLeft: 12,
812+
gap: 14,
813+
cursor: "pointer",
814+
});
815+
dataAccess.addListener("tap", () => osparc.widget.StudyDataManager.popUpInWindow(resourceData["uuid"]));
816+
this.addWidgetToTabs(dataAccess);
817+
818+
if (resourceData["resourceType"] === "study") {
819+
const canShowData = osparc.study.Utils.canShowStudyData(resourceData);
820+
dataAccess.setEnabled(canShowData);
821+
}
822+
}
823+
},
824+
825+
__getActivityOverviewPopUp: function() {
826+
const resourceData = this.__resourceData;
827+
if (
828+
osparc.desktop.credits.Utils.areWalletsEnabled() &&
829+
osparc.utils.Resources.isStudy(resourceData)
830+
) {
831+
const title = this.tr("Activity Overview...");
832+
const iconSrc = "@FontAwesome5Solid/tasks/22";
833+
const dataAccess = new qx.ui.basic.Atom().set({
834+
label: title,
835+
icon: iconSrc,
836+
font: "text-14",
837+
padding: 8,
838+
paddingLeft: 10,
839+
gap: 12, // align with the rest of the tabs
840+
cursor: "pointer",
841+
});
842+
dataAccess.addListener("tap", () => osparc.jobs.ActivityOverview.popUpInWindow(resourceData));
843+
this.addWidgetToTabs(dataAccess);
844+
}
845+
},
818846
}
819847
});

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,25 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
4545
HEIGHT: 36,
4646

4747
getSharedWithOptions: function(resourceType) {
48-
if (resourceType === "service") {
49-
resourceType = "app";
50-
}
48+
const resourceAlias = osparc.product.Utils.resourceTypeToAlias(resourceType, {
49+
firstUpperCase: true,
50+
plural: true
51+
});
5152
return [{
5253
id: "show-all",
53-
label: qx.locale.Manager.tr("All") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
54-
firstUpperCase: true,
55-
plural: true
56-
}),
54+
label: qx.locale.Manager.tr("All") + " " + resourceAlias,
5755
icon: "@FontAwesome5Solid/home/20"
5856
}, {
5957
id: "my-resources",
60-
label: qx.locale.Manager.tr("My") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
61-
firstUpperCase: true,
62-
plural: true
63-
}),
58+
label: qx.locale.Manager.tr("My") + " " + resourceAlias,
6459
icon: "@FontAwesome5Solid/user/20"
6560
}, {
6661
id: "shared-with-me",
6762
label: qx.locale.Manager.tr("Shared with Me"),
6863
icon: "@FontAwesome5Solid/users/20"
6964
}, {
7065
id: "shared-with-everyone",
71-
label: qx.locale.Manager.tr("Public") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
72-
firstUpperCase: true,
73-
plural: true
74-
}),
66+
label: qx.locale.Manager.tr("Public") + " " + resourceAlias,
7567
icon: "@FontAwesome5Solid/globe/20"
7668
}];
7769
}

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ qx.Class.define("osparc.data.Job", {
2323

2424
this.set({
2525
projectUuid: jobData["projectUuid"],
26-
state: jobData["state"],
26+
state: jobData["state"] || "UNKNOWN",
2727
submittedAt: jobData["submittedAt"] ? new Date(jobData["submittedAt"]) : null,
2828
startedAt: jobData["startedAt"] ? new Date(jobData["startedAt"]) : null,
2929
endedAt: jobData["endedAt"] ? new Date(jobData["endedAt"]) : null,
3030
info: jobData["info"] || null,
31+
customMetadata: jobData["customMetadata"] || null,
3132
});
3233

3334
if (jobData["info"] && jobData["info"]["project_name"]) {
@@ -76,11 +77,32 @@ qx.Class.define("osparc.data.Job", {
7677

7778
info: {
7879
check: "Object",
79-
nullable: false,
80+
nullable: true,
81+
init: null,
82+
},
83+
84+
customMetadata: {
85+
check: "Object",
86+
nullable: true,
8087
init: null,
8188
},
8289
},
8390

91+
statics: {
92+
STATUS_LABELS: {
93+
"UNKNOWN": "Unknown",
94+
"NOT_STARTED": "Not Started",
95+
"PUBLISHED": "Published",
96+
"PENDING": "Pending",
97+
"RUNNING": "Running",
98+
"SUCCESS": "Success",
99+
"FAILED": "Failed",
100+
"ABORTED": "Aborted",
101+
"WAITING_FOR_RESOURCES": "Waiting for Resources",
102+
"WAITING_FOR_CLUSTER": "Waiting for Cluster",
103+
},
104+
},
105+
84106
members: {
85107
__subJobs: null,
86108

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,25 @@ qx.Class.define("osparc.data.Resources", {
334334
},
335335
}
336336
},
337-
"jobs": {
337+
"runPipeline": {
338+
useCache: false,
339+
endpoints: {
340+
startPipeline: {
341+
method: "POST",
342+
url: statics.API + "/computations/{studyId}:start"
343+
},
344+
stopPipeline: {
345+
method: "POST",
346+
url: statics.API + "/computations/{studyId}:stop"
347+
},
348+
}
349+
},
350+
"jobsActive": {
338351
useCache: false, // handled in osparc.store.Jobs
339352
endpoints: {
340353
getPage: {
341354
method: "GET",
342-
// url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by={orderBy}"
343-
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D"
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"
344356
},
345357
}
346358
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ qx.Class.define("osparc.data.SubJob", {
2929
progress: subJobData["progress"],
3030
startedAt: subJobData["startedAt"] ? new Date(subJobData["startedAt"]) : null,
3131
endedAt: subJobData["endedAt"] ? new Date(subJobData["endedAt"]) : null,
32-
osparcCredits: subJobData["osparcCredits"] || null,
32+
osparcCredits: subJobData["osparcCredits"] === null ? null : -1*parseFloat(subJobData["osparcCredits"]),
3333
image: subJobData["image"] || {},
3434
logDownloadLink: subJobData["logDownloadLink"] || null,
3535
});

services/static-webserver/client/source/class/osparc/desktop/MainPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ qx.Class.define("osparc.desktop.MainPage", {
6969
preloadPromises.push(osparc.store.Tags.getInstance().fetchTags());
7070
preloadPromises.push(osparc.store.Products.getInstance().fetchUiConfig());
7171
preloadPromises.push(osparc.store.PollTasks.getInstance().fetchTasks());
72-
preloadPromises.push(osparc.store.Jobs.getInstance().fetchJobs());
72+
preloadPromises.push(osparc.store.Jobs.getInstance().fetchJobsActive());
7373
Promise.all(preloadPromises)
7474
.then(() => {
7575
const mainStack = this.__createMainStack();

0 commit comments

Comments
 (0)