diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTable.js b/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTable.js index a757d6e3f2f..b506beca86d 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTable.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTable.js @@ -80,7 +80,7 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", { id: "user", column: 6, label: qx.locale.Manager.tr("User"), - width: 100 + width: 150 }, } } diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTableModel.js b/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTableModel.js index fe59f001d04..8aba01876d9 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTableModel.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/CheckoutsTableModel.js @@ -122,19 +122,16 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", { return Promise.all([ licensedItemsStore.getLicensedItems(), licensedItemsStore.getCheckedOutLicensedItems(walletId, urlParams), - licensedItemsStore.getVipModels(), ]) .then(values => { const licensedItems = values[0]; const checkoutsItems = values[1]; - const vipModels = values[2]; const data = []; const checkoutsCols = osparc.desktop.credits.CheckoutsTable.COLS; checkoutsItems.forEach(checkoutsItem => { const licensedItemId = checkoutsItem["licensedItemId"]; const licensedItem = licensedItems.find(licItem => licItem["licensedItemId"] === licensedItemId); - const vipModel = vipModels.find(vipMdl => licensedItem && (vipMdl["modelId"] == licensedItem["name"])); let start = ""; let duration = ""; if (checkoutsItem["startedAt"]) { @@ -146,11 +143,11 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", { data.push({ [checkoutsCols.CHECKOUT_ID.id]: checkoutsItem["licensedItemCheckoutId"], [checkoutsCols.ITEM_ID.id]: licensedItemId, - [checkoutsCols.ITEM_LABEL.id]: vipModel ? vipModel["name"] : "unknown model", + [checkoutsCols.ITEM_LABEL.id]: licensedItem ? licensedItem["displayName"] : "unknown model", [checkoutsCols.START.id]: start, [checkoutsCols.DURATION.id]: duration, [checkoutsCols.SEATS.id]: checkoutsItem["numOfSeats"], - [checkoutsCols.USER.id]: checkoutsItem["userId"], + [checkoutsCols.USER.id]: checkoutsItem["userEmail"], }); }); return data; diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTable.js b/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTable.js index 8cd31c0287c..8eeb4d7a28b 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTable.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTable.js @@ -87,7 +87,7 @@ qx.Class.define("osparc.desktop.credits.PurchasesTable", { id: "user", column: 7, label: qx.locale.Manager.tr("User"), - width: 100 + width: 150 }, } } diff --git a/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTableModel.js b/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTableModel.js index b1b054071ce..0792fb03180 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTableModel.js +++ b/services/static-webserver/client/source/class/osparc/desktop/credits/PurchasesTableModel.js @@ -121,28 +121,25 @@ qx.Class.define("osparc.desktop.credits.PurchasesTableModel", { return Promise.all([ licensedItemsStore.getLicensedItems(), licensedItemsStore.getPurchasedLicensedItems(walletId, urlParams), - licensedItemsStore.getVipModels(), ]) .then(values => { const licensedItems = values[0]; const purchasesItems = values[1]; - const vipModels = values[2]; const data = []; const purchasesCols = osparc.desktop.credits.PurchasesTable.COLS; purchasesItems.forEach(purchasesItem => { const licensedItemId = purchasesItem["licensedItemId"]; const licensedItem = licensedItems.find(licItem => licItem["licensedItemId"] === licensedItemId); - const vipModel = vipModels.find(vipMdl => licensedItem && (vipMdl["modelId"] == licensedItem["name"])); data.push({ [purchasesCols.PURCHASE_ID.id]: purchasesItem["licensedItemPurchaseId"], [purchasesCols.ITEM_ID.id]: licensedItemId, - [purchasesCols.ITEM_LABEL.id]: vipModel ? vipModel["name"] : "unknown model", + [purchasesCols.ITEM_LABEL.id]: licensedItem ? licensedItem["displayName"] : "unknown model", [purchasesCols.START.id]: osparc.utils.Utils.formatDateAndTime(new Date(purchasesItem["startAt"])), [purchasesCols.END.id]: osparc.utils.Utils.formatDateAndTime(new Date(purchasesItem["expireAt"])), [purchasesCols.SEATS.id]: purchasesItem["numOfSeats"], [purchasesCols.COST.id]: purchasesItem["pricingUnitCost"] ? ("-" + parseFloat(purchasesItem["pricingUnitCost"]).toFixed(2)) : "", // show it negative - [purchasesCols.USER.id]: purchasesItem["purchasedByUser"], + [purchasesCols.USER.id]: purchasesItem["userEmail"], }); }); return data; diff --git a/services/static-webserver/client/source/class/osparc/store/LicensedItems.js b/services/static-webserver/client/source/class/osparc/store/LicensedItems.js index 7e86d835d98..3aad7d40754 100644 --- a/services/static-webserver/client/source/class/osparc/store/LicensedItems.js +++ b/services/static-webserver/client/source/class/osparc/store/LicensedItems.js @@ -23,46 +23,10 @@ qx.Class.define("osparc.store.LicensedItems", { this.base(arguments); this.__licensedItems = null; - this.__modelsCache = {}; - }, - - statics: { - VIP_MODELS: { - HUMAN_BODY: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanWholeBody", - HUMAN_BODY_REGION: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanBodyRegion", - ANIMAL: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/AnimalWholeBody", - PHANTOM: "https://speag.swiss/PD_DirectDownload/getDownloadableItems/ComputationalPhantom", - }, - - curateAnatomicalModels: function(anatomicalModelsRaw) { - const anatomicalModels = []; - const models = anatomicalModelsRaw["availableDownloads"]; - models.forEach(model => { - const curatedModel = {}; - Object.keys(model).forEach(key => { - if (key === "Features") { - let featuresRaw = model["Features"]; - featuresRaw = featuresRaw.substring(1, featuresRaw.length-1); // remove brackets - featuresRaw = featuresRaw.split(","); // split the string by commas - const features = {}; - featuresRaw.forEach(pair => { // each pair is "key: value" - const keyValue = pair.split(":"); - features[keyValue[0].trim()] = keyValue[1].trim() - }); - curatedModel["Features"] = features; - } else { - curatedModel[key] = model[key]; - } - }); - anatomicalModels.push(curatedModel); - }); - return anatomicalModels; - }, }, members: { __licensedItems: null, - __modelsCache: null, getLicensedItems: function() { if (this.__licensedItems) { @@ -118,48 +82,5 @@ qx.Class.define("osparc.store.LicensedItems", { } return osparc.data.Resources.fetch("licensedItems", "checkouts", purchasesParams, options); }, - - __fetchVipModels: async function(vipSubset) { - if (!(vipSubset in this.self().VIP_MODELS)) { - return []; - } - - if (vipSubset in this.__modelsCache) { - return this.__modelsCache[vipSubset]; - } - - return await fetch(this.self().VIP_MODELS[vipSubset], { - method:"POST" - }) - .then(resp => resp.json()) - .then(anatomicalModelsRaw => { - const allAnatomicalModels = this.self().curateAnatomicalModels(anatomicalModelsRaw); - const anatomicalModels = []; - allAnatomicalModels.forEach(model => { - const anatomicalModel = {}; - anatomicalModel["modelId"] = model["ID"]; - anatomicalModel["thumbnail"] = model["Thumbnail"]; - anatomicalModel["name"] = model["Features"]["name"] + " " + model["Features"]["version"]; - anatomicalModel["description"] = model["Description"]; - anatomicalModel["features"] = model["Features"]; - anatomicalModel["date"] = model["Features"]["date"]; - anatomicalModel["DOI"] = model["DOI"]; - anatomicalModels.push(anatomicalModel); - }); - this.__modelsCache[vipSubset] = anatomicalModels; - return anatomicalModels; - }); - }, - - getVipModels: async function(vipSubset) { - const vipModels = this.self().VIP_MODELS; - if (vipSubset && vipSubset in vipModels) { - return await this.__fetchVipModels(vipSubset); - } - const promises = []; - Object.keys(vipModels).forEach(sbs => promises.push(this.__fetchVipModels(sbs))); - return await Promise.all(promises) - .then(values => values.flat()); - }, } }); diff --git a/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js b/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js index 5e1f87c81ee..1710d84bd44 100644 --- a/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js +++ b/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js @@ -24,7 +24,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", { const layout = new qx.ui.layout.VBox(15); this._setLayout(layout); - this.__poplulateLayout(); + this.__populateLayout(); }, events: { @@ -44,17 +44,17 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", { check: "Object", init: null, nullable: true, - apply: "__poplulateLayout" + apply: "__populateLayout" }, }, members: { - __poplulateLayout: function() { + __populateLayout: function() { this._removeAll(); const anatomicalModelsData = this.getAnatomicalModelsData(); if (anatomicalModelsData) { - const modelInfo = this.__createModelInfo(anatomicalModelsData); + const modelInfo = this.__createModelInfo(anatomicalModelsData["licensedResourceData"]); const pricingUnits = this.__createPricingUnits(anatomicalModelsData); const importButton = this.__createImportSection(anatomicalModelsData); this._add(modelInfo); @@ -77,7 +77,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", { const cardGrid = new qx.ui.layout.Grid(16, 16); const cardLayout = new qx.ui.container.Composite(cardGrid); - const description = anatomicalModelsData["description"]; + const description = anatomicalModelsData["description"] || ""; description.split(" - ").forEach((desc, idx) => { const titleLabel = new qx.ui.basic.Label().set({ value: desc, @@ -162,7 +162,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", { }); const doiValue = new qx.ui.basic.Label().set({ - value: anatomicalModelsData["DOI"] ? anatomicalModelsData["DOI"] : "-", + value: anatomicalModelsData["doi"] ? anatomicalModelsData["doi"] : "-", font: "text-14", alignX: "left", marginTop: 16, diff --git a/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelListItem.js b/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelListItem.js index ea3897841fa..415e7cc7517 100644 --- a/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelListItem.js +++ b/services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelListItem.js @@ -68,12 +68,12 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelListItem", { apply: "__applyThumbnail", }, - name: { + displayName: { check: "String", init: null, nullable: false, - event: "changeName", - apply: "__applyName", + event: "changeDisplayName", + apply: "__applyDisplayName", }, date: { @@ -157,7 +157,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelListItem", { this.getChildControl("thumbnail").setSource(value); }, - __applyName: function(value) { + __applyDisplayName: function(value) { this.getChildControl("name").setValue(value); }, diff --git a/services/static-webserver/client/source/class/osparc/vipMarket/Market.js b/services/static-webserver/client/source/class/osparc/vipMarket/Market.js index 2d88ab85ad8..451a86083a1 100644 --- a/services/static-webserver/client/source/class/osparc/vipMarket/Market.js +++ b/services/static-webserver/client/source/class/osparc/vipMarket/Market.js @@ -18,7 +18,7 @@ qx.Class.define("osparc.vipMarket.Market", { extend: osparc.ui.window.TabbedView, - construct: function(category) { + construct: function(openCategory) { this.base(arguments); const miniWallet = osparc.desktop.credits.BillingCenter.createMiniWalletView().set({ @@ -27,34 +27,54 @@ qx.Class.define("osparc.vipMarket.Market", { }); this.addWidgetOnTopOfTheTabs(miniWallet); - osparc.store.LicensedItems.getInstance().getLicensedItems() - .then(() => { - [{ - category: "human", + const store = osparc.store.Store.getInstance(); + const contextWallet = store.getContextWallet(); + if (!contextWallet) { + return; + } + + const walletId = contextWallet.getWalletId(); + const licensedItemsStore = osparc.store.LicensedItems.getInstance(); + Promise.all([ + licensedItemsStore.getLicensedItems(), + licensedItemsStore.getPurchasedLicensedItems(walletId), + ]) + .then(values => { + const licensedItems = values[0]; + const categories = {}; + licensedItems.forEach(licensedItem => { + if (licensedItem["licensedResourceData"] && licensedItem["licensedResourceData"]["category"]) { + const category = licensedItem["licensedResourceData"]["category"]; + if (!(category in categories)) { + categories[category] = []; + } + categories[category].push(licensedItem); + } + }); + + const expectedCategories = [{ + category: "HumanWholeBody", label: "Humans", icon: "@FontAwesome5Solid/users/20", - vipSubset: "HUMAN_BODY", }, { - category: "human_region", + category: "HumanBodyRegion", label: "Humans (Region)", icon: "@FontAwesome5Solid/users/20", - vipSubset: "HUMAN_BODY_REGION", }, { - category: "animal", + category: "AnimalWholeBody", label: "Animals", icon: "@FontAwesome5Solid/users/20", - vipSubset: "ANIMAL", }, { - category: "phantom", + category: "ComputationalPhantom", label: "Phantoms", icon: "@FontAwesome5Solid/users/20", - vipSubset: "PHANTOM", - }].forEach(marketInfo => { - this.__buildViPMarketPage(marketInfo); + }] + expectedCategories.forEach(expectedCategory => { + this.__buildViPMarketPage(expectedCategory, categories[expectedCategory["category"]]); }); - if (category) { - this.openCategory(category); + if (openCategory) { + this.openCategory(openCategory); } }); }, @@ -73,15 +93,15 @@ qx.Class.define("osparc.vipMarket.Market", { }, members: { - __buildViPMarketPage: function(marketInfo) { - const vipMarketView = new osparc.vipMarket.VipMarket(); + __buildViPMarketPage: function(marketTabInfo, licensedItems = []) { + const vipMarketView = new osparc.vipMarket.VipMarket(licensedItems); vipMarketView.set({ - vipSubset: marketInfo["vipSubset"], + category: marketTabInfo["category"], }); this.bind("openBy", vipMarketView, "openBy"); vipMarketView.addListener("importMessageSent", () => this.fireEvent("importMessageSent")); - const page = this.addTab(marketInfo["label"], marketInfo["icon"], vipMarketView); - page.category = marketInfo["category"]; + const page = this.addTab(marketTabInfo["label"], marketTabInfo["icon"], vipMarketView); + page.category = marketTabInfo["category"]; return page; }, diff --git a/services/static-webserver/client/source/class/osparc/vipMarket/VipMarket.js b/services/static-webserver/client/source/class/osparc/vipMarket/VipMarket.js index 77c633b01c4..bd9da478ba1 100644 --- a/services/static-webserver/client/source/class/osparc/vipMarket/VipMarket.js +++ b/services/static-webserver/client/source/class/osparc/vipMarket/VipMarket.js @@ -18,12 +18,16 @@ qx.Class.define("osparc.vipMarket.VipMarket", { extend: qx.ui.core.Widget, - construct: function() { + construct: function(anatomicalModels) { this.base(arguments); this._setLayout(new qx.ui.layout.HBox(10)); this.__buildLayout(); + + if (anatomicalModels) { + this.setLicensedItems(anatomicalModels); + } }, events: { @@ -38,11 +42,10 @@ qx.Class.define("osparc.vipMarket.VipMarket", { event: "changeOpenBy", }, - vipSubset: { - check: ["HUMAN_BODY", "HUMAN_BODY_REGION", "ANIMAL", "PHANTOM"], + category: { + check: ["HumanWholeBody", "HumanBodyRegion", "AnimalWholeBody", "ComputationalPhantom"], init: null, nullable: true, - apply: "__fetchModels", }, }, @@ -125,13 +128,13 @@ qx.Class.define("osparc.vipMarket.VipMarket", { const modelsUIList = this.getChildControl("models-list"); const anatomicalModelsModel = this.__anatomicalModelsModel = new qx.data.Array(); - const membersCtrl = new qx.data.controller.List(anatomicalModelsModel, modelsUIList, "name"); + const membersCtrl = new qx.data.controller.List(anatomicalModelsModel, modelsUIList, "displayName"); membersCtrl.setDelegate({ createItem: () => new osparc.vipMarket.AnatomicalModelListItem(), bindItem: (ctrl, item, id) => { ctrl.bindProperty("modelId", "modelId", null, item, id); ctrl.bindProperty("thumbnail", "thumbnail", null, item, id); - ctrl.bindProperty("name", "name", null, item, id); + ctrl.bindProperty("displayName", "displayName", null, item, id); ctrl.bindProperty("date", "date", null, item, id); ctrl.bindProperty("licensedItemId", "licensedItemId", null, item, id); ctrl.bindProperty("pricingPlanId", "pricingPlanId", null, item, id); @@ -165,103 +168,106 @@ qx.Class.define("osparc.vipMarket.VipMarket", { }, this); }, - __fetchModels: function(vipSubset) { + setLicensedItems: function(licensedItems) { + const store = osparc.store.Store.getInstance(); + const contextWallet = store.getContextWallet(); + if (!contextWallet) { + return; + } + const licensedItemsStore = osparc.store.LicensedItems.getInstance(); - licensedItemsStore.getVipModels(vipSubset) - .then(allAnatomicalModels => { - const store = osparc.store.Store.getInstance(); - const contextWallet = store.getContextWallet(); - if (!contextWallet) { - return; - } - const walletId = contextWallet.getWalletId(); - Promise.all([ - licensedItemsStore.getLicensedItems(), - licensedItemsStore.getPurchasedLicensedItems(walletId), - ]) - .then(values => { - const licensedItems = values[0]; - const purchasesItems = values[1]; - - this.__anatomicalModels = []; - allAnatomicalModels.forEach(model => { - const modelId = model["modelId"]; - const licensedItem = licensedItems.find(licItem => licItem["name"] == modelId); - if (licensedItem) { - const anatomicalModel = osparc.utils.Utils.deepCloneObject(model); - anatomicalModel["date"] = new Date(anatomicalModel["date"]); - // attach license data - anatomicalModel["licensedItemId"] = licensedItem["licensedItemId"]; - anatomicalModel["pricingPlanId"] = licensedItem["pricingPlanId"]; - // attach leased data - anatomicalModel["purchases"] = []; // default - const purchasesItemsFound = purchasesItems.filter(purchasesItem => purchasesItem["licensedItemId"] === licensedItem["licensedItemId"]); - if (purchasesItemsFound.length) { - purchasesItemsFound.forEach(purchasesItemFound => { - anatomicalModel["purchases"].push({ - expiresAt: new Date(purchasesItemFound["expireAt"]), - numberOfSeats: purchasesItemFound["numOfSeats"], - }) - }); - } - this.__anatomicalModels.push(anatomicalModel); - } + const walletId = contextWallet.getWalletId(); + licensedItemsStore.getPurchasedLicensedItems(walletId) + .then(purchasesItems => { + this.__anatomicalModels = []; + licensedItems.forEach(licensedItem => { + const anatomicalModel = osparc.utils.Utils.deepCloneObject(licensedItem); + anatomicalModel["modelId"] = licensedItem["licensedItemId"]; + anatomicalModel["thumbnail"] = ""; + anatomicalModel["date"] = null; + if (anatomicalModel["licensedResourceData"]) { + if (anatomicalModel["licensedResourceData"]["id"]) { + anatomicalModel["modelId"] = anatomicalModel["licensedResourceData"]["id"]; + } + if (anatomicalModel["licensedResourceData"]["thumbnail"]) { + anatomicalModel["thumbnail"] = anatomicalModel["licensedResourceData"]["thumbnail"]; + } + if ( + anatomicalModel["licensedResourceData"]["features"] && + anatomicalModel["licensedResourceData"]["features"]["date"] + ) { + anatomicalModel["date"] = new Date(anatomicalModel["licensedResourceData"]["features"]["date"]); + } + } + // attach license data + anatomicalModel["licensedItemId"] = licensedItem["licensedItemId"]; + anatomicalModel["pricingPlanId"] = licensedItem["pricingPlanId"]; + // attach leased data + anatomicalModel["purchases"] = []; // default + const purchasesItemsFound = purchasesItems.filter(purchasesItem => purchasesItem["licensedItemId"] === licensedItem["licensedItemId"]); + if (purchasesItemsFound.length) { + purchasesItemsFound.forEach(purchasesItemFound => { + anatomicalModel["purchases"].push({ + expiresAt: new Date(purchasesItemFound["expireAt"]), + numberOfSeats: purchasesItemFound["numOfSeats"], + }) }); + } + this.__anatomicalModels.push(anatomicalModel); + }); - this.__populateModels(); + this.__populateModels(); - const anatomicModelDetails = this.getChildControl("models-details"); - anatomicModelDetails.addListener("modelPurchaseRequested", e => { - if (!contextWallet) { - return; - } - const { - modelId, - licensedItemId, - pricingPlanId, - pricingUnitId, - } = e.getData(); - let numberOfSeats = null; - const pricingUnit = osparc.store.Pricing.getInstance().getPricingUnit(pricingPlanId, pricingUnitId); - if (pricingUnit) { - const split = pricingUnit.getName().split(" "); - numberOfSeats = parseInt(split[0]); + const anatomicModelDetails = this.getChildControl("models-details"); + anatomicModelDetails.addListener("modelPurchaseRequested", e => { + if (!contextWallet) { + return; + } + const { + modelId, + licensedItemId, + pricingPlanId, + pricingUnitId, + } = e.getData(); + let numberOfSeats = null; + const pricingUnit = osparc.store.Pricing.getInstance().getPricingUnit(pricingPlanId, pricingUnitId); + if (pricingUnit) { + const split = pricingUnit.getName().split(" "); + numberOfSeats = parseInt(split[0]); + } + licensedItemsStore.purchaseLicensedItem(licensedItemId, walletId, pricingPlanId, pricingUnitId, numberOfSeats) + .then(() => { + const expirationDate = osparc.study.PricingUnitLicense.getExpirationDate(); + const purchaseData = { + expiresAt: expirationDate, // get this info from the response + numberOfSeats, // get this info from the response + }; + + let msg = numberOfSeats; + msg += " seat" + (purchaseData["numberOfSeats"] > 1 ? "s" : ""); + msg += " rented until " + osparc.utils.Utils.formatDate(purchaseData["expiresAt"]); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + + const found = this.__anatomicalModels.find(model => model["modelId"] === modelId); + if (found) { + found["purchases"].push(purchaseData); + this.__populateModels(modelId); + anatomicModelDetails.setAnatomicalModelsData(found); } - licensedItemsStore.purchaseLicensedItem(licensedItemId, walletId, pricingPlanId, pricingUnitId, numberOfSeats) - .then(() => { - const expirationDate = osparc.study.PricingUnitLicense.getExpirationDate(); - const purchaseData = { - expiresAt: expirationDate, // get this info from the response - numberOfSeats, // get this info from the response - }; - - let msg = numberOfSeats; - msg += " seat" + (purchaseData["numberOfSeats"] > 1 ? "s" : ""); - msg += " rented until " + osparc.utils.Utils.formatDate(purchaseData["expiresAt"]); - osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); - - const found = this.__anatomicalModels.find(model => model["modelId"] === modelId); - if (found) { - found["purchases"].push(purchaseData); - this.__populateModels(modelId); - anatomicModelDetails.setAnatomicalModelsData(found); - } - }) - .catch(err => { - const msg = err.message || this.tr("Cannot purchase model"); - osparc.FlashMessenger.getInstance().logAs(msg, "ERROR"); - }); - }, this); - - anatomicModelDetails.addListener("modelImportRequested", e => { - const { - modelId - } = e.getData(); - this.__sendImportModelMessage(modelId); - }, this); - }); - }) - .catch(err => console.error(err)); + }) + .catch(err => { + const msg = err.message || this.tr("Cannot purchase model"); + osparc.FlashMessenger.getInstance().logAs(msg, "ERROR"); + }); + }, this); + + anatomicModelDetails.addListener("modelImportRequested", e => { + const { + modelId + } = e.getData(); + this.__sendImportModelMessage(modelId); + }, this); + }); }, __populateModels: function(selectModelId) { @@ -280,9 +286,9 @@ qx.Class.define("osparc.vipMarket.VipMarket", { if (sortBy["sort"] === "name") { if (sortBy["order"] === "down") { // A -> Z - return a["name"].localeCompare(b["name"]); + return a["displayName"].localeCompare(b["displayName"]); } - return b["name"].localeCompare(a["name"]); + return b["displayName"].localeCompare(a["displayName"]); } else if (sortBy["sort"] === "date") { if (sortBy["order"] === "down") { // Now -> Yesterday @@ -293,7 +299,7 @@ qx.Class.define("osparc.vipMarket.VipMarket", { } // default criteria // A -> Z - return a["name"].localeCompare(b["name"]); + return a["displayName"].localeCompare(b["displayName"]); }); }; sortModel();