Skip to content

Commit

Permalink
🐛 [Frontend] Service Browser and Service Catalog use the same function (
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Oct 30, 2024
1 parent f6a4e68 commit 5717c97
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,10 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
},

__loadServices: function() {
osparc.store.Services.getServicesLatest()
.then(servicesLatest => {
const servicesList = [];
Object.keys(servicesLatest).forEach(key => {
const serviceLatest = servicesLatest[key];
// do not show frontend services
if (key.includes("simcore/services/frontend/")) {
return;
}
// do not show retired services
if (servicesLatest[key]["retired"]) {
return;
}
servicesList.push(serviceLatest);
});
this.__setServicesToList(servicesList);
})
.catch(err => {
console.error(err);
this.__setServicesToList([]);
});
const excludeFrontend = true;
const excludeDeprecated = true
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
.then(servicesList => this.__setServicesToList(servicesList));
},

_updateServiceData: function(serviceData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ qx.Class.define("osparc.store.Services", {
getServicesLatest: function(useCache = true) {
return new Promise(resolve => {
if (useCache && Object.keys(this.servicesCached)) {
// give latest only
// return latest only
const latest = this.__getLatestCached();
resolve(latest);
return;
Expand All @@ -48,6 +48,45 @@ qx.Class.define("osparc.store.Services", {
});
},

getServicesLatestList: function(excludeFrontend = true, excludeDeprecated = true) {
return new Promise(resolve => {
const servicesList = [];
this.getServicesLatest()
.then(async servicesLatest => {
const serviceKeys = Object.keys(servicesLatest);
for (let i=0; i<serviceKeys.length; i++) {
const key = serviceKeys[i];
let serviceLatest = servicesLatest[key];
if (excludeFrontend && key.includes("simcore/services/frontend/")) {
// do not add frontend services
return;
}
if (excludeDeprecated && serviceLatest["retired"]) {
// first check if a previous version of this service isn't retired
let versions = Object.keys(this.servicesCached[key]);
versions = versions.sort(osparc.utils.Utils.compareVersionNumbers).reverse();
for (let j=0; j<versions.length; j++) {
const version = versions[j];
if (!this.servicesCached[key][version]["retired"]) {
serviceLatest = await this.getService(key, version);
break;
}
}
if (serviceLatest["retired"]) {
// do not add retired services
return;
}
}
servicesList.push(serviceLatest);
}
})
.catch(err => {
console.error(err);
})
.finally(() => resolve(servicesList));
});
},

getService: function(key, version, useCache = true) {
return new Promise(resolve => {
if (useCache && this.__isInCache(key, version)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ qx.Class.define("osparc.workbench.ServiceCatalog", {

__populateList: function() {
this.__servicesLatest = [];
osparc.store.Services.getServicesLatest()
.then(servicesLatest => {
Object.keys(servicesLatest).forEach(key => {
this.__servicesLatest.push(servicesLatest[key]);
});
const excludeFrontend = false;
const excludeDeprecated = true;
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
.then(servicesList => {
this.__servicesLatest = servicesList;
this.__updateList();
});
},
Expand Down

0 comments on commit 5717c97

Please sign in to comment.