Skip to content

Commit cbd09d3

Browse files
authored
Merge branch 'master' into pr-osparc-move-service-extras-to-catalog2
2 parents da32d4e + 9c1e764 commit cbd09d3

File tree

16 files changed

+1048
-192
lines changed

16 files changed

+1048
-192
lines changed

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,6 @@ qx.Class.define("osparc.data.Resources", {
936936
method: "PUT",
937937
url: statics.API + "/wallets/{walletId}/auto-recharge"
938938
},
939-
purchases: {
940-
method: "GET",
941-
url: statics.API + "/wallets/{walletId}/licensed-items-purchases"
942-
},
943939
}
944940
},
945941
/*
@@ -1300,10 +1296,18 @@ qx.Class.define("osparc.data.Resources", {
13001296
method: "GET",
13011297
url: statics.API + "/catalog/licensed-items?offset={offset}&limit={limit}"
13021298
},
1299+
purchases: {
1300+
method: "GET",
1301+
url: statics.API + "/wallets/{walletId}/licensed-items-purchases?offset={offset}&limit={limit}"
1302+
},
13031303
purchase: {
13041304
method: "POST",
13051305
url: statics.API + "/catalog/licensed-items/{licensedItemId}:purchase"
13061306
},
1307+
checkouts: {
1308+
method: "GET",
1309+
url: statics.API + "/wallets/{walletId}/licensed-items-checkouts?offset={offset}&limit={limit}"
1310+
},
13071311
}
13081312
}
13091313
};
@@ -1353,11 +1357,10 @@ qx.Class.define("osparc.data.Resources", {
13531357
res[endpoint](params.url || null, params.data || null);
13541358
}
13551359

1356-
res.addListenerOnce(endpoint + "Success", e => {
1360+
const successCB = e => {
13571361
const response = e.getRequest().getResponse();
13581362
const endpointDef = resourceDefinition.endpoints[endpoint];
13591363
const data = endpointDef.isJsonFile ? response : response.data;
1360-
const useCache = ("useCache" in endpointDef) ? endpointDef.useCache : resourceDefinition.useCache;
13611364
// OM: Temporary solution until the quality object is better defined
13621365
if (data && endpoint.includes("get") && ["studies", "templates"].includes(resource)) {
13631366
if (Array.isArray(data)) {
@@ -1368,6 +1371,8 @@ qx.Class.define("osparc.data.Resources", {
13681371
osparc.metadata.Quality.attachQualityToObject(data);
13691372
}
13701373
}
1374+
1375+
const useCache = ("useCache" in endpointDef) ? endpointDef.useCache : resourceDefinition.useCache;
13711376
if (useCache) {
13721377
if (endpoint.includes("delete") && resourceDefinition["deleteId"] && resourceDefinition["deleteId"] in params.url) {
13731378
const deleteId = params.url[resourceDefinition["deleteId"]];
@@ -1382,16 +1387,18 @@ qx.Class.define("osparc.data.Resources", {
13821387
}
13831388
}
13841389
}
1390+
13851391
res.dispose();
1392+
13861393
if ("resolveWResponse" in options && options.resolveWResponse) {
13871394
response.params = params;
13881395
resolve(response);
13891396
} else {
13901397
resolve(data);
13911398
}
1392-
}, this);
1399+
};
13931400

1394-
res.addListener(endpoint + "Error", e => {
1401+
const errorCB = e => {
13951402
if (e.getPhase() === "timeout") {
13961403
if (options.timeout && options.timeoutRetries) {
13971404
options.timeoutRetries--;
@@ -1445,8 +1452,12 @@ qx.Class.define("osparc.data.Resources", {
14451452
err.status = status;
14461453
}
14471454
reject(err);
1448-
});
1455+
};
14491456

1457+
const successEndpoint = endpoint + "Success";
1458+
const errorEndpoint = endpoint + "Error";
1459+
res.addListenerOnce(successEndpoint, e => successCB(e), this);
1460+
res.addListener(errorEndpoint, e => errorCB(e), this);
14501461
sendRequest();
14511462
});
14521463
},

services/static-webserver/client/source/class/osparc/desktop/credits/BillingCenter.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {
3333
if (osparc.data.Permissions.getInstance().canDo("usage.all.read")) {
3434
this.__usagePage = this.__addUsagePage();
3535
}
36+
37+
if (osparc.product.Utils.showS4LStore()) {
38+
this.__addPurchasesPage();
39+
this.__addCheckoutsPage();
40+
}
3641
},
3742

3843
statics: {
@@ -80,7 +85,7 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {
8085
},
8186

8287
__addTransactionsPage: function() {
83-
const title = this.tr("Transactions");
88+
const title = this.tr("Payments");
8489
const iconSrc = "@FontAwesome5Solid/exchange-alt/22";
8590
const transactions = this.__transactionsTable = new osparc.desktop.credits.Transactions();
8691
const page = this.addTab(title, iconSrc, transactions);
@@ -95,6 +100,22 @@ qx.Class.define("osparc.desktop.credits.BillingCenter", {
95100
return page;
96101
},
97102

103+
__addPurchasesPage: function() {
104+
const title = this.tr("Purchases");
105+
const iconSrc = "@FontAwesome5Solid/list/22";
106+
const purchases = new osparc.desktop.credits.Purchases();
107+
const page = this.addTab(title, iconSrc, purchases);
108+
return page;
109+
},
110+
111+
__addCheckoutsPage: function() {
112+
const title = this.tr("Checkouts");
113+
const iconSrc = "@FontAwesome5Solid/list/22";
114+
const purchases = new osparc.desktop.credits.Checkouts();
115+
const page = this.addTab(title, iconSrc, purchases);
116+
return page;
117+
},
118+
98119
openWallets: function() {
99120
if (this.__walletsPage) {
100121
return this._openPage(this.__walletsPage);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.desktop.credits.Checkouts", {
20+
extend: osparc.desktop.credits.ResourceInTableViewer,
21+
22+
members: {
23+
_createChildControlImpl: function(id) {
24+
let control;
25+
switch (id) {
26+
case "table": {
27+
const dateFilters = this.getChildControl("date-filters");
28+
control = new osparc.desktop.credits.CheckoutsTable(this._getSelectWalletId(), dateFilters.getValue()).set({
29+
marginTop: 10
30+
});
31+
const fetchingImage = this.getChildControl("fetching-image");
32+
control.getTableModel().bind("isFetching", fetchingImage, "visibility", {
33+
converter: isFetching => isFetching ? "visible" : "excluded"
34+
})
35+
this._add(control, { flex: 1 })
36+
break;
37+
}
38+
}
39+
return control || this.base(arguments, id);
40+
},
41+
42+
_buildLayout: function() {
43+
this.base(arguments);
44+
45+
this.getChildControl("export-button").exclude();
46+
},
47+
}
48+
});
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
20+
extend: qx.ui.table.Table,
21+
22+
construct: function(walletId, filters) {
23+
this.base(arguments);
24+
25+
const model = new osparc.desktop.credits.CheckoutsTableModel(walletId, filters);
26+
this.setTableModel(model);
27+
28+
this.set({
29+
statusBarVisible: false,
30+
headerCellHeight: 26,
31+
rowHeight: 26,
32+
});
33+
34+
const columnModel = this.getTableColumnModel();
35+
columnModel.setColumnVisible(this.self().COLS.CHECKOUT_ID.column, false);
36+
columnModel.setColumnVisible(this.self().COLS.ITEM_ID.column, false);
37+
38+
Object.values(this.self().COLS).forEach(col => columnModel.setColumnWidth(col.column, col.width));
39+
},
40+
41+
statics: {
42+
COLS: {
43+
CHECKOUT_ID: {
44+
id: "checkoutId",
45+
column: 0,
46+
label: qx.locale.Manager.tr("CheckoutId"),
47+
width: 150
48+
},
49+
ITEM_ID: {
50+
id: "itemId",
51+
column: 1,
52+
label: qx.locale.Manager.tr("ItemId"),
53+
width: 150
54+
},
55+
ITEM_LABEL: {
56+
id: "itemLabel",
57+
column: 2,
58+
label: qx.locale.Manager.tr("Name"),
59+
width: 150
60+
},
61+
START: {
62+
id: "start",
63+
column: 3,
64+
label: qx.locale.Manager.tr("Start"),
65+
width: 150
66+
},
67+
DURATION: {
68+
id: "duration",
69+
column: 4,
70+
label: qx.locale.Manager.tr("Duration"),
71+
width: 150
72+
},
73+
SEATS: {
74+
id: "seats",
75+
column: 5,
76+
label: qx.locale.Manager.tr("Seats"),
77+
width: 50
78+
},
79+
USER: {
80+
id: "user",
81+
column: 6,
82+
label: qx.locale.Manager.tr("User"),
83+
width: 100
84+
},
85+
}
86+
}
87+
});

0 commit comments

Comments
 (0)