Skip to content

Commit 3f92306

Browse files
odeimaizmrnicegyu11
authored andcommitted
🎨 [Frontend] ViP Market: Cache pricing units (ITISFoundation#7248)
1 parent 4761147 commit 3f92306

File tree

5 files changed

+41
-32
lines changed

5 files changed

+41
-32
lines changed

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,26 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
160160
},
161161

162162
__addNewStudyItems: async function() {
163-
await osparc.data.Resources.get("templates")
164-
.then(templates => {
165-
const plusButtonConfig = osparc.store.Products.getInstance().getPlusButtonUiConfig();
166-
if (plusButtonConfig["categories"]) {
167-
this.__addCategories(plusButtonConfig["categories"]);
168-
}
169-
plusButtonConfig["resources"].forEach(newStudyData => {
170-
if (newStudyData["showDisabled"]) {
171-
this.__addDisabledButton(newStudyData);
172-
} else if (newStudyData["resourceType"] === "study") {
173-
this.__addEmptyStudyButton(newStudyData);
174-
} else if (newStudyData["resourceType"] === "template") {
175-
this.__addFromTemplateButton(newStudyData, templates);
176-
} else if (newStudyData["resourceType"] === "service") {
177-
this.__addFromServiceButton(newStudyData);
163+
const plusButtonConfig = osparc.store.Products.getInstance().getPlusButtonUiConfig();
164+
if (plusButtonConfig) {
165+
await osparc.data.Resources.get("templates")
166+
.then(templates => {
167+
if (plusButtonConfig["categories"]) {
168+
this.__addCategories(plusButtonConfig["categories"]);
178169
}
170+
plusButtonConfig["resources"].forEach(newStudyData => {
171+
if (newStudyData["showDisabled"]) {
172+
this.__addDisabledButton(newStudyData);
173+
} else if (newStudyData["resourceType"] === "study") {
174+
this.__addEmptyStudyButton(newStudyData);
175+
} else if (newStudyData["resourceType"] === "template") {
176+
this.__addFromTemplateButton(newStudyData, templates);
177+
} else if (newStudyData["resourceType"] === "service") {
178+
this.__addFromServiceButton(newStudyData);
179+
}
180+
});
179181
});
180-
});
182+
}
181183
},
182184

183185
__getLastIdxFromCategory: function(categoryId) {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -949,13 +949,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
949949

950950
__addPlusButtons: function() {
951951
const plusButtonConfig = osparc.store.Products.getInstance().getNewStudiesUiConfig();
952-
plusButtonConfig["resources"].forEach(newStudyData => {
953-
if (newStudyData["resourceType"] === "study") {
954-
this.__addEmptyStudyPlusButton(newStudyData);
955-
} else if (newStudyData["resourceType"] === "service") {
956-
this.__addNewStudyFromServiceButton(newStudyData);
957-
}
958-
});
952+
if (plusButtonConfig) {
953+
plusButtonConfig["resources"].forEach(newStudyData => {
954+
if (newStudyData["resourceType"] === "study") {
955+
this.__addEmptyStudyPlusButton(newStudyData);
956+
} else if (newStudyData["resourceType"] === "service") {
957+
this.__addNewStudyFromServiceButton(newStudyData);
958+
}
959+
});
960+
}
959961
},
960962

961963
__addEmptyStudyPlusButton: function(newStudyData) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ qx.Class.define("osparc.store.Pricing", {
8282
},
8383

8484
fetchPricingUnits: function(pricingPlanId) {
85+
if (this.getPricingPlan(pricingPlanId)) {
86+
return new Promise(resolve => resolve(this.getPricingPlan(pricingPlanId).getPricingUnits()));
87+
}
8588
const params = {
8689
url: {
8790
pricingPlanId,

‎services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,6 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
375375
this._add(pricingUnitsLayout);
376376
pricingLayout.add(pricingUnitsLayout)
377377

378-
const poweredByLabel = new qx.ui.basic.Label().set({
379-
font: "text-14",
380-
padding: 10,
381-
rich: true,
382-
alignX: "center",
383-
});
384378
osparc.store.LicensedItems.getInstance().getLicensedItems()
385379
.then(licensedItems => {
386380
const lowerLicensedItems = osparc.store.LicensedItems.getLowerLicensedItems(licensedItems, licensedItemData["key"], licensedItemData["version"])
@@ -394,8 +388,14 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
394388
text += `- ${osparc.store.LicensedItems.licensedResourceNameAndVersion(licensedResource)} <br>`;
395389
});
396390
})
397-
poweredByLabel.setValue(text);
398-
pricingLayout.add(poweredByLabel);
391+
const bundleText = new qx.ui.basic.Label().set({
392+
value: text,
393+
font: "text-14",
394+
padding: 10,
395+
rich: true,
396+
alignX: "center",
397+
});
398+
pricingLayout.add(bundleText);
399399
}
400400
});
401401

‎services/static-webserver/client/source/class/osparc/vipMarket/Market.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ qx.Class.define("osparc.vipMarket.Market", {
129129
freeCategory["items"].push(licensedItem);
130130
}
131131
}
132-
this.__buildViPMarketPage(freeCategory, freeCategory["items"]);
132+
if (freeCategory["items"].length) {
133+
this.__buildViPMarketPage(freeCategory, freeCategory["items"]);
134+
}
133135
});
134136
},
135137

0 commit comments

Comments
 (0)