From 5717c973ba50ae83ae7f67eb6e882a848d3c8057 Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:11:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[Frontend]=20Service=20Browser?= =?UTF-8?q?=20and=20Service=20Catalog=20use=20the=20same=20function=20(#66?= =?UTF-8?q?38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../class/osparc/dashboard/ServiceBrowser.js | 25 ++--------- .../source/class/osparc/store/Services.js | 41 ++++++++++++++++++- .../class/osparc/workbench/ServiceCatalog.js | 10 ++--- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js index a84549d1a5b..15278743e54 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js @@ -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) { diff --git a/services/static-webserver/client/source/class/osparc/store/Services.js b/services/static-webserver/client/source/class/osparc/store/Services.js index 1fb2c1b0959..569f5ce08e4 100644 --- a/services/static-webserver/client/source/class/osparc/store/Services.js +++ b/services/static-webserver/client/source/class/osparc/store/Services.js @@ -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; @@ -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 { + console.error(err); + }) + .finally(() => resolve(servicesList)); + }); + }, + getService: function(key, version, useCache = true) { return new Promise(resolve => { if (useCache && this.__isInCache(key, version)) { diff --git a/services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js b/services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js index a1b4db10cb1..a82a513cd3d 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js +++ b/services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js @@ -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(); }); },