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 e2b2550ad7f..f82e1d3cf41 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -119,7 +119,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { osparc.desktop.MainPageHandler.getInstance().startStudy(studyId); }; - const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled(); + const walletsEnabled = osparc.store.StaticInfo.isBillableProduct(); if (walletsEnabled) { Promise.all([ osparc.store.Study.getInstance().getWallet(studyId), @@ -767,7 +767,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true}); this._showLoadingPage(this.tr("Creating ") + (templateData.name || studyAlias)); - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { const studyOptions = new osparc.study.StudyOptions(); // they will be patched once the study is created studyOptions.setPatchStudy(false); 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 d617ea8ddd6..2d803d732f4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js @@ -523,7 +523,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { }, __addBillingPage: function() { - if (!osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (!osparc.store.StaticInfo.isBillableProduct()) { return; } if (osparc.utils.Resources.isStudyLike(this.__resourceData) && !osparc.data.model.Study.canIWrite(this.__resourceData["accessRights"])) { 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 cd03aeac3cd..9c889a71b26 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -2074,7 +2074,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studyDataButton = this.__getStudyDataMenuButton(card); menu.add(studyDataButton); - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { const billingsSettingsButton = this.__getBillingMenuButton(card); menu.add(billingsSettingsButton); } diff --git a/services/static-webserver/client/source/class/osparc/desktop/MainPage.js b/services/static-webserver/client/source/class/osparc/desktop/MainPage.js index fd9045df2e5..7f3add4674b 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/MainPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/MainPage.js @@ -66,10 +66,10 @@ qx.Class.define("osparc.desktop.MainPage", { const store = osparc.store.Store.getInstance(); const preloadPromises = []; - const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled(); + const walletsEnabled = osparc.store.StaticInfo.isBillableProduct(); if (walletsEnabled) { - preloadPromises.push(store.reloadCreditPrice()); - preloadPromises.push(store.reloadWallets()); + preloadPromises.push(store.fetchCreditPrice()); + preloadPromises.push(store.fetchWallets()); } preloadPromises.push(store.getAllClassifiers(true)); preloadPromises.push(osparc.store.Tags.getInstance().fetchTags()); diff --git a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js index 7c70607500e..5a5a36ad7aa 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js +++ b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js @@ -29,7 +29,7 @@ qx.Class.define("osparc.desktop.account.MyAccount", { this.__profilePage = this.__addProfilePage(); // show Usage in My Account if wallets are not enabled. If they are enabled it will be in the BIlling Center - if (!osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (!osparc.store.StaticInfo.isBillableProduct()) { if (osparc.data.Permissions.getInstance().canDo("usage.all.read")) { this.__usagePage = this.__addUsagePage(); } diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/CurrentUsage.js b/services/static-webserver/client/source/class/osparc/desktop/credits/CurrentUsage.js index 48597eb99ef..e76be867bf1 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/CurrentUsage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/CurrentUsage.js @@ -39,7 +39,7 @@ qx.Class.define("osparc.desktop.credits.CurrentUsage", { members: { __currentStudyChanged: function(currentStudy) { - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { if (currentStudy) { const store = osparc.store.Store.getInstance(); const contextWallet = store.getContextWallet(); diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/ResourceInTableViewer.js b/services/static-webserver/client/source/class/osparc/desktop/credits/ResourceInTableViewer.js index 7b75887b846..0ad3fa58256 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/ResourceInTableViewer.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/ResourceInTableViewer.js @@ -122,7 +122,7 @@ qx.Class.define("osparc.desktop.credits.ResourceInTableViewer", { } }); - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { const store = osparc.store.Store.getInstance(); store.getWallets().forEach(wallet => { walletSelectBox.add(new qx.ui.form.ListItem(wallet.getName(), null, wallet)); @@ -136,7 +136,7 @@ qx.Class.define("osparc.desktop.credits.ResourceInTableViewer", { }, _getSelectWalletId: function() { - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { const walletSelectBox = this.getChildControl("wallet-selector"); const selectedWallet = walletSelectBox.getSelection()[0].getModel(); return selectedWallet.getWalletId(); diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/UsageTable.js b/services/static-webserver/client/source/class/osparc/desktop/credits/UsageTable.js index d08615d1a04..d023924dd09 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/UsageTable.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/UsageTable.js @@ -32,7 +32,7 @@ qx.Class.define("osparc.desktop.credits.UsageTable", { columnModel.setDataCellRenderer(this.self().COLS.COST.column, new qx.ui.table.cellrenderer.Number()); - if (!osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (!osparc.store.StaticInfo.isBillableProduct()) { columnModel.setColumnVisible(this.self().COLS.COST.column, false); columnModel.setColumnVisible(this.self().COLS.USER.column, false); } diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/Utils.js b/services/static-webserver/client/source/class/osparc/desktop/credits/Utils.js index a26cd6cb6f3..9acf3804237 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/Utils.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/Utils.js @@ -50,10 +50,6 @@ qx.Class.define("osparc.desktop.credits.Utils", { }; }, - areWalletsEnabled: function() { - return Boolean(osparc.store.StaticInfo.getValue("isPaymentEnabled")); - }, - getNoWriteAccessInformationLabel: function() { return new qx.ui.basic.Label().set({ value: qx.locale.Manager.tr("You can't access this information"), diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js index fcabd3892eb..2921bb8bde2 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js @@ -24,7 +24,7 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { this._setLayout(new qx.ui.layout.VBox(15)); - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { this.__addCreditsIndicatorSettings(); } @@ -33,7 +33,7 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { this.__addLowDiskSpaceSetting(); } - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { this.__addInactivitySetting(); } diff --git a/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js b/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js index 988b9f1b805..865166924b1 100644 --- a/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js @@ -152,7 +152,7 @@ qx.Class.define("osparc.info.ServiceLarge", { vBox.add(infoLayout); // Resources info if not billable - if (!osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (!osparc.store.StaticInfo.isBillableProduct()) { const resources = this.__createResources(); if (resources) { vBox.add(resources); diff --git a/services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js b/services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js index da0fa30810e..58eb2d49d9a 100644 --- a/services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js +++ b/services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js @@ -158,7 +158,7 @@ qx.Class.define("osparc.navigation.NavigationBar", { } this.getChildControl("notifications-button"); this.getChildControl("help-button"); - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { this.getChildControl("credits-button"); } this.getChildControl("log-in-button"); diff --git a/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js b/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js index 90e15c7caf2..c878c80a679 100644 --- a/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js +++ b/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js @@ -70,7 +70,7 @@ qx.Class.define("osparc.navigation.UserMenu", { control = new qx.ui.menu.Button(this.tr("Billing Center")); osparc.utils.Utils.setIdToWidget(control, "userMenuBillingCenterBtn"); control.addListener("execute", () => { - const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled(); + const walletsEnabled = osparc.store.StaticInfo.isBillableProduct(); if (walletsEnabled) { osparc.desktop.credits.BillingCenterWindow.openWindow(); } @@ -166,7 +166,7 @@ qx.Class.define("osparc.navigation.UserMenu", { if (osparc.data.Permissions.getInstance().isAdmin()) { this.getChildControl("admin-center"); } - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { this.getChildControl("billing-center"); } this.getChildControl("organizations"); @@ -222,7 +222,7 @@ qx.Class.define("osparc.navigation.UserMenu", { if (osparc.data.Permissions.getInstance().isAdmin()) { this.getChildControl("admin-center"); } - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { this.getChildControl("billing-center"); } this.getChildControl("organizations"); diff --git a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js index 5e10ea1838f..5e496254a91 100644 --- a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js +++ b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js @@ -282,7 +282,7 @@ qx.Class.define("osparc.notification.NotificationUI", { this.__openStudyDetails(resourceId, notification); break; case "WALLET_SHARED": { - const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled(); + const walletsEnabled = osparc.store.StaticInfo.isBillableProduct(); if (walletsEnabled) { this.__openWalletDetails(parseInt(resourceId)); } diff --git a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js index 0026d8b8779..04cad80d9d1 100644 --- a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js +++ b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js @@ -124,5 +124,9 @@ qx.Class.define("osparc.store.StaticInfo", { isDevFeaturesEnabled: function() { return this.getValue("webserverDevFeaturesEnabled"); }, + + isBillableProduct: function() { + return Boolean(this.getValue("isPaymentEnabled")); + }, } }); diff --git a/services/static-webserver/client/source/class/osparc/store/Store.js b/services/static-webserver/client/source/class/osparc/store/Store.js index c71816377da..0587cbf8c2d 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -436,7 +436,7 @@ qx.Class.define("osparc.store.Store", { return null; }, - reloadCreditPrice: function() { + fetchCreditPrice: function() { const store = osparc.store.Store.getInstance(); store.setCreditPrice(null); @@ -489,15 +489,22 @@ qx.Class.define("osparc.store.Store", { return 0; }, - reloadWallets: function() { + fetchWallets: function() { return new Promise((resolve, reject) => { osparc.data.Resources.fetch("wallets", "get") .then(walletsData => { + let personalWalletFound = false; const wallets = []; + const myGroupId = osparc.auth.Data.getInstance().getGroupId(); walletsData.forEach(walletReducedData => { + personalWalletFound = personalWalletFound || myGroupId === walletReducedData["owner"]; const wallet = new osparc.data.model.Wallet(walletReducedData); wallets.push(wallet); }); + if (!personalWalletFound) { + const msg = this.tr("No personal wallet found, some functionalities might not work properly. Please contact support."); + osparc.FlashMessenger.logAs(msg, "WARNING"); + } this.setWallets(wallets); // 1) fetch the access rights diff --git a/services/static-webserver/client/source/class/osparc/widget/NodeOptions.js b/services/static-webserver/client/source/class/osparc/widget/NodeOptions.js index 961b5cc337e..bce4381f8ef 100644 --- a/services/static-webserver/client/source/class/osparc/widget/NodeOptions.js +++ b/services/static-webserver/client/source/class/osparc/widget/NodeOptions.js @@ -54,7 +54,7 @@ qx.Class.define("osparc.widget.NodeOptions", { let showStartStopButton = false; // Tier Selection - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { const tierSelectionView = new osparc.node.TierSelectionView(node); sections.push(tierSelectionView); 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 226af8c5966..930246abf50 100644 --- a/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js +++ b/services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js @@ -327,7 +327,7 @@ qx.Class.define("osparc.widget.PersistentIframe", { break; } case "openWallets": { - if (osparc.desktop.credits.Utils.areWalletsEnabled()) { + if (osparc.store.StaticInfo.isBillableProduct()) { setTimeout(() => osparc.desktop.credits.BillingCenterWindow.openWindow(), 100); } break;