Skip to content

Commit

Permalink
sendMessageToIframe and sendCloseMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Dec 12, 2024
1 parent 49e850e commit 0881037
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ qx.Class.define("osparc.data.model.Study", {
return !this.getUi().getSlideshow().isEmpty();
},

sendMessageToIframe: function(nodeId, msg) {
if (nodeId) {
const node = this.getWorkbench().getNode(nodeId);
if (node && node.getIFrame()) {
node.getIFrame().sendMessageToIframe(msg);
return true;
}
}
return false;
},

patchStudy: function(studyChanges) {
const matches = this.self().OwnPatch.filter(el => Object.keys(studyChanges).indexOf(el) !== -1);
if (matches.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,17 @@ qx.Class.define("osparc.vipMarket.Market", {
}
return false;
},

sendCloseMessage: function() {
const store = osparc.store.Store.getInstance();
const currentStudy = store.getCurrentStudy();
const nodeId = this.getOpenBy();
if (currentStudy && nodeId) {
const msg = {
"type": "closeMarket",
};
currentStudy.sendMessageToIframe(nodeId, msg);
}
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ qx.Class.define("osparc.vipMarket.MarketWindow", {
if (osparc.product.Utils.showS4LStore()) {
const storeWindow = new osparc.vipMarket.MarketWindow(nodeId, category);
storeWindow.getVipMarket().addListener("importMessageSent", () => storeWindow.close());
storeWindow.addListenerOnce("close", () => {
if (storeWindow.getVipMarket()) {
storeWindow.getVipMarket().sendCloseMessage();
}
});
storeWindow.center();
storeWindow.open();
return storeWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,22 +361,17 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
},

__sendImportModelMessage: function(modelId) {
const store = osparc.store.Store.getInstance();
const currentStudy = store.getCurrentStudy();
const nodeId = this.getOpenBy();
if (nodeId) {
const store = osparc.store.Store.getInstance();
const currentStudy = store.getCurrentStudy();
if (!currentStudy) {
return;
}
const node = currentStudy.getWorkbench().getNode(nodeId);
if (node && node.getIFrame()) {
const msg = {
"type": "importModel",
"message": {
"modelId": modelId,
},
};
node.getIFrame().sendMessageToIframe(msg);
if (currentStudy && nodeId) {
const msg = {
"type": "importModel",
"message": {
"modelId": modelId,
},
};
if (currentStudy.sendMessageToIframe(nodeId, msg)) {
this.fireEvent("importMessageSent");
}
}
Expand Down

0 comments on commit 0881037

Please sign in to comment.