Skip to content

Commit 3912e63

Browse files
committed
refactor
1 parent 7f1280d commit 3912e63

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,13 @@ qx.Class.define("osparc.data.model.IframeHandler", {
119119
});
120120
loadingPage.addExtraWidget(sequenceWidget);
121121

122-
nodeStatus.addListener("changeInteractive", () => {
123-
loadingPage.setHeader(this.__getLoadingPageHeader());
124-
const status = nodeStatus.getInteractive();
125-
if (["idle", "failed"].includes(status)) {
126-
const startButton = new qx.ui.form.Button().set({
127-
label: this.tr("Start"),
128-
icon: "@FontAwesome5Solid/play/18",
129-
font: "text-18",
130-
allowGrowX: false,
131-
height: 32
132-
});
133-
startButton.addListener("execute", () => node.requestStartNode());
134-
loadingPage.addWidgetToMessages(startButton);
135-
} else {
136-
loadingPage.setMessages([]);
137-
}
138-
}, this);
139122
this.setLoadingPage(loadingPage);
140123
},
141124

142125
__getLoadingPageHeader: function() {
143126
const node = this.getNode();
144-
let statusText = this.tr("Starting");
145127
const status = node.getStatus().getInteractive();
146-
if (status) {
147-
statusText = status.charAt(0).toUpperCase() + status.slice(1);
148-
}
128+
const statusText = status ? (status.charAt(0).toUpperCase() + status.slice(1)) : this.tr("Starting");
149129
const metadata = node.getMetaData();
150130
const versionDisplay = osparc.service.Utils.extractVersionDisplay(metadata);
151131
return statusText + " " + node.getLabel() + " <span style='font-size: 16px;font-weight: normal;'><sub>v" + versionDisplay + "</sub></span>";
@@ -325,10 +305,25 @@ qx.Class.define("osparc.data.model.IframeHandler", {
325305
node.getStatus().setInteractive("ready");
326306
},
327307

328-
__statusInteractiveChanged: function(newStatus, oldStatus) {
308+
__statusInteractiveChanged: function(status, oldStatus) {
329309
const node = this.getNode();
330310

331-
if (newStatus === "ready") {
311+
const loadingPage = node.getLoadingPage();
312+
loadingPage.setHeader(this.__getLoadingPageHeader());
313+
loadingPage.clearMessages();
314+
if (["idle", "failed"].includes(status)) {
315+
const startButton = new qx.ui.form.Button().set({
316+
label: this.tr("Start"),
317+
icon: "@FontAwesome5Solid/play/18",
318+
font: "text-18",
319+
allowGrowX: false,
320+
height: 32
321+
});
322+
startButton.addListener("execute", () => node.requestStartNode());
323+
loadingPage.addWidgetToMessages(startButton);
324+
}
325+
326+
if (status === "ready") {
332327
const srvUrl = node.getServiceUrl();
333328
const msg = "Service ready on " + srvUrl;
334329
const msgData = {
@@ -343,9 +338,10 @@ qx.Class.define("osparc.data.model.IframeHandler", {
343338
node.callRetrieveInputs();
344339
}
345340
}
346-
if (oldStatus === "ready") {
341+
if (status === "idle" && oldStatus) {
347342
// will switch to loading page
348-
this.__restartIFrame();
343+
this.getIFrame().resetSource();
344+
this.fireEvent("iframeChanged");
349345
}
350346
},
351347

0 commit comments

Comments
 (0)