Skip to content

Commit

Permalink
🎨 [Frontend] ViP Market: Cache pricing units (#7248)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Feb 19, 2025
1 parent 2eb5b0f commit 75ad9b0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,26 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
},

__addNewStudyItems: async function() {
await osparc.data.Resources.get("templates")
.then(templates => {
const plusButtonConfig = osparc.store.Products.getInstance().getPlusButtonUiConfig();
if (plusButtonConfig["categories"]) {
this.__addCategories(plusButtonConfig["categories"]);
}
plusButtonConfig["resources"].forEach(newStudyData => {
if (newStudyData["showDisabled"]) {
this.__addDisabledButton(newStudyData);
} else if (newStudyData["resourceType"] === "study") {
this.__addEmptyStudyButton(newStudyData);
} else if (newStudyData["resourceType"] === "template") {
this.__addFromTemplateButton(newStudyData, templates);
} else if (newStudyData["resourceType"] === "service") {
this.__addFromServiceButton(newStudyData);
const plusButtonConfig = osparc.store.Products.getInstance().getPlusButtonUiConfig();
if (plusButtonConfig) {
await osparc.data.Resources.get("templates")
.then(templates => {
if (plusButtonConfig["categories"]) {
this.__addCategories(plusButtonConfig["categories"]);
}
plusButtonConfig["resources"].forEach(newStudyData => {
if (newStudyData["showDisabled"]) {
this.__addDisabledButton(newStudyData);
} else if (newStudyData["resourceType"] === "study") {
this.__addEmptyStudyButton(newStudyData);
} else if (newStudyData["resourceType"] === "template") {
this.__addFromTemplateButton(newStudyData, templates);
} else if (newStudyData["resourceType"] === "service") {
this.__addFromServiceButton(newStudyData);
}
});
});
});
}
},

__getLastIdxFromCategory: function(categoryId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -949,13 +949,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {

__addPlusButtons: function() {
const plusButtonConfig = osparc.store.Products.getInstance().getNewStudiesUiConfig();
plusButtonConfig["resources"].forEach(newStudyData => {
if (newStudyData["resourceType"] === "study") {
this.__addEmptyStudyPlusButton(newStudyData);
} else if (newStudyData["resourceType"] === "service") {
this.__addNewStudyFromServiceButton(newStudyData);
}
});
if (plusButtonConfig) {
plusButtonConfig["resources"].forEach(newStudyData => {
if (newStudyData["resourceType"] === "study") {
this.__addEmptyStudyPlusButton(newStudyData);
} else if (newStudyData["resourceType"] === "service") {
this.__addNewStudyFromServiceButton(newStudyData);
}
});
}
},

__addEmptyStudyPlusButton: function(newStudyData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ qx.Class.define("osparc.store.Pricing", {
},

fetchPricingUnits: function(pricingPlanId) {
if (this.getPricingPlan(pricingPlanId)) {
return new Promise(resolve => resolve(this.getPricingPlan(pricingPlanId).getPricingUnits()));
}
const params = {
url: {
pricingPlanId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,6 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
this._add(pricingUnitsLayout);
pricingLayout.add(pricingUnitsLayout)

const poweredByLabel = new qx.ui.basic.Label().set({
font: "text-14",
padding: 10,
rich: true,
alignX: "center",
});
osparc.store.LicensedItems.getInstance().getLicensedItems()
.then(licensedItems => {
const lowerLicensedItems = osparc.store.LicensedItems.getLowerLicensedItems(licensedItems, licensedItemData["key"], licensedItemData["version"])
Expand All @@ -394,8 +388,14 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
text += `- ${osparc.store.LicensedItems.licensedResourceNameAndVersion(licensedResource)} <br>`;
});
})
poweredByLabel.setValue(text);
pricingLayout.add(poweredByLabel);
const bundleText = new qx.ui.basic.Label().set({
value: text,
font: "text-14",
padding: 10,
rich: true,
alignX: "center",
});
pricingLayout.add(bundleText);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ qx.Class.define("osparc.vipMarket.Market", {
freeCategory["items"].push(licensedItem);
}
}
this.__buildViPMarketPage(freeCategory, freeCategory["items"]);
if (freeCategory["items"].length) {
this.__buildViPMarketPage(freeCategory, freeCategory["items"]);
}
});
},

Expand Down

0 comments on commit 75ad9b0

Please sign in to comment.