Skip to content

Commit

Permalink
🐛🎨 [Frontend] Reduce number of (unnecessary) PATCH calls at Study open (
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Jan 9, 2025
1 parent 7e31592 commit 0963820
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ qx.Class.define("osparc.data.Resources", {
method: "POST",
url: statics.API + "/tags"
},
put: {
patch: {
method: "PATCH",
url: statics.API + "/tags/{tagId}"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ qx.Class.define("osparc.data.model.Node", {
event: "changeServiceUrl"
},

thumbnail: {
check: "String",
nullable: true,
init: ""
},

portsConnected: {
check: "Array",
init: [],
Expand Down Expand Up @@ -421,9 +415,12 @@ qx.Class.define("osparc.data.model.Node", {

__getInputUnits: function() {
if (this.isPropertyInitialized("propsForm") && this.getPropsForm()) {
return this.getPropsForm().getChangedXUnits();
const changedUnits = this.getPropsForm().getChangedXUnits();
if (Object.keys(changedUnits).length) {
return changedUnits;
}
}
return {};
return null;
},

getInput: function(inputId) {
Expand Down Expand Up @@ -478,9 +475,6 @@ qx.Class.define("osparc.data.model.Node", {
}
this.populateInputOutputData(nodeData);
this.populateStates(nodeData);
if (nodeData.thumbnail) {
this.setThumbnail(nodeData.thumbnail);
}
if (nodeData.bootOptions) {
this.setBootOptions(nodeData.bootOptions);
}
Expand Down Expand Up @@ -1254,7 +1248,6 @@ qx.Class.define("osparc.data.model.Node", {
inputAccess: this.getInputAccess(),
inputNodes: this.getInputNodes(),
inputsRequired: this.getInputsRequired(),
thumbnail: this.getThumbnail(),
bootOptions: this.getBootOptions()
};
if (!clean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,24 +790,33 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
this.__studyOptionsPage.getChildControl("button").show();
this.getChildControl("side-panel-right-tabs").setSelection([this.__studyOptionsPage]);

this.__studyOptionsPage.add(new osparc.info.StudyMedium(study), {
const scrollView = new qx.ui.container.Scroll();
const secondaryColumnStudyContent = new qx.ui.container.Composite(new qx.ui.layout.VBox(15)).set({
backgroundColor: "transparent"
});
scrollView.add(secondaryColumnStudyContent);
this.__studyOptionsPage.add(scrollView, {
flex: 1
});

secondaryColumnStudyContent.add(new osparc.info.StudyMedium(study), {
flex: 1
});

this.__studyOptionsPage.add(this.__getSlideshowSection());
secondaryColumnStudyContent.add(this.__getSlideshowSection());

this.__studyOptionsPage.add(this.__getAnnotationsSection());
secondaryColumnStudyContent.add(this.__getAnnotationsSection());

const snaps = this.__getSnapshotsSection();
snaps.exclude();
const isVCDisabled = osparc.utils.DisabledPlugins.isVersionControlDisabled();
snaps.setVisibility(isVCDisabled ? "excluded" : "visible");
this.__studyOptionsPage.add(snaps);
secondaryColumnStudyContent.add(snaps);

const iters = this.__getIterationsSection();
const isMMDisabled = osparc.utils.DisabledPlugins.isMetaModelingDisabled();
snaps.setVisibility(isMMDisabled ? "excluded" : "visible");
this.__studyOptionsPage.add(iters);
secondaryColumnStudyContent.add(iters);
},

__getSlideshowSection: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ qx.Class.define("osparc.form.tag.TagItem", {
saveButton.setFetching(true);
const tagsStore = osparc.store.Tags.getInstance();
if (this.isPropertyInitialized("id")) {
tagsStore.putTag(this.getId(), data)
tagsStore.patchTag(this.getId(), data)
.then(tag => this.setTag(tag))
.catch(console.error)
.finally(() => {
Expand Down Expand Up @@ -336,7 +336,7 @@ qx.Class.define("osparc.form.tag.TagItem", {
return {
name: name.trim(),
description: description ? description.trim() : "",
color: color
color: color,
};
},
__applyMode: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ qx.Class.define("osparc.share.Collaborators", {
switch (this._resourceType) {
case "study":
case "template":
canIShare = osparc.study.Utils.canIWrite(this._serializedDataCopy["accessRights"]);
canIShare = osparc.data.model.Study.canIWrite(this._serializedDataCopy["accessRights"]);
break;
case "service":
canIShare = osparc.service.Utils.canIWrite(this._serializedDataCopy["accessRights"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ qx.Class.define("osparc.store.Tags", {
.catch(console.error);
},

putTag: function(tagId, updateData) {
patchTag: function(tagId, updateData) {
const params = {
url: {
tagId
},
data: updateData
};
return osparc.data.Resources.getInstance().fetch("tags", "put", params)
return osparc.data.Resources.getInstance().fetch("tags", "patch", params)
.then(tagData => {
if ("accessRights" in tagData) {
// accessRights are not patched in this endpoint
delete tagData["accessRights"];
}
return this.__addToCache(tagData);
})
.catch(console.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ qx.Class.define("osparc.workbench.NodeUI", {

__createWindowLayout: function() {
const node = this.getNode();
if (node.getThumbnail()) {
this.setThumbnail(node.getThumbnail());
}

this.getChildControl("chips").show();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
// create nodes
const nodes = model.getNodes();
this.__renderNodes(nodes);
qx.ui.core.queue.Layout.flush();
this.__renderAnnotations(model.getStudy().getUi());
}
},
Expand All @@ -1154,7 +1153,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
nodeUI.addListenerOnce("appear", () => {
nNodesToRender--;
if (nNodesToRender === 0) {
// all nodes rendered
this.__renderEdges(nodes);

setTimeout(() => {
// move to position (0, 0)
this._workbenchLayoutScroll.scrollToX(0);
this._workbenchLayoutScroll.scrollToY(0);
}, 10);
}
}, this);
this._addNodeUIToWorkbench(nodeUI, node.getPosition());
Expand Down

0 comments on commit 0963820

Please sign in to comment.