From dbcc99fe862d2bbc6c97e552cac93be974935b0c Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 10:12:58 +0100 Subject: [PATCH 01/18] expose studyData --- .../client/source/class/osparc/study/StudyOptions.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index 9922ec017e3..ab7e10c0ad0 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -23,7 +23,9 @@ qx.Class.define("osparc.study.StudyOptions", { this._setLayout(new qx.ui.layout.VBox(15)); - this.setStudyId(studyId); + if (studyId) { + this.setStudyId(studyId); + } }, properties: { @@ -192,7 +194,7 @@ qx.Class.define("osparc.study.StudyOptions", { ]) .then(values => { const studyData = values[0]; - this.__studyData = osparc.data.model.Study.deepCloneStudyObject(studyData); + this.setStudyData(studyData); if (values[1] && "walletId" in values[1]) { this.__studyWalletId = values[1]["walletId"]; @@ -201,6 +203,10 @@ qx.Class.define("osparc.study.StudyOptions", { }); }, + setStudyData: function(studyData) { + this.__studyData = osparc.data.model.Study.deepCloneStudyObject(studyData); + }, + __applyWallet: function(wallet) { if (wallet) { const walletSelector = this.getChildControl("wallet-selector"); From 566a6fd5047849a17cc260b8ce184c32eb9359d2 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 10:38:16 +0100 Subject: [PATCH 02/18] return studyData --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../static-webserver/client/source/class/osparc/study/Utils.js | 2 +- 2 files changed, 2 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 288290b06df..19dab7c6815 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1199,7 +1199,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { folderId: this.getCurrentFolderId(), }; osparc.study.Utils.createStudyFromTemplate(templateCopyData, this._loadingPage, contextProps) - .then(studyId => this.__startStudyAfterCreating(studyId)) + .then(studyData => this.__startStudyAfterCreating(studyData["uuid"])) .catch(err => { this._hideLoadingPage(); osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR"); diff --git a/services/static-webserver/client/source/class/osparc/study/Utils.js b/services/static-webserver/client/source/class/osparc/study/Utils.js index 0240d263e47..66ed40201f4 100644 --- a/services/static-webserver/client/source/class/osparc/study/Utils.js +++ b/services/static-webserver/client/source/class/osparc/study/Utils.js @@ -255,7 +255,7 @@ qx.Class.define("osparc.study.Utils", { }, this); task.addListener("resultReceived", e => { const studyData = e.getData(); - resolve(studyData["uuid"]); + resolve(studyData); }, this); task.addListener("pollingError", e => { const err = e.getData(); From 74589f9446b5308446b8047b10fb0580aa29c1cd Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 10:59:28 +0100 Subject: [PATCH 03/18] more flexible --- .../source/class/osparc/study/StudyPricingUnits.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js index 793fee5cb34..f6bb1fb5b08 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js @@ -25,9 +25,9 @@ qx.Class.define("osparc.study.StudyPricingUnits", { layout: new qx.ui.layout.VBox(5) }); - this.__studyData = studyData; - - this.__showPricingUnits(); + if (studyData) { + this.setStudyData(studyData); + } }, events: { @@ -38,6 +38,11 @@ qx.Class.define("osparc.study.StudyPricingUnits", { members: { __studyData: null, + setStudyData: function(studyData) { + this.__studyData = studyData; + this.__showPricingUnits(); + }, + __showPricingUnits: function() { const unitsLoading = () => this.fireEvent("loadingUnits"); const unitsAdded = () => this.fireEvent("unitsReady"); From 41dbb5ddb92b53772a5fd002a33a52d2ea09b8af Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:19:16 +0100 Subject: [PATCH 04/18] refactoring --- .../class/osparc/dashboard/TemplateBrowser.js | 73 ++++++--- .../source/class/osparc/study/StudyOptions.js | 141 +++++++++++------- 2 files changed, 138 insertions(+), 76 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index d597d8a438c..2288b4777a8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -138,26 +138,61 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { } this._showLoadingPage(this.tr("Creating ") + (templateData.name || osparc.product.Utils.getStudyAlias({firstUpperCase: true}))); - osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) - .then(studyId => { - const openCB = () => this._hideLoadingPage(); - const cancelCB = () => { - this._hideLoadingPage(); - const params = { - url: { - studyId - } + + const studyOptions = new osparc.study.StudyOptions(); + studyOptions.setStudyData(templateData); + const win = osparc.study.StudyOptions.popUpInWindow(studyOptions); + win.moveItUp(); + const cancelStudyOptions = () => { + this._hideLoadingPage(); + win.close(); + } + win.addListener("cancel", () => cancelStudyOptions()); + studyOptions.addListener("cancel", () => cancelStudyOptions()); + studyOptions.addListener("startStudy", () => { + osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) + .then(studyData => { + const studyId = studyData["uuid"]; + const openCB = () => { + this._hideLoadingPage(); }; - osparc.data.Resources.fetch("studies", "delete", params); - }; - const isStudyCreation = true; - this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); - }) - .catch(err => { - this._hideLoadingPage(); - osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR"); - console.error(err); - }); + const cancelCB = () => { + this._hideLoadingPage(); + const params = { + url: { + studyId + } + }; + osparc.data.Resources.fetch("studies", "delete", params); + }; + + const titleSelection = studyOptions.getChildControl("title-field").getValue(); + if (studyData["name"] !== titleSelection) { + osparc.study.StudyOptions.updateName(studyData, titleSelection) + .catch(err => { + console.error(err); + const msg = this.tr("Something went wrong Renaming"); + osparc.FlashMessenger.logAs(msg, "ERROR"); + }); + } + + const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); + if (walletSelection.length && walletSelection[0]["walletId"]) { + const walletId = walletSelection[0]["walletId"] + osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId) + } + + win.close(); + + const isStudyCreation = true; + this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); + }) + .catch(err => { + this._hideLoadingPage(); + osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR"); + console.error(err); + }); + }); }, // LAYOUT // diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index ab7e10c0ad0..d0b0ad4837c 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -22,6 +22,7 @@ qx.Class.define("osparc.study.StudyOptions", { this.base(arguments); this._setLayout(new qx.ui.layout.VBox(15)); + this.__buildLayout(); if (studyId) { this.setStudyId(studyId); @@ -42,7 +43,14 @@ qx.Class.define("osparc.study.StudyOptions", { nullable: true, event: "changeWallet", apply: "__applyWallet" - } + }, + + patchStudy: { + check: "Boolean", + init: false, + nullable: false, + event: "changePatchStudy", + }, }, events: { @@ -80,7 +88,31 @@ qx.Class.define("osparc.study.StudyOptions", { }); box.setLayout(new qx.ui.layout.VBox(5)); return box; - } + }, + + updateName: function(studyData, name) { + return osparc.info.StudyUtils.patchStudyData(studyData, "name", name) + .catch(err => { + console.error(err); + const msg = err.message || qx.locale.Manager.tr("Something went wrong Renaming"); + osparc.FlashMessenger.logAs(msg, "ERROR"); + }); + }, + + updateWallet: function(studyId, walletId) { + const params = { + url: { + studyId, + walletId, + } + }; + return osparc.data.Resources.fetch("studies", "selectWallet", params) + .catch(err => { + console.error(err); + const msg = err.message || qx.locale.Manager.tr("Error selecting Credit Account"); + osparc.FlashMessenger.getInstance().logAs(msg, "ERROR"); + }); + }, }, members: { @@ -149,6 +181,24 @@ qx.Class.define("osparc.study.StudyOptions", { control = this.self().createGroupBox(this.tr("Tiers")); this.getChildControl("options-layout").add(control); break; + case "study-pricing-units": { + const loadingImage = this.getChildControl("loading-units-spinner"); + const unitsBoxesLayout = this.getChildControl("services-resources-layout"); + const unitsLoading = () => { + loadingImage.show(); + unitsBoxesLayout.exclude(); + }; + const unitsReady = () => { + loadingImage.exclude(); + unitsBoxesLayout.show(); + }; + unitsLoading(); + control = new osparc.study.StudyPricingUnits(); + control.addListener("loadingUnits", () => unitsLoading()); + control.addListener("unitsReady", () => unitsReady()); + unitsBoxesLayout.add(control); + break; + } case "buttons-layout": control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({ alignX: "right" @@ -193,6 +243,8 @@ qx.Class.define("osparc.study.StudyOptions", { osparc.data.Resources.fetch("studies", "getWallet", params) ]) .then(values => { + this.setPatchChanges(true); + const studyData = values[0]; this.setStudyData(studyData); @@ -205,6 +257,12 @@ qx.Class.define("osparc.study.StudyOptions", { setStudyData: function(studyData) { this.__studyData = osparc.data.model.Study.deepCloneStudyObject(studyData); + + const titleField = this.getChildControl("title-field"); + titleField.setValue(this.__studyData["name"]); + + const studyPricingUnits = this.getChildControl("study-pricing-units"); + studyPricingUnits.setStudyData(this.__studyData); }, __applyWallet: function(wallet) { @@ -230,9 +288,6 @@ qx.Class.define("osparc.study.StudyOptions", { const store = osparc.store.Store.getInstance(); const titleField = this.getChildControl("title-field"); - if (this.__studyData) { - titleField.setValue(this.__studyData["name"]); - } titleField.addListener("appear", () => { titleField.focus(); titleField.activate(); @@ -267,21 +322,7 @@ qx.Class.define("osparc.study.StudyOptions", { }, __buildOptionsLayout: function() { - const loadingImage = this.getChildControl("loading-units-spinner"); - const unitsBoxesLayout = this.getChildControl("services-resources-layout"); - const unitsLoading = () => { - loadingImage.show(); - unitsBoxesLayout.exclude(); - }; - const unitsReady = () => { - loadingImage.exclude(); - unitsBoxesLayout.show(); - }; - unitsLoading(); - const studyPricingUnits = new osparc.study.StudyPricingUnits(this.__studyData); - studyPricingUnits.addListener("loadingUnits", () => unitsLoading()); - studyPricingUnits.addListener("unitsReady", () => unitsReady()); - unitsBoxesLayout.add(studyPricingUnits); + this.getChildControl("study-pricing-units"); }, __buildButtons: function() { @@ -297,48 +338,34 @@ qx.Class.define("osparc.study.StudyOptions", { const openButton = this.getChildControl("open-button"); openButton.setFetching(true); - // first, update the name if necessary - const titleSelection = this.getChildControl("title-field").getValue(); - if (this.__studyData && this.__studyData["name"] !== titleSelection) { - await this.__updateName(this.__studyData, titleSelection); - } + if (this.isPatchStudy()) { + // first, update the name if necessary + const titleSelection = this.getChildControl("title-field").getValue(); + if (this.__studyData["name"] !== titleSelection) { + await this.self().updateName(this.__studyData, titleSelection); + } - // second, update the wallet if necessary - const store = osparc.store.Store.getInstance(); - const walletSelection = this.getChildControl("wallet-selector").getSelection(); - const studyId = this.getStudyId(); - if (studyId && walletSelection.length && walletSelection[0]["walletId"]) { - const params = { - url: { - studyId, - "walletId": walletSelection[0]["walletId"] - } - }; - osparc.data.Resources.fetch("studies", "selectWallet", params) - .then(() => { - store.setActiveWallet(this.getWallet()); - this.fireEvent("startStudy"); - }) - .catch(err => { - console.error(err); - const msg = err.message || this.tr("Error selecting Credit Account"); - osparc.FlashMessenger.getInstance().logAs(msg, "ERROR"); - }) - .finally(() => openButton.setFetching(false)); + // second, update the wallet if necessary + const store = osparc.store.Store.getInstance(); + const walletSelection = this.getChildControl("wallet-selector").getSelection(); + if (walletSelection.length && walletSelection[0]["walletId"]) { + const studyId = this.getStudyId(); + const walletId = walletSelection[0]["walletId"]; + this.self().updateWallet(studyId, walletId) + .then(() => { + store.setActiveWallet(this.getWallet()); + this.fireEvent("startStudy"); + }) + .finally(() => openButton.setFetching(false)); + } else { + store.setActiveWallet(this.getWallet()); + this.fireEvent("startStudy"); + openButton.setFetching(false); + } } else { - store.setActiveWallet(this.getWallet()); this.fireEvent("startStudy"); openButton.setFetching(false); } }, - - __updateName: function(studyData, name) { - return osparc.info.StudyUtils.patchStudyData(studyData, "name", name) - .catch(err => { - console.error(err); - const msg = this.tr("Something went wrong Renaming"); - osparc.FlashMessenger.logAs(msg, "ERROR"); - }); - } } }); From db8986644dc9e54489d540091c737e34014be6a8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:27:34 +0100 Subject: [PATCH 05/18] patch changes --- .../class/osparc/dashboard/TemplateBrowser.js | 23 ++++++++----------- .../source/class/osparc/study/StudyOptions.js | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 2288b4777a8..369841536fd 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -166,26 +166,23 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { osparc.data.Resources.fetch("studies", "delete", params); }; + const promises = []; const titleSelection = studyOptions.getChildControl("title-field").getValue(); if (studyData["name"] !== titleSelection) { - osparc.study.StudyOptions.updateName(studyData, titleSelection) - .catch(err => { - console.error(err); - const msg = this.tr("Something went wrong Renaming"); - osparc.FlashMessenger.logAs(msg, "ERROR"); - }); + promises.push(osparc.study.StudyOptions.updateName(studyData, titleSelection)); } - const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); if (walletSelection.length && walletSelection[0]["walletId"]) { - const walletId = walletSelection[0]["walletId"] - osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId) + const walletId = walletSelection[0]["walletId"]; + promises.push(osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId)); } - win.close(); - - const isStudyCreation = true; - this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); + Promise.all(promises) + .then(() => { + win.close(); + const isStudyCreation = true; + this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); + }); }) .catch(err => { this._hideLoadingPage(); diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index d0b0ad4837c..560f442d5f7 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -243,7 +243,7 @@ qx.Class.define("osparc.study.StudyOptions", { osparc.data.Resources.fetch("studies", "getWallet", params) ]) .then(values => { - this.setPatchChanges(true); + this.setPatchStudy(true); const studyData = values[0]; this.setStudyData(studyData); From ff18a24fed248eef2612594761b4107985933e4a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:30:13 +0100 Subject: [PATCH 06/18] renaming --- .../client/source/class/osparc/node/TierSelectionView.js | 2 +- .../client/source/class/osparc/study/NodePricingUnits.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js b/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js index 34dfc397b37..ffa1431a00e 100644 --- a/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js +++ b/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js @@ -105,7 +105,7 @@ qx.Class.define("osparc.node.TierSelectionView", { if (selection.length) { tierBox.setEnabled(false); const selectedUnitId = selection[0].getModel(); - osparc.study.NodePricingUnits.pricingUnitSelected(studyId, nodeId, pricingPlans["pricingPlanId"], selectedUnitId) + osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlans["pricingPlanId"], selectedUnitId) .finally(() => { tierBox.setEnabled(true); showSelectedTier(selectedUnitId); diff --git a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js index d8caa28b68f..7760253a65c 100644 --- a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js @@ -44,7 +44,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { }, statics: { - pricingUnitSelected: function(studyId, nodeId, planId, selectedUnitId) { + patchPricingUnitSelection: function(studyId, nodeId, planId, selectedUnitId) { const params = { url: { studyId, @@ -101,7 +101,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { unitButtons.addListener("changeSelectedUnitId", e => { unitButtons.setEnabled(false); const selectedPricingUnitId = e.getData(); - this.self().pricingUnitSelected(this.__studyId, this.__nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId) + this.self().patchPricingUnitSelection(this.__studyId, this.__nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId) .finally(() => unitButtons.setEnabled(true)); }); } From 70ff84e85e616dd4d4d9e69bcbe1703fd4deebfb Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:35:27 +0100 Subject: [PATCH 07/18] expose getNodePricingUnits --- .../source/class/osparc/study/StudyPricingUnits.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js index f6bb1fb5b08..99d6c4ffc6e 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js @@ -25,6 +25,8 @@ qx.Class.define("osparc.study.StudyPricingUnits", { layout: new qx.ui.layout.VBox(5) }); + this.__nodePricingUnits = []; + if (studyData) { this.setStudyData(studyData); } @@ -37,6 +39,7 @@ qx.Class.define("osparc.study.StudyPricingUnits", { members: { __studyData: null, + __nodePricingUnits: null, setStudyData: function(studyData) { this.__studyData = studyData; @@ -57,12 +60,17 @@ qx.Class.define("osparc.study.StudyPricingUnits", { return; } const nodePricingUnits = new osparc.study.NodePricingUnits(this.__studyData["uuid"], nodeId, node); + this.__nodePricingUnits.push(nodePricingUnits); this._add(nodePricingUnits); promises.push(nodePricingUnits.showPricingUnits()); }); } Promise.all(promises) .then(() => unitsAdded()); - } + }, + + getNodePricingUnits: function() { + return this.__nodePricingUnits; + }, } }); From f9fa585437d491c346eda432f00612fc0b439f91 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:48:57 +0100 Subject: [PATCH 08/18] more progress --- .../source/class/osparc/dashboard/TemplateBrowser.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 369841536fd..75f3e173a4b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -150,6 +150,10 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { win.addListener("cancel", () => cancelStudyOptions()); studyOptions.addListener("cancel", () => cancelStudyOptions()); studyOptions.addListener("startStudy", () => { + const titleSelection = studyOptions.getChildControl("title-field").getValue(); + const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); + const nodesPricingUnits = studyOptions.getNodePricingUnits(); + win.close(); osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) .then(studyData => { const studyId = studyData["uuid"]; @@ -167,15 +171,17 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { }; const promises = []; - const titleSelection = studyOptions.getChildControl("title-field").getValue(); if (studyData["name"] !== titleSelection) { promises.push(osparc.study.StudyOptions.updateName(studyData, titleSelection)); } - const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); if (walletSelection.length && walletSelection[0]["walletId"]) { const walletId = walletSelection[0]["walletId"]; promises.push(osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId)); } + nodesPricingUnits.forEach(nodePricingUnits => { + console.log("nodePricingUnits", nodePricingUnits); + // osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, ) + }) Promise.all(promises) .then(() => { From fea71a60e150a3d0d32ac6bbff1ab8ccd8516b7e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 11:53:24 +0100 Subject: [PATCH 09/18] showStudyOptions flag --- .../source/class/osparc/dashboard/ResourceBrowserBase.js | 4 ++-- .../client/source/class/osparc/dashboard/TemplateBrowser.js | 6 +++--- 2 files changed, 5 insertions(+), 5 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 31524310535..b2f810f313c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -95,7 +95,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { return isLogged; }, - startStudyById: function(studyId, openCB, cancelCB, isStudyCreation = false) { + startStudyById: function(studyId, openCB, cancelCB, showStudyOptions = false) { if (!osparc.dashboard.ResourceBrowserBase.checkLoggedIn()) { return; } @@ -117,7 +117,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { osparc.data.Resources.fetch("studies", "getWallet", params) .then(wallet => { if ( - isStudyCreation || + showStudyOptions || wallet === null || osparc.desktop.credits.Utils.getWallet(wallet["walletId"]) === null ) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 75f3e173a4b..2ab6d4b3acf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -152,7 +152,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { studyOptions.addListener("startStudy", () => { const titleSelection = studyOptions.getChildControl("title-field").getValue(); const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); - const nodesPricingUnits = studyOptions.getNodePricingUnits(); + const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits(); win.close(); osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) .then(studyData => { @@ -186,8 +186,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { Promise.all(promises) .then(() => { win.close(); - const isStudyCreation = true; - this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); + const showStudyOptions = false; + this._startStudyById(studyId, openCB, cancelCB, showStudyOptions); }); }) .catch(err => { From 1855219e52e0f7b1d09c6a45893834ca21eac0c0 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 13:23:03 +0100 Subject: [PATCH 10/18] minor --- .../class/osparc/study/NodePricingUnits.js | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js index 7760253a65c..f6396cf11e3 100644 --- a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js @@ -30,8 +30,10 @@ qx.Class.define("osparc.study.NodePricingUnits", { layout: new qx.ui.layout.VBox() }); - this.__studyId = studyId; - this.__nodeId = nodeId; + this.set({ + studyId, + nodeId, + }); if (node instanceof osparc.data.model.Node) { this.__nodeKey = node.getKey(); this.__nodeVersion = node.getVersion(); @@ -43,6 +45,20 @@ qx.Class.define("osparc.study.NodePricingUnits", { } }, + properties: { + studyId: { + check: "String", + init: null, + nullable: false, + }, + + nodeId: { + check: "String", + init: null, + nullable: false, + }, + }, + statics: { patchPricingUnitSelection: function(studyId, nodeId, planId, selectedUnitId) { const params = { @@ -58,8 +74,6 @@ qx.Class.define("osparc.study.NodePricingUnits", { }, members: { - __studyId: null, - __nodeId: null, __nodeKey: null, __nodeVersion: null, __nodeLabel: null, @@ -69,8 +83,8 @@ qx.Class.define("osparc.study.NodePricingUnits", { const nodeKey = this.__nodeKey; const nodeVersion = this.__nodeVersion; const nodeLabel = this.__nodeLabel; - const studyId = this.__studyId; - const nodeId = this.__nodeId; + const studyId = this.getStudyId(); + const nodeId = this.getNodeId(); const plansParams = { url: osparc.data.Resources.getServiceUrl( @@ -101,7 +115,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { unitButtons.addListener("changeSelectedUnitId", e => { unitButtons.setEnabled(false); const selectedPricingUnitId = e.getData(); - this.self().patchPricingUnitSelection(this.__studyId, this.__nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId) + this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId) .finally(() => unitButtons.setEnabled(true)); }); } From 94dc2fde95240cd9319d869239d225b04f48bbb1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 13:35:53 +0100 Subject: [PATCH 11/18] complete patches --- .../class/osparc/dashboard/TemplateBrowser.js | 6 ++- .../class/osparc/study/NodePricingUnits.js | 37 +++++++++++++------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 2ab6d4b3acf..451937330a7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -179,8 +179,10 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { promises.push(osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId)); } nodesPricingUnits.forEach(nodePricingUnits => { - console.log("nodePricingUnits", nodePricingUnits); - // osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, ) + const nodeId = nodePricingUnits.getNodeId(); + const pricingPlanId = nodePricingUnits.getPricingPlanId(); + const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId(); + promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)); }) Promise.all(promises) diff --git a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js index f6396cf11e3..784918f2ebd 100644 --- a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js @@ -57,6 +57,12 @@ qx.Class.define("osparc.study.NodePricingUnits", { init: null, nullable: false, }, + + pricingPlanId: { + check: "String", + init: null, + nullable: false, + }, }, statics: { @@ -77,6 +83,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { __nodeKey: null, __nodeVersion: null, __nodeLabel: null, + __pricingUnits: null, showPricingUnits: function(inGroupBox = true) { return new Promise(resolve => { @@ -93,30 +100,34 @@ qx.Class.define("osparc.study.NodePricingUnits", { ) }; osparc.data.Resources.fetch("services", "pricingPlans", plansParams) - .then(pricingPlans => { - if (pricingPlans) { + .then(pricingPlan => { + if (pricingPlan) { const unitParams = { url: { studyId, nodeId } }; + this.set({ + pricingPlanId: pricingPlan["pricingPlanId"] + }); osparc.data.Resources.fetch("studies", "getPricingUnit", unitParams) .then(preselectedPricingUnit => { - if (pricingPlans && "pricingUnits" in pricingPlans && pricingPlans["pricingUnits"].length) { - const unitButtons = new osparc.study.PricingUnits(pricingPlans["pricingUnits"], preselectedPricingUnit); + if (pricingPlan && "pricingUnits" in pricingPlan && pricingPlan["pricingUnits"].length) { + const pricingUnitButtons = this.__pricingUnits = new osparc.study.PricingUnits(pricingPlan["pricingUnits"], preselectedPricingUnit); if (inGroupBox) { const pricingUnitsLayout = osparc.study.StudyOptions.createGroupBox(nodeLabel); - pricingUnitsLayout.add(unitButtons); + pricingUnitsLayout.add(pricingUnitButtons); this._add(pricingUnitsLayout); } else { - this._add(unitButtons); + this._add(pricingUnitButtons); } - unitButtons.addListener("changeSelectedUnitId", e => { - unitButtons.setEnabled(false); + pricingUnitButtons.addListener("changeSelectedUnitId", e => { + pricingUnitButtons.setEnabled(false); + const pricingPlanId = this.getPricingPlanId(); const selectedPricingUnitId = e.getData(); - this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId) - .finally(() => unitButtons.setEnabled(true)); + this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId) + .finally(() => pricingUnitButtons.setEnabled(true)); }); } }) @@ -124,6 +135,10 @@ qx.Class.define("osparc.study.NodePricingUnits", { } }); }); - } + }, + + getPricingUnits: function() { + return this.__pricingUnits; + }, } }); From 09463085bfa952d521b48a2e72412678e0de1934 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 13:49:32 +0100 Subject: [PATCH 12/18] patchNode prop --- .../class/osparc/study/NodePricingUnits.js | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js index 784918f2ebd..76918e12b3e 100644 --- a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js @@ -59,10 +59,17 @@ qx.Class.define("osparc.study.NodePricingUnits", { }, pricingPlanId: { - check: "String", + check: "Number", init: null, nullable: false, }, + + patchNode: { + check: "Boolean", + init: true, + nullable: false, + event: "changePatchNode", + }, }, statics: { @@ -123,11 +130,13 @@ qx.Class.define("osparc.study.NodePricingUnits", { this._add(pricingUnitButtons); } pricingUnitButtons.addListener("changeSelectedUnitId", e => { - pricingUnitButtons.setEnabled(false); - const pricingPlanId = this.getPricingPlanId(); - const selectedPricingUnitId = e.getData(); - this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId) - .finally(() => pricingUnitButtons.setEnabled(true)); + if (this.isPatchNode()) { + pricingUnitButtons.setEnabled(false); + const pricingPlanId = this.getPricingPlanId(); + const selectedPricingUnitId = e.getData(); + this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId) + .finally(() => pricingUnitButtons.setEnabled(true)); + } }); } }) From 9145cf4febc3ebb00eea48682c5bce1e47e6615a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 13:49:59 +0100 Subject: [PATCH 13/18] bind props --- .../client/source/class/osparc/study/StudyOptions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index 560f442d5f7..97f39a7f673 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -47,7 +47,7 @@ qx.Class.define("osparc.study.StudyOptions", { patchStudy: { check: "Boolean", - init: false, + init: true, nullable: false, event: "changePatchStudy", }, @@ -182,6 +182,7 @@ qx.Class.define("osparc.study.StudyOptions", { this.getChildControl("options-layout").add(control); break; case "study-pricing-units": { + control = new osparc.study.StudyPricingUnits(); const loadingImage = this.getChildControl("loading-units-spinner"); const unitsBoxesLayout = this.getChildControl("services-resources-layout"); const unitsLoading = () => { @@ -191,9 +192,11 @@ qx.Class.define("osparc.study.StudyOptions", { const unitsReady = () => { loadingImage.exclude(); unitsBoxesLayout.show(); + control.getNodePricingUnits().forEach(nodePricingUnits => { + this.bind("patchStudy", nodePricingUnits, "patchNode"); + }); }; unitsLoading(); - control = new osparc.study.StudyPricingUnits(); control.addListener("loadingUnits", () => unitsLoading()); control.addListener("unitsReady", () => unitsReady()); unitsBoxesLayout.add(control); From efaf769861932bc6a44914fcbb4aa3f6aaf5253b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 13:58:27 +0100 Subject: [PATCH 14/18] patch study false --- .../client/source/class/osparc/dashboard/TemplateBrowser.js | 1 + .../client/source/class/osparc/study/StudyOptions.js | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 451937330a7..f0b1cd46dd4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -140,6 +140,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { this._showLoadingPage(this.tr("Creating ") + (templateData.name || osparc.product.Utils.getStudyAlias({firstUpperCase: true}))); const studyOptions = new osparc.study.StudyOptions(); + studyOptions.setPatchStudy(false); studyOptions.setStudyData(templateData); const win = osparc.study.StudyOptions.popUpInWindow(studyOptions); win.moveItUp(); diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index 97f39a7f673..5b0fd30cadb 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -246,8 +246,6 @@ qx.Class.define("osparc.study.StudyOptions", { osparc.data.Resources.fetch("studies", "getWallet", params) ]) .then(values => { - this.setPatchStudy(true); - const studyData = values[0]; this.setStudyData(studyData); From 099120f1ca1de351f46b332b89e903340440099b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 15:03:44 +0100 Subject: [PATCH 15/18] only if selection changed --- .../client/source/class/osparc/dashboard/TemplateBrowser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index f0b1cd46dd4..4a29337b763 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -183,7 +183,9 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { const nodeId = nodePricingUnits.getNodeId(); const pricingPlanId = nodePricingUnits.getPricingPlanId(); const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId(); - promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)); + if (selectedPricingUnitId) { + promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)); + } }) Promise.all(promises) From 8b39cccf63ceaf895cea2fa0ad64cf97c444eafb Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 15:14:26 +0100 Subject: [PATCH 16/18] minor --- .../client/source/class/osparc/dashboard/TemplateBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 4a29337b763..d66ba67ab21 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -186,7 +186,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { if (selectedPricingUnitId) { promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)); } - }) + }); Promise.all(promises) .then(() => { From 1cb601187cab41a8d7212173516e5e48a047653d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 15:25:00 +0100 Subject: [PATCH 17/18] mapping --- .../class/osparc/dashboard/TemplateBrowser.js | 29 ++++++++++++++----- .../class/osparc/study/StudyPricingUnits.js | 17 +++++++---- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index d66ba67ab21..f7b90b99604 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -140,6 +140,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { this._showLoadingPage(this.tr("Creating ") + (templateData.name || osparc.product.Utils.getStudyAlias({firstUpperCase: true}))); const studyOptions = new osparc.study.StudyOptions(); + // they will be patched once the study is created studyOptions.setPatchStudy(false); studyOptions.setStudyData(templateData); const win = osparc.study.StudyOptions.popUpInWindow(studyOptions); @@ -156,8 +157,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits(); win.close(); osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) - .then(studyData => { - const studyId = studyData["uuid"]; + .then(newStudyData => { + const studyId = newStudyData["uuid"]; const openCB = () => { this._hideLoadingPage(); }; @@ -172,18 +173,30 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { }; const promises = []; - if (studyData["name"] !== titleSelection) { - promises.push(osparc.study.StudyOptions.updateName(studyData, titleSelection)); + // patch the name + if (newStudyData["name"] !== titleSelection) { + promises.push(osparc.study.StudyOptions.updateName(newStudyData, titleSelection)); } + // patch the wallet if (walletSelection.length && walletSelection[0]["walletId"]) { const walletId = walletSelection[0]["walletId"]; - promises.push(osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId)); + promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId)); } - nodesPricingUnits.forEach(nodePricingUnits => { - const nodeId = nodePricingUnits.getNodeId(); - const pricingPlanId = nodePricingUnits.getPricingPlanId(); + // patch the pricing units + // the nodeIds are coming from the original template, they need to be mapped to the newStudy + const workbench = newStudyData["workbench"]; + const nodesIdsListed = []; + Object.keys(workbench).forEach(nodeId => { + const node = workbench[nodeId]; + if (osparc.study.StudyPricingUnits.includeInList(node)) { + nodesIdsListed.push(nodeId); + } + }); + nodesPricingUnits.forEach((nodePricingUnits, idx) => { const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId(); if (selectedPricingUnitId) { + const nodeId = nodesIdsListed[idx]; + const pricingPlanId = nodePricingUnits.getPricingPlanId(); promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)); } }); diff --git a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js index 99d6c4ffc6e..e3e8514fbaf 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyPricingUnits.js @@ -37,6 +37,12 @@ qx.Class.define("osparc.study.StudyPricingUnits", { "unitsReady": "qx.event.type.Event" }, + statics: { + includeInList: function(node) { + return !osparc.data.model.Node.isFrontend(node); + }, + }, + members: { __studyData: null, __nodePricingUnits: null, @@ -56,13 +62,12 @@ qx.Class.define("osparc.study.StudyPricingUnits", { const workbench = this.__studyData["workbench"]; Object.keys(workbench).forEach(nodeId => { const node = workbench[nodeId]; - if (osparc.data.model.Node.isFrontend(node)) { - return; + if (this.self().includeInList(node)) { + const nodePricingUnits = new osparc.study.NodePricingUnits(this.__studyData["uuid"], nodeId, node); + this.__nodePricingUnits.push(nodePricingUnits); + this._add(nodePricingUnits); + promises.push(nodePricingUnits.showPricingUnits()); } - const nodePricingUnits = new osparc.study.NodePricingUnits(this.__studyData["uuid"], nodeId, node); - this.__nodePricingUnits.push(nodePricingUnits); - this._add(nodePricingUnits); - promises.push(nodePricingUnits.showPricingUnits()); }); } Promise.all(promises) From 1175fec8f8569c167aaceb3f8080f3e2db130596 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 12 Nov 2024 15:35:42 +0100 Subject: [PATCH 18/18] update name on loading page --- .../source/class/osparc/dashboard/TemplateBrowser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index f7b90b99604..7f4f0362cab 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -137,7 +137,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { return; } - this._showLoadingPage(this.tr("Creating ") + (templateData.name || osparc.product.Utils.getStudyAlias({firstUpperCase: true}))); + const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true}); + this._showLoadingPage(this.tr("Creating ") + (templateData.name || studyAlias)); const studyOptions = new osparc.study.StudyOptions(); // they will be patched once the study is created @@ -152,10 +153,11 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { win.addListener("cancel", () => cancelStudyOptions()); studyOptions.addListener("cancel", () => cancelStudyOptions()); studyOptions.addListener("startStudy", () => { - const titleSelection = studyOptions.getChildControl("title-field").getValue(); + const newName = studyOptions.getChildControl("title-field").getValue(); const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection(); const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits(); win.close(); + this._showLoadingPage(this.tr("Creating ") + (newName || studyAlias)); osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) .then(newStudyData => { const studyId = newStudyData["uuid"]; @@ -174,8 +176,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { const promises = []; // patch the name - if (newStudyData["name"] !== titleSelection) { - promises.push(osparc.study.StudyOptions.updateName(newStudyData, titleSelection)); + if (newStudyData["name"] !== newName) { + promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName)); } // patch the wallet if (walletSelection.length && walletSelection[0]["walletId"]) {