From 6749447e2cd62fdde927ec5b74a3d5850cc8d517 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 7 Jan 2022 09:33:39 +0100 Subject: [PATCH 1/4] minor --- .../web/client/source/class/osparc/data/Resources.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/services/web/client/source/class/osparc/data/Resources.js b/services/web/client/source/class/osparc/data/Resources.js index cf6b5f79039..d751cc097aa 100644 --- a/services/web/client/source/class/osparc/data/Resources.js +++ b/services/web/client/source/class/osparc/data/Resources.js @@ -474,18 +474,6 @@ qx.Class.define("osparc.data.Resources", { } } }, - /* - * HEALTHCHECK - */ - "healthCheck": { - useCache: false, - endpoints: { - get: { - method: "GET", - url: statics.API + "/" - } - } - }, /* * AUTH */ From 7a85b8712bec0ba8fdec54e8f2dd8b0a1ad4356f Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 7 Jan 2022 09:33:50 +0100 Subject: [PATCH 2/4] update all services --- .../component/metadata/ServicesInStudy.js | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js index f1ad681ec20..3c6acff5ec1 100644 --- a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js +++ b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js @@ -96,6 +96,38 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { }); }, + __updateAllServices: function(nodeId, newVersion, button) { + this.setEnabled(false); + const workbench = this.__studyData["workbench"]; + for (const id in workbench) { + if (id === nodeId) { + workbench[nodeId]["version"] = newVersion; + } + } + + const params = { + url: { + "studyId": this.__studyData["uuid"] + }, + data: this.__studyData + }; + button.setFetching(true); + osparc.data.Resources.fetch("studies", "put", params) + .then(updatedData => { + this.fireDataEvent("updateServices", updatedData); + this.__studyData = osparc.data.model.Study.deepCloneStudyObject(updatedData); + this.__populateLayout(); + }) + .catch(err => { + osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("Something went wrong updating the Service"), "ERROR"); + console.error(err); + }) + .finally(() => { + button.setFetching(false); + this.setEnabled(true); + }); + }, + __populateLayout: function() { this._removeAll(); @@ -137,13 +169,24 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { row: i, column: this.self().gridPos.latestVersion }); + + const updateAllButton = new osparc.ui.form.FetchButton(this.tr("Update all"), "@MaterialIcons/update/14"); + updateAllButton.addListener("execute", () => this.__updateAllServices(updateAllButton), this); + this._add(updateAllButton, { + row: i, + column: this.self().gridPos.updateButton + }); + i++; + let allUpdatable = false; for (const nodeId in workbench) { const node = workbench[nodeId]; const nodeMetaData = osparc.utils.Services.getFromObject(this.__services, node["key"], node["version"]); const latestCompatibleMetadata = osparc.utils.Services.getLatestCompatible(this.__services, node["key"], node["version"]); + const updatable = node["version"] !== latestCompatibleMetadata["version"]; + allUpdatable = allUpdatable || updatable; const infoButton = new qx.ui.form.Button(null, "@MaterialIcons/info_outline/14"); infoButton.addListener("execute", () => { @@ -178,7 +221,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { const currentVersionLabel = new qx.ui.basic.Label(node["version"]).set({ font: "title-14", - backgroundColor: qx.theme.manager.Color.getInstance().resolve(node["version"] === latestCompatibleMetadata["version"] ? "ready-green" : "warning-yellow") + backgroundColor: qx.theme.manager.Color.getInstance().resolve(updatable ? "warning-yellow" : "ready-green") }); this._add(currentVersionLabel, { row: i, @@ -200,12 +243,10 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { if (osparc.data.Permissions.getInstance().canDo("study.service.update") && canIWrite) { const updateButton = new osparc.ui.form.FetchButton(null, "@MaterialIcons/update/14"); updateButton.set({ - label: node["version"] === latestCompatibleMetadata["version"] ? this.tr("Up-to-date") : this.tr("Update"), - enabled: node["version"] !== latestCompatibleMetadata["version"] + label: updatable ? this.tr("Update") : this.tr("Up-to-date"), + enabled: updatable }); - updateButton.addListener("execute", () => { - this.__updateService(nodeId, latestCompatibleMetadata["version"], updateButton); - }, this); + updateButton.addListener("execute", () => this.__updateService(nodeId, latestCompatibleMetadata["version"], updateButton), this); this._add(updateButton, { row: i, column: this.self().gridPos.updateButton @@ -214,6 +255,8 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { i++; } + + updateAllButton.setEnabled(allUpdatable); } } }); From e3938eed934aa840061fc32c9048856d38c6c9a7 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 7 Jan 2022 09:59:27 +0100 Subject: [PATCH 3/4] updateAllServices logic and refactoring --- .../component/metadata/ServicesInStudy.js | 56 +++++++------------ 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js index 3c6acff5ec1..8da4fa9b201 100644 --- a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js +++ b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js @@ -66,52 +66,34 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { __updateService: function(nodeId, newVersion, button) { this.setEnabled(false); - const workbench = this.__studyData["workbench"]; - for (const id in workbench) { + for (const id in this.__studyData["workbench"]) { if (id === nodeId) { - workbench[nodeId]["version"] = newVersion; + this.__studyData["workbench"][nodeId]["version"] = newVersion; } } - - const params = { - url: { - "studyId": this.__studyData["uuid"] - }, - data: this.__studyData - }; - button.setFetching(true); - osparc.data.Resources.fetch("studies", "put", params) - .then(updatedData => { - this.fireDataEvent("updateServices", updatedData); - this.__studyData = osparc.data.model.Study.deepCloneStudyObject(updatedData); - this.__populateLayout(); - }) - .catch(err => { - osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("Something went wrong updating the Service"), "ERROR"); - console.error(err); - }) - .finally(() => { - button.setFetching(false); - this.setEnabled(true); - }); + this.__updateStudy(button); }, - __updateAllServices: function(nodeId, newVersion, button) { + __updateAllServices: function(nodeIds, button) { this.setEnabled(false); - const workbench = this.__studyData["workbench"]; - for (const id in workbench) { - if (id === nodeId) { - workbench[nodeId]["version"] = newVersion; + for (const nodeId in this.__studyData["workbench"]) { + if (nodeIds.includes(nodeId)) { + const node = this.__studyData["workbench"][nodeId]; + const latestCompatibleMetadata = osparc.utils.Services.getLatestCompatible(this.__services, node["key"], node["version"]); + this.__studyData["workbench"][nodeId]["version"] = latestCompatibleMetadata; } } + this.__updateStudy(button); + }, + __updateStudy: function(fetchButton) { + fetchButton.setFetching(true); const params = { url: { "studyId": this.__studyData["uuid"] }, data: this.__studyData }; - button.setFetching(true); osparc.data.Resources.fetch("studies", "put", params) .then(updatedData => { this.fireDataEvent("updateServices", updatedData); @@ -123,7 +105,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { console.error(err); }) .finally(() => { - button.setFetching(false); + fetchButton.setFetching(false); this.setEnabled(true); }); }, @@ -170,8 +152,9 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { column: this.self().gridPos.latestVersion }); + const updatableServices = []; const updateAllButton = new osparc.ui.form.FetchButton(this.tr("Update all"), "@MaterialIcons/update/14"); - updateAllButton.addListener("execute", () => this.__updateAllServices(updateAllButton), this); + updateAllButton.addListener("execute", () => this.__updateAllServices(updatableServices, updateAllButton), this); this._add(updateAllButton, { row: i, column: this.self().gridPos.updateButton @@ -179,14 +162,15 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { i++; - let allUpdatable = false; for (const nodeId in workbench) { const node = workbench[nodeId]; const nodeMetaData = osparc.utils.Services.getFromObject(this.__services, node["key"], node["version"]); const latestCompatibleMetadata = osparc.utils.Services.getLatestCompatible(this.__services, node["key"], node["version"]); const updatable = node["version"] !== latestCompatibleMetadata["version"]; - allUpdatable = allUpdatable || updatable; + if (updatable) { + updatableServices.push(nodeId); + } const infoButton = new qx.ui.form.Button(null, "@MaterialIcons/info_outline/14"); infoButton.addListener("execute", () => { @@ -256,7 +240,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { i++; } - updateAllButton.setEnabled(allUpdatable); + updateAllButton.setEnabled(updatableServices.length); } } }); From 77bb6e3c6a47609b2cf04a645b8210553c6c623d Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 7 Jan 2022 10:56:15 +0100 Subject: [PATCH 4/4] minor fix --- .../class/osparc/component/metadata/ServicesInStudy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js index 8da4fa9b201..e8df47d254c 100644 --- a/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js +++ b/services/web/client/source/class/osparc/component/metadata/ServicesInStudy.js @@ -80,7 +80,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { if (nodeIds.includes(nodeId)) { const node = this.__studyData["workbench"][nodeId]; const latestCompatibleMetadata = osparc.utils.Services.getLatestCompatible(this.__services, node["key"], node["version"]); - this.__studyData["workbench"][nodeId]["version"] = latestCompatibleMetadata; + this.__studyData["workbench"][nodeId]["version"] = latestCompatibleMetadata["version"]; } } this.__updateStudy(button); @@ -165,7 +165,6 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { for (const nodeId in workbench) { const node = workbench[nodeId]; - const nodeMetaData = osparc.utils.Services.getFromObject(this.__services, node["key"], node["version"]); const latestCompatibleMetadata = osparc.utils.Services.getLatestCompatible(this.__services, node["key"], node["version"]); const updatable = node["version"] !== latestCompatibleMetadata["version"]; if (updatable) { @@ -194,6 +193,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { column: this.self().gridPos.label }); + const nodeMetaData = osparc.utils.Services.getFromObject(this.__services, node["key"], node["version"]); const nameLabel = new qx.ui.basic.Label(nodeMetaData["name"]).set({ font: "text-14", toolTipText: node["key"] @@ -240,7 +240,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", { i++; } - updateAllButton.setEnabled(updatableServices.length); + updateAllButton.setEnabled(Boolean(updatableServices.length)); } } });