Skip to content

Commit

Permalink
🐛 Fix: Guest Node viewer (ITISFoundation#6177)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Aug 13, 2024
1 parent 204a2fa commit 2682a07
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ qx.Class.define("osparc.data.model.Workbench", {
init: null,
nullable: false,
event: "changeStudy"
},

deserialized: {
check: "Boolean",
init: false,
nullable: false,
event: "changeDeserialized"
}
},

Expand Down Expand Up @@ -662,6 +669,7 @@ qx.Class.define("osparc.data.model.Workbench", {
this.__deserializeEdges(workbenchInitData);
workbenchInitData = null;
workbenchUIInitData = null;
this.setDeserialized(true);
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,51 @@ qx.Class.define("osparc.viewer.NodeViewer", {

this._setLayout(new qx.ui.layout.VBox());

let studyData = null;
this.self().openStudy(studyId)
.then(resp => {
studyData = resp;
if (studyData["workbench"] && nodeId in studyData["workbench"]) {
const nodeData = studyData["workbench"][nodeId];
return osparc.service.Store.getService(nodeData.key, nodeData.version)
}
throw new Error("Node data not found in Study");
})
.then(metadata => {
const params = {
url: {
studyId
},
data: osparc.utils.Utils.getClientSessionID()
};
osparc.data.Resources.fetch("studies", "open", params)
.then(studyData => {
// create study
const study = new osparc.data.model.Study(studyData);
this.setStudy(study);

// create node
const node = new osparc.data.model.Node(study, metadata, nodeId);
this.setNode(node);

node.addListener("retrieveInputs", e => {
const data = e.getData();
const portKey = data["portKey"];
node.retrieveInputs(portKey);
}, this);

node.initIframeHandler();

const iframeHandler = node.getIframeHandler();
if (iframeHandler) {
iframeHandler.startPolling();
iframeHandler.addListener("iframeChanged", () => this.__iFrameChanged(), this);
iframeHandler.getIFrame().addListener("load", () => this.__iFrameChanged(), this);
this.__iFrameChanged();
const startPolling = () => {
const node = study.getWorkbench().getNode(nodeId);
this.setNode(node);

node.addListener("retrieveInputs", e => {
const data = e.getData();
const portKey = data["portKey"];
node.retrieveInputs(portKey);
}, this);

node.initIframeHandler();

const iframeHandler = node.getIframeHandler();
if (iframeHandler) {
iframeHandler.startPolling();
iframeHandler.addListener("iframeChanged", () => this.__iFrameChanged(), this);
iframeHandler.getIFrame().addListener("load", () => this.__iFrameChanged(), this);
this.__iFrameChanged();

this.__attachSocketEventHandlers();
} else {
console.error(node.getLabel() + " iframe handler not ready");
}
}

this.__attachSocketEventHandlers();
if (study.getWorkbench().isDeserialized()) {
startPolling();
} else {
console.error(node.getLabel() + " iframe handler not ready");
study.getWorkbench().addListener("changeDeserialized", e => {
if (e.getData()) {
startPolling();
}
});
}
})
.catch(err => console.error(err));
Expand All @@ -81,18 +89,6 @@ qx.Class.define("osparc.viewer.NodeViewer", {
}
},

statics: {
openStudy: function(studyId) {
const params = {
url: {
"studyId": studyId
},
data: osparc.utils.Utils.getClientSessionID()
};
return osparc.data.Resources.fetch("studies", "open", params);
}
},

members: {
__iFrameChanged: function() {
this._removeAll();
Expand Down

0 comments on commit 2682a07

Please sign in to comment.