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

🎨🐛 [Frontend] Reduce the initial number of patch calls #6641

Merged
merged 15 commits into from
Nov 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
if (filterData.text) {
this.__changeContext("search");
} else {
// Back to My Workspace
this.__changeContext("studiesAndFolders", null, null);
const workspaceId = this.getCurrentWorkspaceId();
const folderId = this.getCurrentFolderId();
this.__changeContext("studiesAndFolders", workspaceId, folderId);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,21 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
return control || this.base(arguments, id);
},

__titleTapped: function() {
const workspaceId = this.getCurrentWorkspaceId();
const folderId = null;
this.setCurrentFolderId(folderId);
this.fireDataEvent("locationChanged", {
workspaceId,
folderId,
});
},

__buildLayout: function() {
this.getChildControl("icon");
const title = this.getChildControl("workspace-title");
title.resetCursor();
title.removeListener("tap", this.__titleTapped, this);
this.getChildControl("breadcrumbs");
this.getChildControl("edit-button").exclude();
this.resetAccessRights();
Expand All @@ -198,27 +210,16 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
this.__setIcon("@FontAwesome5Solid/search/24");
title.set({
value: this.tr("Search results"),
cursor: "auto",
});
} else if (currentContext === "workspaces") {
this.__setIcon(osparc.store.Workspaces.iconPath(32));
title.set({
value: this.tr("Shared Workspaces"),
cursor: "auto",
})
} else if (currentContext === "studiesAndFolders") {
const workspaceId = this.getCurrentWorkspaceId();
title.set({
cursor: "pointer"
});
title.addListener("tap", () => {
const folderId = null;
this.setCurrentFolderId(folderId);
this.fireDataEvent("locationChanged", {
workspaceId,
folderId,
});
});
title.setCursor("pointer");
title.addListener("tap", this.__titleTapped, this);
const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId);
if (workspace) {
const thumbnail = workspace.getThumbnail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ qx.Class.define("osparc.data.model.Study", {

workspaceId: {
check: "Number",
init: true,
init: null,
nullable: true,
event: "changeWorkspaceId"
},

folderId: {
check: "Number",
init: true,
init: null,
nullable: true,
event: "changeFolderId"
},
Expand All @@ -103,9 +103,9 @@ qx.Class.define("osparc.data.model.Study", {

description: {
check: "String",
nullable: false,
nullable: true,
event: "changeDescription",
init: ""
init: null
},

prjOwner: {
Expand Down Expand Up @@ -356,11 +356,7 @@ qx.Class.define("osparc.data.model.Study", {
jsonObject[key] = this.getUi().serialize();
return;
}
const value = this.get(key);
if (value !== null) {
// only put the value in the payload if there is a value
jsonObject[key] = value;
}
jsonObject[key] = this.get(key);
});
return jsonObject;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,34 @@ qx.Class.define("osparc.widget.NodeOutputs", {
for (let i=0; i<portKeys.length; i++) {
const portKey = portKeys[i];
const value = (portKey in outputs && "value" in outputs[portKey]) ? outputs[portKey]["value"] : null;
if (value && typeof value === "object" && "store" in value && "eTag" in value) {
// it's a file in storage.
// check if the eTag changed before requesting the presigned link again
const eTag = value["eTag"];
const valueWidget = this.__getValueWidget(i);
if (eTag && valueWidget && valueWidget.eTag && eTag === valueWidget.eTag) {
continue;
}
}
this.__valueToGrid(value, i);
}
},

__getValueWidget: function(row) {
const children = this.__gridLayout.getChildren();
for (let i=0; i<children.length; i++) {
const child = children[i];
const layoutProps = child.getLayoutProperties();
if (
layoutProps.row === row &&
layoutProps.column === this.self().POS.VALUE
) {
return child;
}
}
return null;
},

__valueToGrid: function(value, row) {
let valueWidget = null;
if (value && typeof value === "object") {
Expand All @@ -179,6 +203,7 @@ qx.Class.define("osparc.widget.NodeOutputs", {
const fileId = value.path;
const filename = value.filename || osparc.file.FilePicker.getFilenameFromPath(value);
valueWidget.setValue(filename);
valueWidget.eTag = value["eTag"];
osparc.store.Data.getInstance().getPresignedLink(download, locationId, fileId)
.then(presignedLinkData => {
if ("resp" in presignedLinkData && presignedLinkData.resp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ qx.Class.define("osparc.workbench.DiskUsageController", {
let freeSpace = osparc.utils.Utils.bytesToSize(diskHostUsage.free);
let warningLevel = this.__getWarningLevel(diskHostUsage.free);

if ("STATE_VOLUMES" in data.usage) {
const diskVolsUsage = data.usage["STATE_VOLUMES"];
if ("STATES_VOLUMES" in data.usage) {
const diskVolsUsage = data.usage["STATES_VOLUMES"];
if (diskVolsUsage["used_percent"] > diskHostUsage["used_percent"]) {
// "STATE_VOLUMES" is more critical so it takes over
// "STATES_VOLUMES" is more critical so it takes over
freeSpace = osparc.utils.Utils.bytesToSize(diskVolsUsage.free);
warningLevel = this.__getWarningLevel(diskVolsUsage.free);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ qx.Class.define("osparc.workbench.DiskUsageIndicator", {
let progress = `${diskHostUsage["used_percent"]}%`;
let labelDiskSize = osparc.utils.Utils.bytesToSize(diskHostUsage.free);
let toolTipText = this.tr("Disk usage");
if ("STATE_VOLUMES" in diskUsage["usage"]) {
const diskVolsUsage = diskUsage["usage"]["STATE_VOLUMES"];
if ("STATES_VOLUMES" in diskUsage["usage"]) {
const diskVolsUsage = diskUsage["usage"]["STATES_VOLUMES"];
if (diskVolsUsage["used_percent"] > diskHostUsage["used_percent"]) {
// "STATE_VOLUMES" is more critical so it takes over
// "STATES_VOLUMES" is more critical so it takes over
color1 = this.__getIndicatorColor(diskVolsUsage.free);
progress = `${diskVolsUsage["used_percent"]}%`;
labelDiskSize = osparc.utils.Utils.bytesToSize(diskVolsUsage.free);
Expand Down
Loading