Skip to content

Commit 5ea6dba

Browse files
committed
more refactoring
1 parent 7e4059d commit 5ea6dba

File tree

3 files changed

+26
-39
lines changed

3 files changed

+26
-39
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,29 @@ 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 loadingPage = node.getLoadingPage();
67+
const iFrame = node.getIFrame();
68+
const src = iFrame.getSource();
69+
const iFrameView = (src === null || src === "about:blank") ? loadingPage : iFrame;
70+
iframeLayout.add(iFrameView, {
71+
flex: 1
72+
});
73+
}
74+
},
75+
76+
listenToIframeStateChanges: function(node, iframeLayout) {
77+
if (node && node.getIFrame()) {
78+
const iFrame = node.getIFrame();
79+
node.getIframeHandler().addListener("iframeStateChanged", () => this.__handleIframeStateChange(node, iframeLayout), this);
80+
iFrame.addListener("load", () => this.__handleIframeStateChange(node, iframeLayout));
81+
this.__handleIframeStateChange(node, iframeLayout);
82+
}
83+
},
6284
},
6385

6486
events: {
@@ -756,9 +778,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
756778
widget.addListener("restore", () => this.setMaximized(false), this);
757779
}
758780
});
759-
node.getIframeHandler().addListener("iframeStateChanged", () => this.__iFrameStateChanged(node), this);
760-
iFrame.addListener("load", () => this.__iFrameStateChanged(node), this);
761-
this.__iFrameStateChanged(node);
781+
osparc.desktop.WorkbenchView.listenToIframeStateChanges(node, this.__iframePage);
762782
} else {
763783
// This will keep what comes after at the bottom
764784
this.__iframePage.add(new qx.ui.core.Spacer(), {
@@ -767,10 +787,6 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
767787
}
768788
},
769789

770-
__iFrameStateChanged: function(node) {
771-
osparc.node.slideshow.NodeView.handleIframeStateChange(node, this.__iframePage);
772-
},
773-
774790
__populateSecondaryColumn: function(node) {
775791
[
776792
this.__studyOptionsPage,

services/static-webserver/client/source/class/osparc/node/slideshow/NodeView.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ qx.Class.define("osparc.node.slideshow.NodeView", {
4040
LOGGER_HEIGHT: 28,
4141
},
4242

43-
statics: {
44-
handleIframeStateChange: function(node, iframeLayout) {
45-
iframeLayout.removeAll();
46-
if (node && node.getIFrame()) {
47-
const loadingPage = node.getLoadingPage();
48-
const iFrame = node.getIFrame();
49-
const src = iFrame.getSource();
50-
const iFrameView = (src === null || src === "about:blank") ? loadingPage : iFrame;
51-
iframeLayout.add(iFrameView, {
52-
flex: 1
53-
});
54-
}
55-
},
56-
},
57-
5843
members: {
5944
__loggerPanel: null,
6045

@@ -91,10 +76,7 @@ qx.Class.define("osparc.node.slideshow.NodeView", {
9176
const loadingPage = this.getNode().getLoadingPage();
9277
const iFrame = this.getNode().getIFrame();
9378
if (loadingPage && iFrame) {
94-
const node = this.getNode();
95-
node.getIframeHandler().addListener("iframeStateChanged", () => this.__iFrameStateChanged(), this);
96-
iFrame.addListener("load", () => this.__iFrameStateChanged());
97-
this.__iFrameStateChanged();
79+
osparc.desktop.WorkbenchView.listenToIframeStateChanges(this.getNode(), this._iFrameLayout);
9880
} else {
9981
// This will keep what comes after at the bottom
10082
this._iFrameLayout.add(new qx.ui.core.Spacer(), {
@@ -147,9 +129,5 @@ qx.Class.define("osparc.node.slideshow.NodeView", {
147129
_applyNode: function(node) {
148130
this.base(arguments, node);
149131
},
150-
151-
__iFrameStateChanged: function() {
152-
osparc.node.slideshow.NodeView.handleIframeStateChange(this.getNode(), this._iFrameLayout);
153-
}
154132
}
155133
});

services/static-webserver/client/source/class/osparc/viewer/NodeViewer.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,13 @@ qx.Class.define("osparc.viewer.NodeViewer", {
7878
const iframeHandler = node.getIframeHandler();
7979
if (iframeHandler) {
8080
iframeHandler.checkState();
81-
iframeHandler.addListener("iframeStateChanged", () => this.__iFrameStateChanged(), this);
82-
iframeHandler.getIFrame().addListener("load", () => this.__iFrameStateChanged(), this);
83-
this.__iFrameStateChanged();
84-
81+
osparc.desktop.WorkbenchView.listenToIframeStateChanges(node, this);
8582
this.__attachSocketEventHandlers();
8683
} else {
8784
console.error(node.getLabel() + " iframe handler not ready");
8885
}
8986
},
9087

91-
__iFrameStateChanged: function() {
92-
osparc.node.slideshow.NodeView.handleIframeStateChange(this.getNode(), this);
93-
},
94-
9588
__attachSocketEventHandlers: function() {
9689
this.__listenToNodeUpdated();
9790
this.__listenToNodeProgress();

0 commit comments

Comments
 (0)