Skip to content

Commit ef25275

Browse files
committed
Merge branch 'feature/share-functions' of github.com:odeimaiz/osparc-simcore into feature/share-functions
2 parents 948de8b + f04483f commit ef25275

File tree

16 files changed

+464
-176
lines changed

16 files changed

+464
-176
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
100100
paddingBottom: 5,
101101
allowGrowX: false
102102
});
103-
control.getChildControl("icon").set(this.getThumbnailProps(32));
103+
control.getChildControl("icon").set(osparc.utils.Utils.getThumbnailProps(32));
104104
control.getChildControl("label").set({
105105
rich: true,
106106
wrap: true

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

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
3030
});
3131

3232
this.__initLoadingPage();
33+
this.__initLockedPage();
3334
this.__initIFrame();
3435
},
3536

@@ -44,7 +45,9 @@ qx.Class.define("osparc.data.model.IframeHandler", {
4445
node: {
4546
check: "osparc.data.model.Node",
4647
init: null,
47-
nullable: false
48+
nullable: false,
49+
event: "changeNode",
50+
apply: "__applyNode",
4851
},
4952

5053
loadingPage: {
@@ -53,6 +56,12 @@ qx.Class.define("osparc.data.model.IframeHandler", {
5356
nullable: true
5457
},
5558

59+
lockedPage: {
60+
check: "osparc.ui.message.NodeLockedPage",
61+
init: null,
62+
nullable: true
63+
},
64+
5665
iFrame: {
5766
check: "osparc.widget.PersistentIframe",
5867
init: null,
@@ -61,7 +70,19 @@ qx.Class.define("osparc.data.model.IframeHandler", {
6170
},
6271

6372
events: {
64-
"iframeChanged": "qx.event.type.Event"
73+
"iframeStateChanged": "qx.event.type.Event"
74+
},
75+
76+
statics: {
77+
evalShowToolbar: function(loadingPage, study) {
78+
if (osparc.product.Utils.isProduct("s4llite")) {
79+
loadingPage.setShowToolbar(false);
80+
} else {
81+
study.getUi().bind("mode", loadingPage, "showToolbar", {
82+
converter: mode => mode !== "standalone"
83+
});
84+
}
85+
},
6586
},
6687

6788
members: {
@@ -89,16 +110,14 @@ qx.Class.define("osparc.data.model.IframeHandler", {
89110
}
90111
},
91112

113+
__applyNode: function(node) {
114+
node.getStatus().getLockState().addListener("changeLocked", () => this.fireEvent("iframeStateChanged"), this);
115+
},
116+
92117
__initIFrame: function() {
93118
const iframe = new osparc.widget.PersistentIframe();
94119
osparc.utils.Utils.setIdToWidget(iframe.getIframe(), "iframe_"+this.getNode().getNodeId());
95-
if (osparc.product.Utils.isProduct("s4llite")) {
96-
iframe.setShowToolbar(false);
97-
} else {
98-
this.getStudy().getUi().bind("mode", iframe, "showToolbar", {
99-
converter: mode => mode !== "standalone"
100-
});
101-
}
120+
this.self().evalShowToolbar(iframe, this.getStudy());
102121
iframe.addListener("restart", () => this.restartIFrame(), this);
103122
iframe.getDiskUsageIndicator().setCurrentNode(this.getNode())
104123
this.setIFrame(iframe);
@@ -108,13 +127,8 @@ qx.Class.define("osparc.data.model.IframeHandler", {
108127
const loadingPage = new osparc.ui.message.Loading().set({
109128
header: this.__getLoadingPageHeader()
110129
});
111-
if (osparc.product.Utils.isProduct("s4llite")) {
112-
loadingPage.setShowToolbar(false);
113-
} else {
114-
this.getStudy().getUi().bind("mode", loadingPage, "showToolbar", {
115-
converter: mode => mode !== "standalone"
116-
});
117-
}
130+
131+
this.self().evalShowToolbar(loadingPage, this.getStudy());
118132

119133
const node = this.getNode();
120134
const thumbnail = node.getMetadata()["thumbnail"];
@@ -146,6 +160,13 @@ qx.Class.define("osparc.data.model.IframeHandler", {
146160
return statusText + " " + node.getLabel() + " <span style='font-size: 16px;font-weight: normal;'><sub>v" + versionDisplay + "</sub></span>";
147161
},
148162

163+
__initLockedPage: function() {
164+
const lockedPage = new osparc.ui.message.NodeLockedPage();
165+
this.self().evalShowToolbar(lockedPage, this.getStudy());
166+
this.bind("node", lockedPage, "node");
167+
this.setLockedPage(lockedPage);
168+
},
169+
149170
__nodeState: function() {
150171
// Check if study is still there
151172
if (this.getStudy() === null || this.__stopRequestingStatus === true) {
@@ -381,7 +402,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
381402
if (this.getIFrame()) {
382403
this.getIFrame().resetSource();
383404
}
384-
this.fireEvent("iframeChanged");
405+
this.fireEvent("iframeStateChanged");
385406
}
386407
},
387408

@@ -418,7 +439,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
418439

419440
// fire event to force switching to iframe's content:
420441
// it is required in those cases where the native 'load' event isn't triggered (voila)
421-
this.fireEvent("iframeChanged");
442+
this.fireEvent("iframeStateChanged");
422443
}
423444
}
424445
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ qx.Class.define("osparc.data.model.Node", {
528528
this.setLabel(nodeData.label);
529529
}
530530
this.__populateInputOutputData(nodeData);
531-
this.populateStates(nodeData);
531+
this.populateProgress(nodeData);
532+
this.populateState(nodeData);
532533
if (nodeData.bootOptions) {
533534
this.setBootOptions(nodeData.bootOptions);
534535
}
@@ -570,7 +571,7 @@ qx.Class.define("osparc.data.model.Node", {
570571
this.setInputsRequired(nodeData.inputsRequired || []);
571572
},
572573

573-
populateStates: function(nodeData) {
574+
populateProgress: function(nodeData) {
574575
if ("progress" in nodeData) {
575576
const progress = Number.parseInt(nodeData["progress"]);
576577
const oldProgress = this.getStatus().getProgress();
@@ -581,6 +582,9 @@ qx.Class.define("osparc.data.model.Node", {
581582
this.getStatus().setProgress(progress);
582583
}
583584
}
585+
},
586+
587+
populateState: function(nodeData) {
584588
if ("state" in nodeData) {
585589
this.getStatus().setState(nodeData.state);
586590
}
@@ -608,6 +612,10 @@ qx.Class.define("osparc.data.model.Node", {
608612
return this.getIframeHandler() ? this.getIframeHandler().getLoadingPage() : null;
609613
},
610614

615+
getLockedPage: function() {
616+
return this.getIframeHandler() ? this.getIframeHandler().getLockedPage() : null;
617+
},
618+
611619
__applyPropsForm: function(propsForm) {
612620
osparc.utils.Utils.setIdToWidget(propsForm, "settingsForm_" + this.getNodeId());
613621
},
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.model.NodeLockState", {
19+
extend: qx.core.Object,
20+
21+
construct: function() {
22+
this.base(arguments);
23+
24+
this.initCurrentUserGroupIds();
25+
this.initLocked();
26+
this.initStatus();
27+
},
28+
29+
properties: {
30+
currentUserGroupIds: {
31+
check: "Array",
32+
init: [],
33+
nullable: false,
34+
event: "changeCurrentUserGroupIds",
35+
},
36+
37+
locked: {
38+
check: "Boolean",
39+
init: false,
40+
nullable: false,
41+
event: "changeLocked",
42+
},
43+
44+
status: {
45+
// check: ["NOT_STARTED", "STARTED", "OPENED"],
46+
check: "String",
47+
init: "NOT_STARTED",
48+
nullable: false,
49+
event: "changeStatus",
50+
}
51+
},
52+
53+
members: {
54+
stateReceived: function(state) {
55+
if (state) {
56+
this.set({
57+
currentUserGroupIds: "current_user_groupids" in state ? state["current_user_groupids"] : [],
58+
locked: "locked" in state ? state["locked"] : false,
59+
status: "status" in state ? state["status"] : "NOT_STARTED",
60+
});
61+
}
62+
},
63+
64+
isLockedBySomeoneElse: function() {
65+
if (this.isLocked()) {
66+
const currentUserGroupIds = this.getCurrentUserGroupIds();
67+
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
68+
return !currentUserGroupIds.includes(myGroupId);
69+
}
70+
return false;
71+
}
72+
}
73+
});

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ qx.Class.define("osparc.data.model.NodeStatus", {
9393
hasOutputs: {
9494
check: "Boolean",
9595
init: false
96+
},
97+
98+
lockState: {
99+
check: "osparc.data.model.NodeLockState",
100+
nullable: true,
101+
init: null,
102+
event: "changeLockState"
96103
}
97104
},
98105

@@ -139,17 +146,20 @@ qx.Class.define("osparc.data.model.NodeStatus", {
139146

140147
members: {
141148
__applyNode: function(node) {
142-
const addNodeProgressSequence = () => {
149+
const initNode = () => {
143150
if (node.isDynamic()) {
144151
const progressSequence = new osparc.data.model.NodeProgressSequence();
145152
this.setProgressSequence(progressSequence);
146153
}
154+
155+
const lockState = new osparc.data.model.NodeLockState();
156+
this.setLockState(lockState);
147157
};
148158

149159
if (node.getMetadata()) {
150-
addNodeProgressSequence();
160+
initNode();
151161
} else {
152-
node.addListenerOnce("changeMetadata", () => addNodeProgressSequence(), this);
162+
node.addListenerOnce("changeMetadata", () => initNode(), this);
153163
}
154164
},
155165

@@ -217,6 +227,9 @@ qx.Class.define("osparc.data.model.NodeStatus", {
217227
this.setModified(null);
218228
}
219229
}
230+
if ("lock_state" in state) {
231+
this.getLockState().stateReceived(state.lock_state);
232+
}
220233
},
221234

222235
serialize: function() {

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,8 @@ qx.Class.define("osparc.data.model.Study", {
576576
if (node) {
577577
if (nodeData && !osparc.data.model.Node.isFrontend(node.getMetadata())) {
578578
node.setOutputData(nodeData.outputs);
579-
if ("progress" in nodeData) {
580-
const progress = Number.parseInt(nodeData["progress"]);
581-
node.getStatus().setProgress(progress);
582-
}
583-
node.populateStates(nodeData);
579+
node.populateProgress(nodeData);
580+
node.populateState(nodeData);
584581
}
585582
if ("errors" in nodeUpdatedData) {
586583
const errors = nodeUpdatedData["errors"];

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

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,33 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
5858
const win = osparc.widget.StudyDataManager.popUpInWindow(node.getStudy().serialize(), node.getNodeId(), node.getLabel());
5959
const closeBtn = win.getChildControl("close-button");
6060
osparc.utils.Utils.setIdToWidget(closeBtn, "nodeDataManagerCloseBtn");
61-
}
61+
},
62+
63+
__handleIframeStateChange: function(node, iframeLayout) {
64+
iframeLayout.removeAll();
65+
if (node && node.getIFrame()) {
66+
const iFrame = node.getIFrame();
67+
const src = iFrame.getSource();
68+
let showPage = iFrame;
69+
if (node.getStatus().getLockState().isLockedBySomeoneElse()) {
70+
showPage = node.getLockedPage();
71+
} else if (src === null || src === "about:blank") {
72+
showPage = node.getLoadingPage();
73+
}
74+
iframeLayout.add(showPage, {
75+
flex: 1
76+
});
77+
}
78+
},
79+
80+
listenToIframeStateChanges: function(node, iframeLayout) {
81+
if (node && node.getIFrame()) {
82+
const iFrame = node.getIFrame();
83+
node.getIframeHandler().addListener("iframeStateChanged", () => this.__handleIframeStateChange(node, iframeLayout), this);
84+
iFrame.addListener("load", () => this.__handleIframeStateChange(node, iframeLayout));
85+
this.__handleIframeStateChange(node, iframeLayout);
86+
}
87+
},
6288
},
6389

6490
events: {
@@ -357,6 +383,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
357383
alignX: "center",
358384
marginLeft: 10
359385
});
386+
// do not allow modifying the pipeline
360387
this.getStudy().bind("pipelineRunning", addNewNodeBtn, "enabled", {
361388
converter: running => !running
362389
});
@@ -755,9 +782,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
755782
widget.addListener("restore", () => this.setMaximized(false), this);
756783
}
757784
});
758-
node.getIframeHandler().addListener("iframeChanged", () => this.__iFrameChanged(node), this);
759-
iFrame.addListener("load", () => this.__iFrameChanged(node), this);
760-
this.__iFrameChanged(node);
785+
osparc.desktop.WorkbenchView.listenToIframeStateChanges(node, this.__iframePage);
761786
} else {
762787
// This will keep what comes after at the bottom
763788
this.__iframePage.add(new qx.ui.core.Spacer(), {
@@ -766,20 +791,6 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
766791
}
767792
},
768793

769-
__iFrameChanged: function(node) {
770-
this.__iframePage.removeAll();
771-
772-
if (node && node.getIFrame()) {
773-
const loadingPage = node.getLoadingPage();
774-
const iFrame = node.getIFrame();
775-
const src = iFrame.getSource();
776-
const iFrameView = (src === null || src === "about:blank") ? loadingPage : iFrame;
777-
this.__iframePage.add(iFrameView, {
778-
flex: 1
779-
});
780-
}
781-
},
782-
783794
__populateSecondaryColumn: function(node) {
784795
[
785796
this.__studyOptionsPage,
@@ -803,8 +814,12 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
803814
this.__populateSecondaryColumnNode(node);
804815
}
805816

806-
if (node instanceof osparc.data.model.Node) {
807-
node.getStudy().bind("pipelineRunning", this.__serviceOptionsPage, "enabled", {
817+
if (
818+
node instanceof osparc.data.model.Node &&
819+
node.isComputational() &&
820+
node.getPropsForm()
821+
) {
822+
node.getStudy().bind("pipelineRunning", node.getPropsForm(), "enabled", {
808823
converter: pipelineRunning => !pipelineRunning
809824
});
810825
}

0 commit comments

Comments
 (0)