Skip to content

Commit 17dfc14

Browse files
committed
get and select wallet
1 parent cfbbba9 commit 17dfc14

File tree

4 files changed

+27
-36
lines changed

4 files changed

+27
-36
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
121121

122122
const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
123123
if (walletsEnabled) {
124-
const params = {
125-
url: {
126-
studyId
127-
}
128-
};
129-
osparc.data.Resources.fetch("studies", "getWallet", params)
124+
osparc.store.Study.getInstance().getWallet(studyId)
130125
.then(wallet => {
131126
if (
132127
isStudyCreation ||
@@ -164,8 +159,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
164159
} else {
165160
openStudy();
166161
}
167-
})
168-
.catch(err => osparc.FlashMessenger.logError(err));
162+
});
169163
} else {
170164
openStudy();
171165
}

services/static-webserver/client/source/class/osparc/store/Study.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,27 @@ qx.Class.define("osparc.store.Study", {
172172
});
173173
},
174174

175+
getWallet: function(studyId) {
176+
const params = {
177+
url: {
178+
studyId
179+
}
180+
};
181+
return osparc.data.Resources.fetch("studies", "getWallet", params)
182+
.catch(err => osparc.FlashMessenger.logError(err));
183+
},
184+
185+
selectWallet: function(studyId, walletId) {
186+
const params = {
187+
url: {
188+
studyId,
189+
walletId,
190+
}
191+
};
192+
return osparc.data.Resources.fetch("studies", "selectWallet", params)
193+
.catch(err => osparc.FlashMessenger.logError(err));
194+
},
195+
175196
addTag: function(studyId, tagId) {
176197
const params = {
177198
url: {

services/static-webserver/client/source/class/osparc/study/BillingSettings.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,7 @@ qx.Class.define("osparc.study.BillingSettings", {
119119

120120
const walletSelector = this.getChildControl("wallet-selector");
121121

122-
const paramsGet = {
123-
url: {
124-
studyId: this.__studyData["uuid"]
125-
}
126-
};
127-
osparc.data.Resources.fetch("studies", "getWallet", paramsGet)
122+
osparc.store.Study.getInstance().getWallet(this.__studyData["uuid"])
128123
.then(wallet => {
129124
if (wallet) {
130125
this.__studyWalletId = wallet["walletId"];
@@ -275,13 +270,7 @@ qx.Class.define("osparc.study.BillingSettings", {
275270
__switchWallet: function(walletId) {
276271
const creditAccountBox = this.getChildControl("credit-account-box");
277272
creditAccountBox.setEnabled(false);
278-
const paramsPut = {
279-
url: {
280-
studyId: this.__studyData["uuid"],
281-
walletId
282-
}
283-
};
284-
osparc.data.Resources.fetch("studies", "selectWallet", paramsPut)
273+
osparc.store.Study.getInstance().selectWallet(this.__studyData["uuid"], walletId)
285274
.then(() => {
286275
this.__studyWalletId = walletId;
287276
const msg = this.tr("Credit Account saved");
@@ -291,7 +280,6 @@ qx.Class.define("osparc.study.BillingSettings", {
291280
if ("status" in err && err["status"] == 402) {
292281
osparc.study.Utils.extractDebtFromError(this.__studyData["uuid"], err);
293282
}
294-
osparc.FlashMessenger.logError(err);
295283
this.fireEvent("closeWindow");
296284
})
297285
.finally(() => {

services/static-webserver/client/source/class/osparc/study/StudyOptions.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,7 @@ qx.Class.define("osparc.study.StudyOptions", {
9696
},
9797

9898
updateWallet: function(studyId, walletId) {
99-
const params = {
100-
url: {
101-
studyId,
102-
walletId,
103-
}
104-
};
105-
return osparc.data.Resources.fetch("studies", "selectWallet", params)
106-
.catch(err => osparc.FlashMessenger.logError(err, qx.locale.Manager.tr("An issue occurred while selecting Credit Account")));
99+
return osparc.store.Study.getInstance().selectWallet(studyId, walletId);
107100
},
108101
},
109102

@@ -231,14 +224,9 @@ qx.Class.define("osparc.study.StudyOptions", {
231224
},
232225

233226
__fetchStudy: function(studyId) {
234-
const params = {
235-
url: {
236-
studyId
237-
}
238-
};
239227
Promise.all([
240228
osparc.store.Study.getInstance().getOne(studyId),
241-
osparc.data.Resources.fetch("studies", "getWallet", params)
229+
osparc.store.Study.getInstance().getWallet(studyId),
242230
])
243231
.then(values => {
244232
const studyData = values[0];

0 commit comments

Comments
 (0)