diff --git a/services/web/client/source/class/osparc/component/workbench/SvgWidget.js b/services/web/client/source/class/osparc/component/workbench/SvgWidget.js index 12dc21ee9cb..964cfd7b4fa 100644 --- a/services/web/client/source/class/osparc/component/workbench/SvgWidget.js +++ b/services/web/client/source/class/osparc/component/workbench/SvgWidget.js @@ -46,12 +46,20 @@ qx.Class.define("osparc.component.workbench.SvgWidget", { this.__svgWrapper = new osparc.wrapper.Svg(); this.__svgWrapper.addListener(("svgLibReady"), () => { this.__canvas = this.__svgWrapper.createEmptyCanvas(svgLayerId); + this.setReady(true); this.fireDataEvent("SvgWidgetReady", true); }); this.__svgWrapper.init(); }); }, + properties: { + ready: { + check: "Boolean", + init: false + } + }, + events: { "SvgWidgetReady": "qx.event.type.Data" }, diff --git a/services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js b/services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js index d33152c5203..70fc3cd8488 100644 --- a/services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js +++ b/services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js @@ -78,16 +78,6 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", { this.__desktopCanvas.add(this.__startHint); this.__svgWidgetLinks = new osparc.component.workbench.SvgWidget("SvgWidget_Links"); - // this gets fired once the widget has appeared and the library has been loaded - // due to the qx rendering, this will always happen after setup, so we are - // sure to catch this event - this.__svgWidgetLinks.addListenerOnce("SvgWidgetReady", () => { - // Will be called only the first time Svg lib is loaded - this.loadModel(workbench); - const study = osparc.store.Store.getInstance().getCurrentStudy(); - this.__nodeSelected(study.getUuid()); - }); - this.__desktop.add(this.__svgWidgetLinks, { left: 0, top: 0, @@ -761,6 +751,16 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", { }, loadModel: function(model) { + if (this.__svgWidgetLinks.getReady()) { + this.__loadModel(model); + } else { + this.__svgWidgetLinks.addListenerOnce("SvgWidgetReady", () => { + this.__loadModel(model); + }, this); + } + }, + + __loadModel: function(model) { this.clearAll(); this.resetSelectedNodes(); this.__currentModel = model; diff --git a/services/web/client/source/class/osparc/data/model/Node.js b/services/web/client/source/class/osparc/data/model/Node.js index ce93a8f9a4d..3d01dbe3469 100644 --- a/services/web/client/source/class/osparc/data/model/Node.js +++ b/services/web/client/source/class/osparc/data/model/Node.js @@ -368,6 +368,10 @@ qx.Class.define("osparc.data.model.Node", { if (this.__outputWidget) { this.__outputWidget.populatePortsData(); } + + if (this.isDynamic()) { + this.__showLoadingIFrame(); + } }, giveUniqueName: function() { @@ -775,8 +779,6 @@ qx.Class.define("osparc.data.model.Node", { }, this); restartBtn.setEnabled(false); this.setRestartIFrameButton(restartBtn); - - this.__showLoadingIFrame(); } }, diff --git a/services/web/client/source/class/osparc/desktop/StudyEditor.js b/services/web/client/source/class/osparc/desktop/StudyEditor.js index 5bb6ab4c7b3..4798e4bbebf 100644 --- a/services/web/client/source/class/osparc/desktop/StudyEditor.js +++ b/services/web/client/source/class/osparc/desktop/StudyEditor.js @@ -74,9 +74,28 @@ qx.Class.define("osparc.desktop.StudyEditor", { osparc.store.Store.getInstance().setCurrentStudy(study); study.buildWorkbench(); study.openStudy(); - this.__initDefault(); + this.__initViews(); this.__connectEvents(); this.__startAutoSaveTimer(); + + this.__openOneNode(); + }, + + __openOneNode: function() { + const validNodeIds = []; + const allNodes = this.getStudy().getWorkbench().getNodes(true); + Object.values(allNodes).forEach(node => { + if (!node.isFilePicker()) { + validNodeIds.push(node.getNodeId()); + } + }); + + const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance(); + if (validNodeIds.length === 1 && preferencesSettings.getAutoOpenNode()) { + this.nodeSelected(validNodeIds[0]); + } else { + this.nodeSelected(this.getStudy().getUuid()); + } }, /** @@ -87,7 +106,7 @@ qx.Class.define("osparc.desktop.StudyEditor", { this.__stopAutoSaveTimer(); }, - __initDefault: function() { + __initViews: function() { const study = this.getStudy(); const nodesTree = this.__nodesTree = new osparc.component.widget.NodesTree(study); @@ -112,7 +131,6 @@ qx.Class.define("osparc.desktop.StudyEditor", { const edgeId = e.getData(); this.__removeEdge(edgeId); }, this); - this.showInMainView(workbenchUI, study.getUuid()); this.__nodeView = new osparc.component.node.NodeView().set({ minHeight: 200 diff --git a/services/web/client/source/class/osparc/desktop/preferences/Preferences.js b/services/web/client/source/class/osparc/desktop/preferences/Preferences.js index fb43a959af6..210f8fbbadc 100644 --- a/services/web/client/source/class/osparc/desktop/preferences/Preferences.js +++ b/services/web/client/source/class/osparc/desktop/preferences/Preferences.js @@ -33,6 +33,13 @@ qx.Class.define("osparc.desktop.preferences.Preferences", { init: false, check: "Boolean", event: "changeAutoConnectPorts" + }, + + autoOpenNode: { + nullable: false, + init: true, + check: "Boolean", + event: "changeAutoOpenNode" } } }); diff --git a/services/web/client/source/class/osparc/desktop/preferences/pages/ExperimentalPage.js b/services/web/client/source/class/osparc/desktop/preferences/pages/ExperimentalPage.js index 4158a836935..8d5ac5682a9 100644 --- a/services/web/client/source/class/osparc/desktop/preferences/pages/ExperimentalPage.js +++ b/services/web/client/source/class/osparc/desktop/preferences/pages/ExperimentalPage.js @@ -105,12 +105,16 @@ qx.Class.define("osparc.desktop.preferences.pages.ExperimentalPage", { const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance(); - const cbAutoPorts = new qx.ui.form.CheckBox("Auto Connect Ports"); + const cbAutoPorts = new qx.ui.form.CheckBox(this.tr("Connect ports automatically")); preferencesSettings.bind("autoConnectPorts", cbAutoPorts, "value"); cbAutoPorts.bind("value", preferencesSettings, "autoConnectPorts"); - box.add(cbAutoPorts); + const cbAutoOpenNode = new qx.ui.form.CheckBox(this.tr("Open node automatically when opening studies with a single node")); + preferencesSettings.bind("autoOpenNode", cbAutoOpenNode, "value"); + cbAutoOpenNode.bind("value", preferencesSettings, "autoOpenNode"); + box.add(cbAutoOpenNode); + return box; } }