Skip to content
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

Update All services with one click #2721

Merged
merged 5 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +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;
}
}
this.__updateStudy(button);
},

__updateAllServices: function(nodeIds, button) {
this.setEnabled(false);
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["version"];
}
}
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);
Expand All @@ -91,7 +105,7 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", {
console.error(err);
})
.finally(() => {
button.setFetching(false);
fetchButton.setFetching(false);
this.setEnabled(true);
});
},
Expand Down Expand Up @@ -137,13 +151,25 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", {
row: i,
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(updatableServices, updateAllButton), this);
this._add(updateAllButton, {
row: i,
column: this.self().gridPos.updateButton
});

i++;

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) {
updatableServices.push(nodeId);
}

const infoButton = new qx.ui.form.Button(null, "@MaterialIcons/info_outline/14");
infoButton.addListener("execute", () => {
Expand All @@ -167,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"]
Expand All @@ -178,7 +205,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,
Expand All @@ -200,12 +227,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
Expand All @@ -214,6 +239,8 @@ qx.Class.define("osparc.component.metadata.ServicesInStudy", {

i++;
}

updateAllButton.setEnabled(Boolean(updatableServices.length));
}
}
});
12 changes: 0 additions & 12 deletions services/web/client/source/class/osparc/data/Resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,18 +474,6 @@ qx.Class.define("osparc.data.Resources", {
}
}
},
/*
* HEALTHCHECK
*/
"healthCheck": {
useCache: false,
endpoints: {
get: {
method: "GET",
url: statics.API + "/"
}
}
},
/*
* AUTH
*/
Expand Down