Skip to content

Commit 9012c4d

Browse files
authored
🎨 [Frontend] Connect Anatomical modes to Licensed items (#6911)
1 parent 791d9d1 commit 9012c4d

29 files changed

+1310
-629
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ qx.Class.define("osparc.data.Resources", {
631631
* PRICING PLANS
632632
*/
633633
"pricingPlans": {
634-
useCache: true,
634+
useCache: false, // handled in osparc.store.Pricing
635635
endpoints: {
636636
get: {
637637
method: "GET",
@@ -656,7 +656,7 @@ qx.Class.define("osparc.data.Resources", {
656656
* PRICING UNITS
657657
*/
658658
"pricingUnits": {
659-
useCache: true,
659+
useCache: false, // handled in osparc.store.Pricing
660660
endpoints: {
661661
getOne: {
662662
method: "GET",
@@ -918,7 +918,11 @@ qx.Class.define("osparc.data.Resources", {
918918
putAutoRecharge: {
919919
method: "PUT",
920920
url: statics.API + "/wallets/{walletId}/auto-recharge"
921-
}
921+
},
922+
purchases: {
923+
method: "GET",
924+
url: statics.API + "/wallets/{walletId}/licensed-items-purchases"
925+
},
922926
}
923927
},
924928
/*
@@ -1247,6 +1251,27 @@ qx.Class.define("osparc.data.Resources", {
12471251
url: statics.API + "/tags/{tagId}"
12481252
}
12491253
}
1254+
},
1255+
1256+
/*
1257+
* LICENSED ITEMS
1258+
*/
1259+
"licensedItems": {
1260+
useCache: true,
1261+
endpoints: {
1262+
get: {
1263+
method: "GET",
1264+
url: statics.API + "/catalog/licensed-items"
1265+
},
1266+
getPage: {
1267+
method: "GET",
1268+
url: statics.API + "/catalog/licensed-items?offset={offset}&limit={limit}"
1269+
},
1270+
purchase: {
1271+
method: "POST",
1272+
url: statics.API + "/catalog/licensed-items/{licensedItemId}:purchase"
1273+
},
1274+
}
12501275
}
12511276
};
12521277
},
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 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+
* Class that stores PricingPlan data.
20+
*/
21+
22+
qx.Class.define("osparc.data.model.PricingPlan", {
23+
extend: qx.core.Object,
24+
25+
/**
26+
* @param pricingPlanData {Object} Object containing the serialized PricingPlan Data
27+
*/
28+
construct: function(pricingPlanData) {
29+
this.base(arguments);
30+
31+
this.set({
32+
pricingPlanId: pricingPlanData.pricingPlanId,
33+
pricingPlanKey: pricingPlanData.pricingPlanKey,
34+
classification: pricingPlanData.classification,
35+
name: pricingPlanData.displayName,
36+
description: pricingPlanData.description,
37+
isActive: pricingPlanData.isActive,
38+
pricingUnits: [],
39+
});
40+
41+
if (pricingPlanData.pricingUnits) {
42+
pricingPlanData.pricingUnits.forEach(pricingUnitData => {
43+
const pricingUnit = new osparc.data.model.PricingUnit(pricingUnitData);
44+
this.getPricingUnits().push(pricingUnit);
45+
});
46+
}
47+
},
48+
49+
properties: {
50+
pricingPlanId: {
51+
check: "Number",
52+
nullable: false,
53+
init: null,
54+
event: "changePricingPlanId"
55+
},
56+
57+
pricingPlanKey: {
58+
check: "String",
59+
nullable: true,
60+
init: null,
61+
event: "changePricingPlanKey"
62+
},
63+
64+
pricingUnits: {
65+
check: "Array",
66+
nullable: true,
67+
init: [],
68+
event: "changePricingunits"
69+
},
70+
71+
classification: {
72+
check: ["TIER", "LICENSE"],
73+
nullable: false,
74+
init: null,
75+
event: "changeClassification"
76+
},
77+
78+
name: {
79+
check: "String",
80+
nullable: false,
81+
init: null,
82+
event: "changeName"
83+
},
84+
85+
description: {
86+
check: "String",
87+
nullable: true,
88+
init: null,
89+
event: "changeDescription"
90+
},
91+
92+
isActive: {
93+
check: "Boolean",
94+
nullable: false,
95+
init: false,
96+
event: "changeIsActive"
97+
},
98+
},
99+
});
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 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+
* Class that stores PricingUnit data.
20+
*/
21+
22+
qx.Class.define("osparc.data.model.PricingUnit", {
23+
extend: qx.core.Object,
24+
25+
/**
26+
* @param pricingUnitData {Object} Object containing the serialized PricingUnit Data
27+
*/
28+
construct: function(pricingUnitData) {
29+
this.base(arguments);
30+
31+
this.set({
32+
pricingUnitId: pricingUnitData.pricingUnitId,
33+
name: pricingUnitData.unitName,
34+
cost: parseFloat(pricingUnitData.currentCostPerUnit),
35+
isDefault: pricingUnitData.default,
36+
extraInfo: pricingUnitData.unitExtraInfo,
37+
specificInfo: pricingUnitData.specificInfo || null,
38+
});
39+
},
40+
41+
properties: {
42+
pricingUnitId: {
43+
check: "Number",
44+
nullable: true,
45+
init: null,
46+
event: "changePricingUnitId"
47+
},
48+
49+
classification: {
50+
check: ["TIER", "LICENSE"],
51+
nullable: false,
52+
init: null,
53+
event: "changeClassification"
54+
},
55+
56+
name: {
57+
check: "String",
58+
nullable: false,
59+
init: null,
60+
event: "changeName"
61+
},
62+
63+
cost: {
64+
check: "Number",
65+
nullable: false,
66+
init: null,
67+
event: "changeCost"
68+
},
69+
70+
isDefault: {
71+
check: "Boolean",
72+
nullable: false,
73+
init: false,
74+
event: "changeIsDefault",
75+
},
76+
77+
extraInfo: {
78+
check: "Object",
79+
nullable: false,
80+
init: null,
81+
event: "changeExtraInfo",
82+
},
83+
84+
specificInfo: {
85+
check: "Object",
86+
nullable: true,
87+
init: null,
88+
event: "changeSpecificInfo",
89+
},
90+
},
91+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
752752
__iFrameChanged: function(node) {
753753
this.__iframePage.removeAll();
754754

755-
if (node) {
755+
if (node && node.getIFrame()) {
756756
const loadingPage = node.getLoadingPage();
757757
const iFrame = node.getIFrame();
758758
const src = iFrame.getSource();

services/static-webserver/client/source/class/osparc/navigation/UserMenu.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ qx.Class.define("osparc.navigation.UserMenu", {
112112
this.add(control);
113113
break;
114114
}
115-
case "license":
115+
case "license": {
116116
control = new qx.ui.menu.Button(this.tr("License"));
117117
osparc.utils.Utils.setIdToWidget(control, "userMenuLicenseBtn");
118118
const licenseURL = osparc.store.Support.getLicenseURL();
119119
control.addListener("execute", () => window.open(licenseURL));
120120
this.add(control);
121121
break;
122+
}
122123
case "tip-lite-button":
123124
control = new qx.ui.menu.Button(this.tr("Access Full TIP"));
124125
osparc.utils.Utils.setIdToWidget(control, "userMenuAccessTIPBtn");
@@ -237,7 +238,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
237238
this.addSeparator();
238239

239240
this.__addAnnouncements();
240-
241+
241242
if (osparc.product.Utils.showS4LStore()) {
242243
this.getChildControl("market");
243244
}

services/static-webserver/client/source/class/osparc/node/TierSelectionView.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,20 @@ qx.Class.define("osparc.node.TierSelectionView", {
4646
tiersLayout.add(tierBox);
4747

4848
const node = this.getNode();
49-
const plansParams = {
50-
url: osparc.data.Resources.getServiceUrl(
51-
node.getKey(),
52-
node.getVersion()
53-
)
54-
};
55-
const studyId = node.getStudy().getUuid();
56-
const nodeId = node.getNodeId();
57-
osparc.data.Resources.fetch("services", "pricingPlans", plansParams)
49+
const pricingStore = osparc.store.Pricing.getInstance();
50+
pricingStore.fetchPricingPlansService(node.getKey(), node.getVersion())
5851
.then(pricingPlans => {
5952
if (pricingPlans && "pricingUnits" in pricingPlans && pricingPlans["pricingUnits"].length) {
60-
const pUnits = pricingPlans["pricingUnits"];
61-
pUnits.forEach(pUnit => {
62-
const tItem = new qx.ui.form.ListItem(pUnit.unitName, null, pUnit.pricingUnitId);
53+
const pricingUnits = pricingPlans["pricingUnits"].map(princingUnitData => {
54+
const pricingUnit = new osparc.data.model.PricingUnit(princingUnitData);
55+
return pricingUnit;
56+
});
57+
pricingUnits.forEach(pricingUnit => {
58+
const tItem = new qx.ui.form.ListItem(pricingUnit.getName(), null, pricingUnit.getPricingUnitId());
6359
tierBox.add(tItem);
6460
});
61+
const studyId = node.getStudy().getUuid();
62+
const nodeId = node.getNodeId();
6563
const unitParams = {
6664
url: {
6765
studyId,
@@ -81,9 +79,9 @@ qx.Class.define("osparc.node.TierSelectionView", {
8179
})
8280
.finally(() => {
8381
const pUnitUIs = [];
84-
pUnits.forEach(pUnit => {
85-
const pUnitUI = new osparc.study.PricingUnit(pUnit).set({
86-
allowGrowX: false
82+
pricingUnits.forEach(pricingUnit => {
83+
const pUnitUI = new osparc.study.PricingUnitTier(pricingUnit).set({
84+
showEditButton: false,
8785
});
8886
pUnitUI.getChildControl("name").exclude();
8987
pUnitUI.exclude();

services/static-webserver/client/source/class/osparc/node/slideshow/NodeView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ qx.Class.define("osparc.node.slideshow.NodeView", {
143143
this._iFrameLayout.removeAll();
144144

145145
const node = this.getNode();
146-
if (node) {
146+
if (node && node.getIFrame()) {
147147
const loadingPage = node.getLoadingPage();
148148
const iFrame = node.getIFrame();
149149
const src = iFrame.getSource();

0 commit comments

Comments
 (0)