From 045dcf18308544768436a02e2ac38e674659af59 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 16:11:24 +0100 Subject: [PATCH 1/4] rename --- .../class/osparc/dashboard/StudyBrowser.js | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 288290b06df7..9a9e3e981918 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -721,7 +721,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { break; case "tis": case "tiplite": - this.__addTIPPlusButtons(); + this.__addTIPPlusButton(); break; case "s4l": case "s4lacad": @@ -745,24 +745,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.addNonResourceCard(newStudyBtn); }, - __addTIPPlusButtons: function() { - osparc.data.Resources.get("templates") - .then(templates => { - if (templates) { - osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json") - .then(newStudiesData => { - const product = osparc.product.Utils.getProductName() - if (product in newStudiesData) { - const mode = this._resourcesContainer.getMode(); - const title = this.tr("New Plan"); - const newStudyBtn = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title) : new osparc.dashboard.ListButtonNew(title); - newStudyBtn.setCardKey("new-study"); - newStudyBtn.subscribeToFilterGroup("searchBarFilter"); - osparc.utils.Utils.setIdToWidget(newStudyBtn, "newStudyBtn"); - this._resourcesContainer.addNonResourceCard(newStudyBtn); - newStudyBtn.addListener("execute", () => { - newStudyBtn.setValue(false); - + __addTIPPlusButton: function() { const newStudies = new osparc.dashboard.NewStudies(newStudiesData[product]); newStudies.addListener("templatesLoaded", () => { newStudies.setGroupBy("category"); From dd6dfe9fdb5f126e788915e8a92f482c5bb2db78 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 16:31:56 +0100 Subject: [PATCH 2/4] do not use cached templates --- .../class/osparc/dashboard/StudyBrowser.js | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 9a9e3e981918..96aa75138119 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -746,6 +746,28 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __addTIPPlusButton: function() { + const mode = this._resourcesContainer.getMode(); + const title = this.tr("New Plan"); + const newStudyBtn = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title) : new osparc.dashboard.ListButtonNew(title); + newStudyBtn.setCardKey("new-study"); + newStudyBtn.subscribeToFilterGroup("searchBarFilter"); + osparc.utils.Utils.setIdToWidget(newStudyBtn, "newStudyBtn"); + this._resourcesContainer.addNonResourceCard(newStudyBtn); + newStudyBtn.setEnabled(false); + + osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json") + .then(newStudiesData => { + const product = osparc.product.Utils.getProductName() + if (product in newStudiesData) { + newStudyBtn.setEnabled(true); + + newStudyBtn.addListener("execute", () => { + newStudyBtn.setValue(false); + // do not use cached templates + osparc.data.Resources.get("templates", {}, false) + .then(templates => { + console.log("templates", templates); + if (templates) { const newStudies = new osparc.dashboard.NewStudies(newStudiesData[product]); newStudies.addListener("templatesLoaded", () => { newStudies.setGroupBy("category"); @@ -764,9 +786,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow"); }); - }); - } - }); + } + }); + }); } }); }, From a808e4570ea4a9a62b6e7ce3ce60714884e05b93 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 16:38:28 +0100 Subject: [PATCH 3/4] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 1 - 1 file changed, 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 96aa75138119..4922cb31bffe 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -766,7 +766,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // do not use cached templates osparc.data.Resources.get("templates", {}, false) .then(templates => { - console.log("templates", templates); if (templates) { const newStudies = new osparc.dashboard.NewStudies(newStudiesData[product]); newStudies.addListener("templatesLoaded", () => { From 2184ffe8c45911b09f25d5794d785c9a615d2d5f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 16:44:21 +0100 Subject: [PATCH 4/4] reload templates --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 3 +-- .../client/source/class/osparc/info/StudyLarge.js | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 4922cb31bffe..8e5f2507b242 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -763,8 +763,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { newStudyBtn.addListener("execute", () => { newStudyBtn.setValue(false); - // do not use cached templates - osparc.data.Resources.get("templates", {}, false) + osparc.data.Resources.get("templates") .then(templates => { if (templates) { const newStudies = new osparc.dashboard.NewStudies(newStudiesData[product]); diff --git a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js index 3351ed0fc96d..5709bfd70a23 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -324,6 +324,10 @@ qx.Class.define("osparc.info.StudyLarge", { studyData["resourceType"] = this.__isTemplate ? "template" : "study"; this.fireDataEvent("updateStudy", studyData); qx.event.message.Bus.getInstance().dispatchByName("updateStudy", studyData); + if (this.__isTemplate) { + // reload templates + osparc.data.Resources.get("templates", {}, false) + } }) .catch(err => { console.error(err);