Skip to content

🎨🐛 [Frontend] Enh/fix: Services Pricing Plans #7412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 24, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
break;
}
}
});
})
.catch(err => osparc.FlashMessenger.logError(err));
},

events: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,42 @@ qx.Class.define("osparc.pricing.ServicesList", {
.then(data => this.__populateList(data));
},

__populateList: function(services) {
// before accessing the metadata in a sync way, we need to bring them to the cache
const metadataPromises = [];
services.forEach(service => {
__populateList: async function(services) {
const failedServices = [];
const servicePromises = services.map(async service => {
const key = service["serviceKey"];
const version = service["serviceVersion"];
metadataPromises.push(osparc.store.Services.getService(key, version));
});
Promise.all(metadataPromises)
.catch(err => console.error(err))
.finally(() => {
const sList = [];
services.forEach(service => {
const key = service["serviceKey"];
const version = service["serviceVersion"];
const serviceMetadata = osparc.store.Services.getMetadata(key, version);
if (serviceMetadata) {
sList.push(new osparc.data.model.Service(serviceMetadata));
}
try {
return await osparc.store.Services.getService(key, version);
} catch (err) {
console.error(err);
failedServices.push({
key: service["serviceKey"],
version: service["serviceVersion"],
});
const servicesList = this.getChildControl("services-list");
servicesList.setModel(new qx.data.Array(sList));
})
return null; // Return null to maintain array structure
}
});

const serviceModels = new qx.data.Array();
// ensure that even if one request fails, the rest continue executing
const results = await Promise.allSettled(servicePromises);
results.forEach(result => {
if (result.status === "fulfilled" && result.value) {
const serviceMetadata = result.value;
serviceModels.push(new osparc.data.model.Service(serviceMetadata));
}
});
const servicesList = this.getChildControl("services-list");
servicesList.setModel(serviceModels);

if (failedServices.length) {
let msg = "Could not retrieve data from some services:<br>";
failedServices.forEach(failedService => {
msg+= `- ${failedService.key}:${failedService.version}<br>`;
});
osparc.FlashMessenger.logAs(msg, "WARNING");
}
},

__openAddServiceToPlan: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ qx.Class.define("osparc.store.Services", {
},

getService: function(key, version, useCache = true) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
if (
useCache &&
this.__isInCache(key, version) &&
Expand All @@ -120,7 +120,10 @@ qx.Class.define("osparc.store.Services", {
this.__addToCache(service)
resolve(service);
})
.catch(console.error);
.catch(err => {
console.error(err);
reject();
});
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ qx.Class.define("osparc.ui.window.Window", {
resizable: true,
width: width,
minHeight: minHeight,
maxHeight: Math.max(minHeight, document.documentElement.clientHeight),
modal: true,
clickAwayClose: true
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ qx.Class.define("osparc.widget.StudyDataManager", {
if (!title) {
title = osparc.product.Utils.getStudyAlias({firstUpperCase: true}) + qx.locale.Manager.tr(" Files");
}
return osparc.ui.window.Window.popUpInWindow(studyDataManager, title, osparc.dashboard.ResourceDetails.WIDTH, osparc.dashboard.ResourceDetails.HEIGHT).set({
maxHeight: document.documentElement.clientHeight,
});
return osparc.ui.window.Window.popUpInWindow(studyDataManager, title, osparc.dashboard.ResourceDetails.WIDTH, osparc.dashboard.ResourceDetails.HEIGHT);
},
},

Expand Down
Loading