From 12444c15b5a64f6221c28552bc20a2a325397a7e Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 09:23:12 +0200 Subject: [PATCH 1/7] popUpPreview --- .../source/class/osparc/study/StudyPreview.js | 27 +++++++++++++++++++ .../class/osparc/widget/PersistentIframe.js | 6 +---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index 7d2a101ba53f..e08cd456992f 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -31,6 +31,33 @@ qx.Class.define("osparc.study.StudyPreview", { this.__buildPreview(); }, + statics: { + __popUpPreview: function(studyData) { + const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]); + if (cantReadServices.length) { + unknownServices(cantReadServices); + } + const templateModel = new osparc.data.model.Study(studyData); + const preview = new osparc.study.StudyPreview(templateModel); + const title = this.tr("Function Preview"); + const width = osparc.dashboard.ResourceDetails.WIDTH; + const height = osparc.dashboard.ResourceDetails.HEIGHT; + osparc.ui.window.Window.popUpInWindow(preview, title, width, height); + }, + + popUpPreview: function(studyData) { + if ("services" in studyData) { + this.__popUpPreview(studyData); + } else { + osparc.store.Services.getStudyServices(resourceData.uuid) + .then(resp => { + const services = resp["services"]; + studyData["services"] = services; + this.__popUpPreview(studyData); + }); + } + }, + members: { __study: null, diff --git a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js index 7734141dfca1..fa2ccdf5bf52 100644 --- a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js +++ b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js @@ -336,11 +336,7 @@ qx.Class.define("osparc.widget.PersistentIframe", { const templateId = data["message"]["functionId"]; osparc.store.Templates.fetchTemplate(templateId) .then(templateData => { - templateData["resourceType"] = "template"; - const resourceDetails = new osparc.dashboard.ResourceDetails(templateData).set({ - showOpenButton: false, - }); - osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); + osparc.study.StudyPreview.popUpPreview(templateData); }) .catch(() => osparc.FlashMessenger.logError(this.tr("Function not found"))); } From 163392148d81dad67d1e44b15e2195954ce9a198 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 09:39:53 +0200 Subject: [PATCH 2/7] logerror --- .../client/source/class/osparc/study/StudyPreview.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index e08cd456992f..ce9ddacf2aa2 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -34,11 +34,12 @@ qx.Class.define("osparc.study.StudyPreview", { statics: { __popUpPreview: function(studyData) { const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]); - if (cantReadServices.length) { - unknownServices(cantReadServices); + if (cantReadServices && cantReadServices.length) { + osparc.FlashMessenger.logError("Function Data not available"); + return; } - const templateModel = new osparc.data.model.Study(studyData); - const preview = new osparc.study.StudyPreview(templateModel); + const study = new osparc.data.model.Study(studyData); + const preview = new osparc.study.StudyPreview(study); const title = this.tr("Function Preview"); const width = osparc.dashboard.ResourceDetails.WIDTH; const height = osparc.dashboard.ResourceDetails.HEIGHT; @@ -49,13 +50,14 @@ qx.Class.define("osparc.study.StudyPreview", { if ("services" in studyData) { this.__popUpPreview(studyData); } else { - osparc.store.Services.getStudyServices(resourceData.uuid) + osparc.store.Services.getStudyServices(studyData) .then(resp => { const services = resp["services"]; studyData["services"] = services; this.__popUpPreview(studyData); }); } + } }, members: { From 1c687bfd154c86d70dcd4d2e25ea2aa55a7e8dfb Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 10:08:04 +0200 Subject: [PATCH 3/7] working --- .../source/class/osparc/study/StudyPreview.js | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index ce9ddacf2aa2..cda6119780a9 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -38,19 +38,39 @@ qx.Class.define("osparc.study.StudyPreview", { osparc.FlashMessenger.logError("Function Data not available"); return; } + const study = new osparc.data.model.Study(studyData); - const preview = new osparc.study.StudyPreview(study); - const title = this.tr("Function Preview"); - const width = osparc.dashboard.ResourceDetails.WIDTH; - const height = osparc.dashboard.ResourceDetails.HEIGHT; - osparc.ui.window.Window.popUpInWindow(preview, title, width, height); + // make sure it will be shown + study.getUi().setMode("pipeline"); + + const studyReady = () => { + const preview = new osparc.study.StudyPreview(study); + const title = qx.locale.Manager.tr("Function Preview"); + const width = osparc.dashboard.ResourceDetails.WIDTH; + const height = osparc.dashboard.ResourceDetails.HEIGHT; + osparc.ui.window.Window.popUpInWindow(preview, title, width, height).set({ + clickAwayClose: false, + resizable: true, + showClose: true, + }); + } + + if (study.getWorkbench().isDeserialized()) { + studyReady(); + } else { + study.getWorkbench().addListener("changeDeserialized", e => { + if (e.getData()) { + studyReady(); + } + }, this); + } }, popUpPreview: function(studyData) { if ("services" in studyData) { this.__popUpPreview(studyData); } else { - osparc.store.Services.getStudyServices(studyData) + osparc.store.Services.getStudyServices(studyData["uuid"]) .then(resp => { const services = resp["services"]; studyData["services"] = services; From a7440ae81b6561d0d3151a8d40d9942c495afb31 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 10:29:35 +0200 Subject: [PATCH 4/7] working again --- .../osparc/dashboard/ResourceBrowserBase.js | 14 ++++ .../class/osparc/dashboard/ResourceDetails.js | 15 ++++ .../source/class/osparc/study/StudyPreview.js | 76 +++++-------------- .../class/osparc/widget/PersistentIframe.js | 13 ++-- 4 files changed, 58 insertions(+), 60 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index b9666fec810a..6b1314fcda02 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -939,6 +939,20 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { }, _openResourceDetails: function(resourceData) { + // OM: remove this + const hack = true; + if (hack) { + const functionData = { + "uuid": resourceData["uuid"], + "resourceType": "function", + }; + const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({ + showOpenButton: false, + }); + osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); + return; + } + const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData); const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); resourceDetails.addListener("updateStudy", e => this._updateStudyData(e.getData())); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js index d517f80bdd11..bd5f17852275 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js @@ -37,6 +37,10 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { latestPromise = osparc.data.Resources.fetch("studies", "getOne", params); break; } + case "function": { + latestPromise = osparc.store.Templates.fetchTemplate(resourceData["uuid"]); + break; + } case "service": { latestPromise = osparc.store.Services.getService(resourceData["key"], resourceData["version"]); break; @@ -57,6 +61,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { case "template": case "tutorial": case "hypertool": + case "function": // when getting the latest study data, the debt information was lost if (osparc.study.Utils.isInDebt(this.__resourceData)) { const mainStore = osparc.store.Store.getInstance(); @@ -372,6 +377,16 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { // removeAll osparc.utils.Utils.removeAllChildren(tabsView); + if (this.__resourceData["resourceType"] === "function") { + // for now, we only want the preview page + const page = this.__getPreviewPage(); + if (page) { + tabsView.add(page); + } + this.fireEvent("pagesAdded"); + return; + } + // add Open service button [ this.__getInfoPage, diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index cda6119780a9..fcc547985b77 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -31,67 +31,33 @@ qx.Class.define("osparc.study.StudyPreview", { this.__buildPreview(); }, - statics: { - __popUpPreview: function(studyData) { - const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]); - if (cantReadServices && cantReadServices.length) { - osparc.FlashMessenger.logError("Function Data not available"); - return; - } - - const study = new osparc.data.model.Study(studyData); - // make sure it will be shown - study.getUi().setMode("pipeline"); - - const studyReady = () => { - const preview = new osparc.study.StudyPreview(study); - const title = qx.locale.Manager.tr("Function Preview"); - const width = osparc.dashboard.ResourceDetails.WIDTH; - const height = osparc.dashboard.ResourceDetails.HEIGHT; - osparc.ui.window.Window.popUpInWindow(preview, title, width, height).set({ - clickAwayClose: false, - resizable: true, - showClose: true, - }); - } - - if (study.getWorkbench().isDeserialized()) { - studyReady(); - } else { - study.getWorkbench().addListener("changeDeserialized", e => { - if (e.getData()) { - studyReady(); - } - }, this); - } - }, - - popUpPreview: function(studyData) { - if ("services" in studyData) { - this.__popUpPreview(studyData); - } else { - osparc.store.Services.getStudyServices(studyData["uuid"]) - .then(resp => { - const services = resp["services"]; - studyData["services"] = services; - this.__popUpPreview(studyData); - }); - } - } - }, - members: { __study: null, __buildPreview: function() { const study = this.__study; + + const studyReady = () => { + if (!study.isPipelineEmpty()) { + const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview(); + workbenchUIPreview.setStudy(study); + workbenchUIPreview.loadModel(study.getWorkbench()); + workbenchUIPreview.setMaxHeight(550); + this._add(workbenchUIPreview); + } + }; + const uiMode = study.getUi().getMode(); - if (["workbench", "pipeline"].includes(uiMode) && !study.isPipelineEmpty()) { - const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview(); - workbenchUIPreview.setStudy(study); - workbenchUIPreview.loadModel(study.getWorkbench()); - workbenchUIPreview.setMaxHeight(550); - this._add(workbenchUIPreview); + if (["workbench", "pipeline"].includes(uiMode)) { + if (study.getWorkbench().isDeserialized()) { + studyReady(); + } else { + study.getWorkbench().addListener("changeDeserialized", e => { + if (e.getData()) { + studyReady(); + } + }, this); + } } } } diff --git a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js index fa2ccdf5bf52..96aa0b0a7856 100644 --- a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js +++ b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js @@ -334,11 +334,14 @@ qx.Class.define("osparc.widget.PersistentIframe", { // this is the MetaModeling service trying to show function/template information if (data["message"] && data["message"]["functionId"]) { const templateId = data["message"]["functionId"]; - osparc.store.Templates.fetchTemplate(templateId) - .then(templateData => { - osparc.study.StudyPreview.popUpPreview(templateData); - }) - .catch(() => osparc.FlashMessenger.logError(this.tr("Function not found"))); + const functionData = { + "uuid": templateId, + "resourceType": "function", + }; + const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({ + showOpenButton: false, + }); + osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); } break; } From 02a370f50e002d630d918c8530a7aeb9e841c879 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 10:30:52 +0200 Subject: [PATCH 5/7] minor --- .../client/source/class/osparc/study/StudyPreview.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index fcc547985b77..845eaf1f3551 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -37,7 +37,7 @@ qx.Class.define("osparc.study.StudyPreview", { __buildPreview: function() { const study = this.__study; - const studyReady = () => { + const workbenchReady = () => { if (!study.isPipelineEmpty()) { const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview(); workbenchUIPreview.setStudy(study); @@ -50,11 +50,11 @@ qx.Class.define("osparc.study.StudyPreview", { const uiMode = study.getUi().getMode(); if (["workbench", "pipeline"].includes(uiMode)) { if (study.getWorkbench().isDeserialized()) { - studyReady(); + workbenchReady(); } else { study.getWorkbench().addListener("changeDeserialized", e => { if (e.getData()) { - studyReady(); + workbenchReady(); } }, this); } From 64b134ab5c2a34c5e0d395f50041bc99488f3c8f Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 23 Jun 2025 10:37:36 +0200 Subject: [PATCH 6/7] cleanup --- .../class/osparc/dashboard/ResourceBrowserBase.js | 14 -------------- .../source/class/osparc/widget/PersistentIframe.js | 3 ++- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index 6b1314fcda02..b9666fec810a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -939,20 +939,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { }, _openResourceDetails: function(resourceData) { - // OM: remove this - const hack = true; - if (hack) { - const functionData = { - "uuid": resourceData["uuid"], - "resourceType": "function", - }; - const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({ - showOpenButton: false, - }); - osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); - return; - } - const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData); const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); resourceDetails.addListener("updateStudy", e => this._updateStudyData(e.getData())); diff --git a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js index 96aa0b0a7856..b4293f56ca1a 100644 --- a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js +++ b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js @@ -341,7 +341,8 @@ qx.Class.define("osparc.widget.PersistentIframe", { const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({ showOpenButton: false, }); - osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); + const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); + win.setCaption("Function Details"); } break; } From 5d0991a87dd12ec74e41d96d97837b8f5f2e1d48 Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:40:27 +0200 Subject: [PATCH 7/7] Update services/static-webserver/client/source/class/osparc/study/StudyPreview.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../client/source/class/osparc/study/StudyPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js index 845eaf1f3551..fe2a967b2b75 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPreview.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPreview.js @@ -52,7 +52,7 @@ qx.Class.define("osparc.study.StudyPreview", { if (study.getWorkbench().isDeserialized()) { workbenchReady(); } else { - study.getWorkbench().addListener("changeDeserialized", e => { + study.getWorkbench().addListenerOnce("changeDeserialized", e => { if (e.getData()) { workbenchReady(); }