Skip to content

Commit fffb8f2

Browse files
Merge branch 'master' into fix-api-base-url-generation
2 parents c2d9da2 + d2a092c commit fffb8f2

24 files changed

+306
-139
lines changed

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/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();

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

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -569,64 +569,64 @@ qx.Class.define("osparc.desktop.StudyEditor", {
569569
return;
570570
}
571571

572-
this.getStudy().setPipelineRunning(true);
573572
this.updateStudyDocument()
574573
.then(() => {
575574
this.__requestStartPipeline(this.getStudy().getUuid(), partialPipeline);
576575
})
577576
.catch(() => {
578577
this.getStudyLogger().error(null, "Run failed");
579-
this.getStudy().setPipelineRunning(false);
580578
});
581579
},
582580

583581
__requestStartPipeline: function(studyId, partialPipeline = [], forceRestart = false) {
584-
const url = "/computations/" + encodeURIComponent(studyId) + ":start";
585-
const req = new osparc.io.request.ApiRequest(url, "POST");
586-
req.addListener("success", this.__onPipelineSubmitted, this);
587-
req.addListener("error", () => {
588-
this.getStudyLogger().error(null, "Error submitting pipeline");
589-
this.getStudy().setPipelineRunning(false);
590-
}, this);
591-
req.addListener("fail", async e => {
592-
if (e.getTarget().getStatus() == "409") {
593-
this.getStudyLogger().error(null, "Pipeline is already running");
594-
} else if (e.getTarget().getStatus() == "422") {
595-
this.getStudyLogger().info(null, "The pipeline is up-to-date");
596-
const msg = this.tr("The pipeline is up-to-date. Do you want to re-run it?");
597-
const win = new osparc.ui.window.Confirmation(msg).set({
598-
caption: this.tr("Re-run"),
599-
confirmText: this.tr("Run"),
600-
confirmAction: "create"
601-
});
602-
win.center();
603-
win.open();
604-
win.addListener("close", () => {
605-
if (win.getConfirmed()) {
606-
this.__requestStartPipeline(studyId, partialPipeline, true);
607-
}
608-
}, this);
609-
} else if (e.getTarget().getStatus() == "402") {
610-
const msg = await e.getTarget().getResponse().error.errors[0].message;
611-
osparc.FlashMessenger.logAs(msg, "WARNING");
612-
} else {
613-
this.getStudyLogger().error(null, "Unsuccessful pipeline submission");
614-
}
615-
this.getStudy().setPipelineRunning(false);
616-
}, this);
582+
this.getStudy().setPipelineRunning(true);
617583

618-
const requestData = {
619-
"subgraph": partialPipeline,
620-
"force_restart": forceRestart
621-
};
622-
req.setRequestData(requestData);
623-
req.send();
624584
if (partialPipeline.length) {
625585
this.getStudyLogger().info(null, "Starting partial pipeline");
626586
} else {
627587
this.getStudyLogger().info(null, "Starting pipeline");
628588
}
629589

590+
const params = {
591+
url: {
592+
"studyId": studyId
593+
},
594+
data: {
595+
"subgraph": partialPipeline,
596+
"force_restart": forceRestart,
597+
}
598+
};
599+
osparc.data.Resources.fetch("runPipeline", "startPipeline", params)
600+
.then(() => this.__onPipelineSubmitted())
601+
.catch(err => {
602+
let msg = err.message;
603+
const errStatus = err.status;
604+
if (errStatus == "409") {
605+
this.getStudyLogger().error(null, "Pipeline is already running");
606+
} else if (errStatus == "422") {
607+
this.getStudyLogger().info(null, "The pipeline is up-to-date");
608+
msg = this.tr("The pipeline is up-to-date. Do you want to re-run it?");
609+
const win = new osparc.ui.window.Confirmation(msg).set({
610+
caption: this.tr("Re-run"),
611+
confirmText: this.tr("Run"),
612+
confirmAction: "create"
613+
});
614+
win.center();
615+
win.open();
616+
win.addListener("close", () => {
617+
if (win.getConfirmed()) {
618+
this.__requestStartPipeline(studyId, partialPipeline, true);
619+
}
620+
}, this);
621+
} else if (err.status == "402") {
622+
osparc.FlashMessenger.logAs(msg, "WARNING");
623+
} else {
624+
osparc.FlashMessenger.logAs(msg, "WARNING");
625+
this.getStudyLogger().error(null, "Unsuccessful pipeline submission");
626+
}
627+
this.getStudy().setPipelineRunning(false);
628+
});
629+
630630
return true;
631631
},
632632

@@ -662,19 +662,20 @@ qx.Class.define("osparc.desktop.StudyEditor", {
662662
return;
663663
}
664664

665-
this.__requestStopPipeline(this.getStudy().getUuid());
665+
this.__requestStopPipeline();
666666
},
667667

668-
__requestStopPipeline: function(studyId) {
669-
const url = "/computations/" + encodeURIComponent(studyId) + ":stop";
670-
const req = new osparc.io.request.ApiRequest(url, "POST");
671-
req.addListener("success", () => this.getStudyLogger().debug(null, "Pipeline aborting"), this);
672-
req.addListener("error", () => this.getStudyLogger().error(null, "Error stopping pipeline"), this);
673-
req.addListener("fail", () => this.getStudyLogger().error(null, "Failed stopping pipeline"), this);
674-
req.send();
675-
668+
__requestStopPipeline: function() {
676669
this.getStudyLogger().info(null, "Stopping pipeline");
677-
return true;
670+
671+
const params = {
672+
url: {
673+
"studyId": this.getStudy().getUuid()
674+
},
675+
};
676+
osparc.data.Resources.fetch("runPipeline", "stopPipeline", params)
677+
.then(() => this.getStudyLogger().debug(null, "Stopping pipeline"), this)
678+
.catch(() => this.getStudyLogger().error(null, "Error stopping pipeline"), this);
678679
},
679680
// ------------------ START/STOP PIPELINE ------------------
680681

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ qx.Class.define("osparc.jobs.ActivityCenterWindow", {
2424
this.set({
2525
layout: new qx.ui.layout.VBox(),
2626
modal: true,
27-
width: 1100,
28-
height: 500,
27+
width: this.self().WIDTH,
28+
height: this.self().HEIGHT,
2929
showMaximize: false,
3030
showMinimize: false,
3131
});
@@ -34,6 +34,9 @@ qx.Class.define("osparc.jobs.ActivityCenterWindow", {
3434
},
3535

3636
statics: {
37+
WIDTH: 1000,
38+
HEIGHT: 500,
39+
3740
openWindow: function() {
3841
const runsWindow = new osparc.jobs.ActivityCenterWindow();
3942
runsWindow.center();

0 commit comments

Comments
 (0)