Skip to content

Commit 38f9c66

Browse files
authored
Studies of one node open directly in fullscreen view instead displaying the pipeline (#1316)
* Studies of one node open directly in that node * autoOpenNode added to preferences
1 parent 82e8778 commit 38f9c66

File tree

6 files changed

+56
-17
lines changed

6 files changed

+56
-17
lines changed

services/web/client/source/class/osparc/component/workbench/SvgWidget.js

+8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ qx.Class.define("osparc.component.workbench.SvgWidget", {
4646
this.__svgWrapper = new osparc.wrapper.Svg();
4747
this.__svgWrapper.addListener(("svgLibReady"), () => {
4848
this.__canvas = this.__svgWrapper.createEmptyCanvas(svgLayerId);
49+
this.setReady(true);
4950
this.fireDataEvent("SvgWidgetReady", true);
5051
});
5152
this.__svgWrapper.init();
5253
});
5354
},
5455

56+
properties: {
57+
ready: {
58+
check: "Boolean",
59+
init: false
60+
}
61+
},
62+
5563
events: {
5664
"SvgWidgetReady": "qx.event.type.Data"
5765
},

services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
7878
this.__desktopCanvas.add(this.__startHint);
7979

8080
this.__svgWidgetLinks = new osparc.component.workbench.SvgWidget("SvgWidget_Links");
81-
// this gets fired once the widget has appeared and the library has been loaded
82-
// due to the qx rendering, this will always happen after setup, so we are
83-
// sure to catch this event
84-
this.__svgWidgetLinks.addListenerOnce("SvgWidgetReady", () => {
85-
// Will be called only the first time Svg lib is loaded
86-
this.loadModel(workbench);
87-
const study = osparc.store.Store.getInstance().getCurrentStudy();
88-
this.__nodeSelected(study.getUuid());
89-
});
90-
9181
this.__desktop.add(this.__svgWidgetLinks, {
9282
left: 0,
9383
top: 0,
@@ -761,6 +751,16 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
761751
},
762752

763753
loadModel: function(model) {
754+
if (this.__svgWidgetLinks.getReady()) {
755+
this.__loadModel(model);
756+
} else {
757+
this.__svgWidgetLinks.addListenerOnce("SvgWidgetReady", () => {
758+
this.__loadModel(model);
759+
}, this);
760+
}
761+
},
762+
763+
__loadModel: function(model) {
764764
this.clearAll();
765765
this.resetSelectedNodes();
766766
this.__currentModel = model;

services/web/client/source/class/osparc/data/model/Node.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ qx.Class.define("osparc.data.model.Node", {
368368
if (this.__outputWidget) {
369369
this.__outputWidget.populatePortsData();
370370
}
371+
372+
if (this.isDynamic()) {
373+
this.__showLoadingIFrame();
374+
}
371375
},
372376

373377
giveUniqueName: function() {
@@ -775,8 +779,6 @@ qx.Class.define("osparc.data.model.Node", {
775779
}, this);
776780
restartBtn.setEnabled(false);
777781
this.setRestartIFrameButton(restartBtn);
778-
779-
this.__showLoadingIFrame();
780782
}
781783
},
782784

services/web/client/source/class/osparc/desktop/StudyEditor.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,28 @@ qx.Class.define("osparc.desktop.StudyEditor", {
7474
osparc.store.Store.getInstance().setCurrentStudy(study);
7575
study.buildWorkbench();
7676
study.openStudy();
77-
this.__initDefault();
77+
this.__initViews();
7878
this.__connectEvents();
7979
this.__startAutoSaveTimer();
80+
81+
this.__openOneNode();
82+
},
83+
84+
__openOneNode: function() {
85+
const validNodeIds = [];
86+
const allNodes = this.getStudy().getWorkbench().getNodes(true);
87+
Object.values(allNodes).forEach(node => {
88+
if (!node.isFilePicker()) {
89+
validNodeIds.push(node.getNodeId());
90+
}
91+
});
92+
93+
const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance();
94+
if (validNodeIds.length === 1 && preferencesSettings.getAutoOpenNode()) {
95+
this.nodeSelected(validNodeIds[0]);
96+
} else {
97+
this.nodeSelected(this.getStudy().getUuid());
98+
}
8099
},
81100

82101
/**
@@ -87,7 +106,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
87106
this.__stopAutoSaveTimer();
88107
},
89108

90-
__initDefault: function() {
109+
__initViews: function() {
91110
const study = this.getStudy();
92111

93112
const nodesTree = this.__nodesTree = new osparc.component.widget.NodesTree(study);
@@ -112,7 +131,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
112131
const edgeId = e.getData();
113132
this.__removeEdge(edgeId);
114133
}, this);
115-
this.showInMainView(workbenchUI, study.getUuid());
116134

117135
this.__nodeView = new osparc.component.node.NodeView().set({
118136
minHeight: 200

services/web/client/source/class/osparc/desktop/preferences/Preferences.js

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ qx.Class.define("osparc.desktop.preferences.Preferences", {
3333
init: false,
3434
check: "Boolean",
3535
event: "changeAutoConnectPorts"
36+
},
37+
38+
autoOpenNode: {
39+
nullable: false,
40+
init: true,
41+
check: "Boolean",
42+
event: "changeAutoOpenNode"
3643
}
3744
}
3845
});

services/web/client/source/class/osparc/desktop/preferences/pages/ExperimentalPage.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ qx.Class.define("osparc.desktop.preferences.pages.ExperimentalPage", {
105105

106106
const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance();
107107

108-
const cbAutoPorts = new qx.ui.form.CheckBox("Auto Connect Ports");
108+
const cbAutoPorts = new qx.ui.form.CheckBox(this.tr("Connect ports automatically"));
109109
preferencesSettings.bind("autoConnectPorts", cbAutoPorts, "value");
110110
cbAutoPorts.bind("value", preferencesSettings, "autoConnectPorts");
111-
112111
box.add(cbAutoPorts);
113112

113+
const cbAutoOpenNode = new qx.ui.form.CheckBox(this.tr("Open node automatically when opening studies with a single node"));
114+
preferencesSettings.bind("autoOpenNode", cbAutoOpenNode, "value");
115+
cbAutoOpenNode.bind("value", preferencesSettings, "autoOpenNode");
116+
box.add(cbAutoOpenNode);
117+
114118
return box;
115119
}
116120
}

0 commit comments

Comments
 (0)