Skip to content

Commit 8e0f469

Browse files
committed
fetchVipModels from Store
1 parent 87512a2 commit 8e0f469

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ qx.Class.define("osparc.store.LicensedItems", {
2929
VIP_MODELS: {
3030
HUMAN_BODY: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanWholeBody",
3131
HUMAN_BODY_REGION: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanBodyRegion",
32-
ANIMAL_BODY: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/AnimalWholeBody",
32+
ANIMAL: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/AnimalWholeBody",
3333
PHANTOM: "https://speag.swiss/PD_DirectDownload/getDownloadableItems/ComputationalPhantom",
3434
},
3535

@@ -63,15 +63,15 @@ qx.Class.define("osparc.store.LicensedItems", {
6363
__modelsCache: null,
6464

6565
__fetchVipModels: async function(vipSubset) {
66-
if (!(vipSubset in this.VIP_MODELS)) {
66+
if (!(vipSubset in this.self().VIP_MODELS)) {
6767
return [];
6868
}
6969

7070
if (vipSubset in this.__modelsCache) {
7171
return this.__modelsCache[vipSubset];
7272
}
7373

74-
return await fetch(this.VIP_MODELS[vipSubset], {
74+
return await fetch(this.self().VIP_MODELS[vipSubset], {
7575
method:"POST"
7676
})
7777
.then(resp => resp.json())
@@ -85,7 +85,7 @@ qx.Class.define("osparc.store.LicensedItems", {
8585
anatomicalModel["name"] = model["Features"]["name"] + " " + model["Features"]["version"];
8686
anatomicalModel["description"] = model["Description"];
8787
anatomicalModel["features"] = model["Features"];
88-
anatomicalModel["date"] = new Date(model["Features"]["date"]);
88+
anatomicalModel["date"] = model["Features"]["date"];
8989
anatomicalModel["DOI"] = model["DOI"];
9090
anatomicalModels.push(anatomicalModel);
9191
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ qx.Class.define("osparc.vipMarket.Market", {
3333
category: "human",
3434
label: "Humans",
3535
icon: "@FontAwesome5Solid/users/20",
36-
url: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanWholeBody",
36+
vipSubset: "HUMAN_BODY",
3737
}, {
3838
category: "human_region",
3939
label: "Humans (Region)",
4040
icon: "@FontAwesome5Solid/users/20",
41-
url: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/HumanBodyRegion",
41+
vipSubset: "HUMAN_BODY_REGION",
4242
}, {
4343
category: "animal",
4444
label: "Animals",
4545
icon: "@FontAwesome5Solid/users/20",
46-
url: "https://itis.swiss/PD_DirectDownload/getDownloadableItems/AnimalWholeBody",
46+
vipSubset: "ANIMAL",
4747
}, {
4848
category: "phantom",
4949
label: "Phantoms",
5050
icon: "@FontAwesome5Solid/users/20",
51-
url: "https://speag.swiss/PD_DirectDownload/getDownloadableItems/ComputationalPhantom",
51+
vipSubset: "PHANTOM",
5252
}].forEach(marketInfo => {
5353
this.__buildViPMarketPage(marketInfo);
5454
});
@@ -76,7 +76,7 @@ qx.Class.define("osparc.vipMarket.Market", {
7676
__buildViPMarketPage: function(marketInfo) {
7777
const vipMarketView = new osparc.vipMarket.VipMarket();
7878
vipMarketView.set({
79-
metadataUrl: marketInfo["url"],
79+
vipSubset: marketInfo["vipSubset"],
8080
});
8181
this.bind("openBy", vipMarketView, "openBy");
8282
vipMarketView.addListener("importMessageSent", () => this.fireEvent("importMessageSent"));

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
3838
event: "changeOpenBy",
3939
},
4040

41-
metadataUrl: {
42-
check: "String",
41+
vipSubset: {
42+
check: ["HUMAN_BODY", "HUMAN_BODY_REGION", "ANIMAL", "PHANTOM"],
4343
init: null,
44-
nullable: false,
44+
nullable: true,
4545
apply: "__fetchModels",
46-
}
46+
},
4747
},
4848

4949
statics: {
@@ -192,14 +192,9 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
192192
}, this);
193193
},
194194

195-
__fetchModels: function(url) {
196-
fetch(url, {
197-
method:"POST"
198-
})
199-
.then(resp => resp.json())
200-
.then(anatomicalModelsRaw => {
201-
const allAnatomicalModels = this.self().curateAnatomicalModels(anatomicalModelsRaw);
202-
195+
__fetchModels: function(vipSubset) {
196+
osparc.store.LicensedItems.getInstance().fetchVipModels(vipSubset)
197+
.then(allAnatomicalModels => {
203198
const store = osparc.store.Store.getInstance();
204199
const contextWallet = store.getContextWallet();
205200
if (!contextWallet) {
@@ -221,17 +216,11 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
221216

222217
this.__anatomicalModels = [];
223218
allAnatomicalModels.forEach(model => {
224-
const modelId = model["ID"];
219+
const modelId = model["modelId"];
225220
const licensedItem = licensedItems.find(licItem => licItem["name"] == modelId);
226221
if (licensedItem) {
227-
const anatomicalModel = {};
228-
anatomicalModel["modelId"] = model["ID"];
229-
anatomicalModel["thumbnail"] = model["Thumbnail"];
230-
anatomicalModel["name"] = model["Features"]["name"] + " " + model["Features"]["version"];
231-
anatomicalModel["description"] = model["Description"];
232-
anatomicalModel["features"] = model["Features"];
233-
anatomicalModel["date"] = new Date(model["Features"]["date"]);
234-
anatomicalModel["DOI"] = model["DOI"];
222+
const anatomicalModel = osparc.utils.Utils.deepCloneObject(model);
223+
anatomicalModel["date"] = new Date(anatomicalModel["date"]);
235224
// attach license data
236225
anatomicalModel["licensedItemId"] = licensedItem["licensedItemId"];
237226
anatomicalModel["pricingPlanId"] = licensedItem["pricingPlanId"];

0 commit comments

Comments
 (0)