diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 0971a7d4990..2932a774c92 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -128,6 +128,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { control.getContentElement().setStyles({ "border-radius": `${osparc.dashboard.ListButtonItem.MENU_BTN_DIMENSIONS / 2}px` }); + osparc.utils.Utils.setIdToWidget(control, "folderItemMenuButton"); this._add(control, osparc.dashboard.FolderButtonBase.POS.MENU); break; } @@ -146,6 +147,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { folder.bind("name", this, "title"); folder.bind("lastModified", this, "lastModified"); + osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId()); + this.__addMenuButton(); }, @@ -211,11 +214,13 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { const moveToButton = new qx.ui.menu.Button(this.tr("Move to..."), "@FontAwesome5Solid/folder/12"); moveToButton.addListener("execute", () => this.fireDataEvent("moveFolderToRequested", this.getFolderId()), this); + osparc.utils.Utils.setIdToWidget(moveToButton, "moveFolderMenuItem"); menu.add(moveToButton); menu.addSeparator(); const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); + osparc.utils.Utils.setIdToWidget(deleteButton, "deleteFolderMenuItem"); deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this); menu.add(deleteButton); } @@ -264,6 +269,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { confirmText: this.tr("Delete"), confirmAction: "delete" }); + osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteFolderButton"); confirmationWin.center(); confirmationWin.open(); confirmationWin.addListener("close", () => { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js index 627ff5ccab9..6fe4c7d9bba 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js @@ -35,6 +35,8 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW); this.__buildLayout(); + + osparc.utils.Utils.setIdToWidget(this, "newFolderButton"); }, events: { 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 7f4f0362cab..3ff37cd8412 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -140,30 +140,89 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { 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 - studyOptions.setPatchStudy(false); - 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", () => { - 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)); + if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + 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); + win.moveItUp(); + const cancelStudyOptions = () => { + this._hideLoadingPage(); + win.close(); + } + win.addListener("cancel", () => cancelStudyOptions()); + studyOptions.addListener("cancel", () => cancelStudyOptions()); + studyOptions.addListener("startStudy", () => { + 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"]; + const openCB = () => { + this._hideLoadingPage(); + }; + const cancelCB = () => { + this._hideLoadingPage(); + const params = { + url: { + studyId + } + }; + osparc.data.Resources.fetch("studies", "delete", params); + }; + + const promises = []; + // patch the name + if (newStudyData["name"] !== newName) { + promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName)); + } + // patch the wallet + if (walletSelection.length && walletSelection[0]["walletId"]) { + const walletId = walletSelection[0]["walletId"]; + promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId)); + } + // 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)); + } + }); + + Promise.all(promises) + .then(() => { + win.close(); + const showStudyOptions = false; + this._startStudyById(studyId, openCB, cancelCB, showStudyOptions); + }); + }) + .catch(err => { + this._hideLoadingPage(); + osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR"); + console.error(err); + }); + }); + } else { osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage) .then(newStudyData => { const studyId = newStudyData["uuid"]; - const openCB = () => { - this._hideLoadingPage(); - }; + const openCB = () => this._hideLoadingPage(); const cancelCB = () => { this._hideLoadingPage(); const params = { @@ -173,49 +232,15 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { }; osparc.data.Resources.fetch("studies", "delete", params); }; - - const promises = []; - // patch the name - if (newStudyData["name"] !== newName) { - promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName)); - } - // patch the wallet - if (walletSelection.length && walletSelection[0]["walletId"]) { - const walletId = walletSelection[0]["walletId"]; - promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId)); - } - // 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)); - } - }); - - Promise.all(promises) - .then(() => { - win.close(); - const showStudyOptions = false; - this._startStudyById(studyId, openCB, cancelCB, showStudyOptions); - }); + 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/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index 4d5253410bf..187be3598e2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -127,6 +127,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { control.getContentElement().setStyles({ "border-radius": `${this.self().MENU_BTN_DIMENSIONS / 2}px` }); + osparc.utils.Utils.setIdToWidget(control, "workspaceItemMenuButton"); layout = this.getChildControl("header"); layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.HPOS.MENU); break; @@ -159,6 +160,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { workspace.bind("accessRights", this, "accessRights"); workspace.bind("modifiedAt", this, "modifiedAt"); workspace.bind("myAccessRights", this, "myAccessRights"); + + osparc.utils.Utils.setIdToWidget(this, "workspaceItem_" + workspace.getWorkspaceId()); }, __applyTitle: function(value) { @@ -201,6 +204,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { menu.addSeparator(); const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); + osparc.utils.Utils.setIdToWidget(deleteButton, "deleteWorkspaceMenuItem"); deleteButton.addListener("execute", () => this.__deleteWorkspaceRequested(), this); menu.add(deleteButton); @@ -254,6 +258,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { confirmText: this.tr("Delete"), confirmAction: "delete" }); + osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteWorkspaceButton"); confirmationWin.center(); confirmationWin.open(); confirmationWin.addListener("close", () => { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js index ac87579355e..dd65702503b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js @@ -43,6 +43,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", { opacity: 1 }); this.getChildControl("footer").exclude(); + + osparc.utils.Utils.setIdToWidget(this, "newWorkspaceButton"); }, events: { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js index 7f35c3ff320..e8914ca6166 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js @@ -137,6 +137,12 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { return isOpen; }, }, item, id); + }, + configureItem: item => { + item.addListener("changeModel", e => { + const model = e.getData(); + osparc.utils.Utils.setIdToWidget(item, `workspacesAndFoldersTreeItem_${model.getWorkspaceId()}_${model.getFolderId()}`); + }) } }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js index ccedd3b3b3d..13793622cb7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js @@ -29,8 +29,6 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", { this.setNotHoveredStyle(); this.__attachEventHandlers(); - - osparc.utils.Utils.setIdToWidget(this, "workspacesAndFoldersTreeItem"); }, members: { diff --git a/services/static-webserver/client/source/class/osparc/editor/FolderEditor.js b/services/static-webserver/client/source/class/osparc/editor/FolderEditor.js index 42d2013293f..4e8238d4f7f 100644 --- a/services/static-webserver/client/source/class/osparc/editor/FolderEditor.js +++ b/services/static-webserver/client/source/class/osparc/editor/FolderEditor.js @@ -60,6 +60,7 @@ qx.Class.define("osparc.editor.FolderEditor", { placeholder: this.tr("Title"), height: 27 }); + osparc.utils.Utils.setIdToWidget(control, "folderEditorTitle"); this.bind("label", control, "value"); control.bind("value", this, "label"); this._add(control); @@ -78,6 +79,7 @@ qx.Class.define("osparc.editor.FolderEditor", { this.fireEvent("createFolder"); } }, this); + osparc.utils.Utils.setIdToWidget(control, "folderEditorCreate"); buttons.addAt(control, 1); break; } @@ -94,6 +96,7 @@ qx.Class.define("osparc.editor.FolderEditor", { this.fireEvent("updateFolder"); } }, this); + osparc.utils.Utils.setIdToWidget(control, "folderEditorSave"); buttons.addAt(control, 1); break; } diff --git a/services/static-webserver/client/source/class/osparc/editor/WorkspaceEditor.js b/services/static-webserver/client/source/class/osparc/editor/WorkspaceEditor.js index dab5a9807c3..4e151d4e433 100644 --- a/services/static-webserver/client/source/class/osparc/editor/WorkspaceEditor.js +++ b/services/static-webserver/client/source/class/osparc/editor/WorkspaceEditor.js @@ -125,6 +125,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", { placeholder: this.tr("Title"), height: 30, }); + osparc.utils.Utils.setIdToWidget(control, "workspaceEditorTitle"); this.bind("label", control, "value"); control.bind("value", this, "label"); this._addAt(control, this.self().POS.TITLE); @@ -170,6 +171,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", { control = new osparc.ui.form.FetchButton(this.tr("Save")).set({ appearance: "form-button" }); + osparc.utils.Utils.setIdToWidget(control, "workspaceEditorSave"); control.addListener("execute", () => this.__saveWorkspace(control), this); buttons.addAt(control, 1); break;