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] Patch study from Study Editor #5916

Merged
merged 65 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d793098
renaming
odeimaiz Jun 5, 2024
575acb7
getStudyChanges
odeimaiz Jun 5, 2024
f23280c
minor
odeimaiz Jun 5, 2024
8c68429
patchStudy expects array of changes
odeimaiz Jun 5, 2024
726225a
deprecate run argument
odeimaiz Jun 5, 2024
5e96bc1
minor
odeimaiz Jun 5, 2024
15825a5
__getStudyChanges
odeimaiz Jun 5, 2024
6fbdf5f
minor
odeimaiz Jun 5, 2024
88ccf26
fixes
odeimaiz Jun 5, 2024
9b16520
patchStudy expects object
odeimaiz Jun 5, 2024
f14f5d0
fix patch resolve
odeimaiz Jun 5, 2024
95779eb
do not call update anymore
odeimaiz Jun 5, 2024
3f4ec09
__studyDataToModel
odeimaiz Jun 5, 2024
2c1d1a5
minor
odeimaiz Jun 5, 2024
e5b48ec
more refactoring
odeimaiz Jun 5, 2024
fe69238
patchWorkbench
odeimaiz Jun 5, 2024
71f92aa
refactor
odeimaiz Jun 5, 2024
fdc07ab
minor
odeimaiz Jun 5, 2024
be45b46
more promises
odeimaiz Jun 5, 2024
ef81b48
deltaToPatchObj
odeimaiz Jun 5, 2024
8ada745
comments
odeimaiz Jun 5, 2024
75cf9de
patchStudy2
odeimaiz Jun 5, 2024
efaef36
minor
odeimaiz Jun 5, 2024
1dfaaa0
Merge branch 'master' into enh/patch-study
odeimaiz Jun 6, 2024
23be5fc
delayed patches
odeimaiz Jun 6, 2024
7a9b0b7
diffs, not changes
odeimaiz Jun 6, 2024
7985913
Merge branch 'master' into enh/patch-study
odeimaiz Jun 6, 2024
3b598c7
minor
odeimaiz Jun 6, 2024
f6b7056
patch only what changed
odeimaiz Jun 6, 2024
7e79f33
cleanup
odeimaiz Jun 6, 2024
3931db4
Merge branch 'master' into enh/patch-study
odeimaiz Jun 7, 2024
ac04252
patch only in master isDevelopmentPlatform
odeimaiz Jun 7, 2024
3210ed3
minor
odeimaiz Jun 7, 2024
1483715
Merge branch 'master' into enh/patch-study
odeimaiz Jun 7, 2024
ed075cb
minor fix
odeimaiz Jun 7, 2024
1283c72
minor
odeimaiz Jun 7, 2024
5d8b669
the change was that it was deleted
odeimaiz Jun 7, 2024
a1ae182
if workbenchDiffs is an array means that the node was either added or…
odeimaiz Jun 7, 2024
eea4731
@ignapas reviews
odeimaiz Jun 7, 2024
727de13
@ignapas reviews: less promises
odeimaiz Jun 7, 2024
c62d374
minor
odeimaiz Jun 10, 2024
ed1600e
minor
odeimaiz Jun 10, 2024
1b3b5a6
minor
odeimaiz Jun 10, 2024
07fc5cd
let the backend set the nodeId
odeimaiz Jun 10, 2024
8cb9490
Merge branch 'master' into enh/patch-study
odeimaiz Jun 17, 2024
10562b1
Merge branch 'master' into enh/patch-study
odeimaiz Jun 17, 2024
b79bf66
Merge branch 'enh/patch-study' of github.com:odeimaiz/osparc-simcore …
odeimaiz Jun 17, 2024
12c2afa
minor fix
odeimaiz Jun 17, 2024
93de249
Merge branch 'master' into enh/patch-study
odeimaiz Jun 19, 2024
1acf724
Merge branch 'enh/patch-study' of github.com:odeimaiz/osparc-simcore …
odeimaiz Jun 19, 2024
9a04366
Merge branch 'master' into enh/patch-study
odeimaiz Jul 2, 2024
28b748a
Merge branch 'master' into enh/patch-study
odeimaiz Jul 10, 2024
1e73fdf
Merge branch 'master' into enh/patch-study
odeimaiz Jul 11, 2024
452f96a
node_id
odeimaiz Jul 11, 2024
d0a0014
postRemoveNodeId
odeimaiz Jul 11, 2024
0cb8086
Merge branch 'master' into enh/patch-study
odeimaiz Jul 11, 2024
ae6fd22
minor
odeimaiz Jul 11, 2024
7f065e9
refactoring
odeimaiz Jul 11, 2024
ff4f47c
Merge branch 'enh/patch-study' of github.com:odeimaiz/osparc-simcore …
odeimaiz Jul 11, 2024
5c0b4a0
Merge branch 'master' into enh/patch-study
odeimaiz Jul 11, 2024
2ce4cb3
Merge branch 'master' into enh/patch-study
odeimaiz Jul 12, 2024
37bc617
no need to trigger the retrieve inputs calls chain if it's not dynamic
odeimaiz Jul 12, 2024
c48ba08
Merge branch 'master' into enh/patch-study
odeimaiz Jul 15, 2024
04e026f
minor
odeimaiz Jul 15, 2024
d316c7f
init studyDataInBackend
odeimaiz Jul 15, 2024
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 @@ -143,19 +143,19 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {


if (this.__tagButtons.length >= maxTags) {
const showAllButton = new qx.ui.form.Button(this.tr("Show all Tags..."), "@FontAwesome5Solid/tags/20");
const showAllButton = new qx.ui.form.Button(this.tr("All Tags..."), "@FontAwesome5Solid/tags/20");
showAllButton.set({
appearance: "filter-toggle-button"
});
showAllButton.showingAll = false;
showAllButton.addListener("execute", () => {
if (showAllButton.showingAll) {
this.__tagButtons.forEach((btn, idx) => btn.setVisibility(idx >= maxTags ? "excluded" : "visible"));
showAllButton.setLabel(this.tr("Show all Tags..."));
showAllButton.setLabel(this.tr("All Tags..."));
showAllButton.showingAll = false;
} else {
this.__tagButtons.forEach(btn => btn.setVisibility("visible"));
showAllButton.setLabel(this.tr("Show less Tags..."));
showAllButton.setLabel(this.tr("Less Tags..."));
showAllButton.showingAll = true;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ qx.Class.define("osparc.data.model.Study", {
this.setWorkbench(workbench);
workbench.setStudy(this);

this.setUi(new osparc.data.model.StudyUI(studyData.ui));
const workbenchUi = new osparc.data.model.StudyUI(studyData.ui);
this.setUi(workbenchUi);

this.getWorkbench().buildWorkbench();
},
Expand Down Expand Up @@ -316,6 +317,30 @@ qx.Class.define("osparc.data.model.Study", {
},

members: {
serialize: function(clean = true) {
let jsonObject = {};
const propertyKeys = this.self().getProperties();
propertyKeys.forEach(key => {
if (this.self().IgnoreSerializationProps.includes(key)) {
return;
}
if (key === "workbench") {
jsonObject[key] = this.getWorkbench().serialize(clean);
return;
}
if (key === "ui") {
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;
}
});
return jsonObject;
},

initStudy: function() {
this.getWorkbench().initWorkbench();
},
Expand Down Expand Up @@ -549,80 +574,80 @@ qx.Class.define("osparc.data.model.Study", {
return !this.getUi().getSlideshow().isEmpty();
},

serializeStudyData: function() {
let studyData = {};
const propertyKeys = this.self().getProperties();
propertyKeys.forEach(key => {
if (key === "workbench") {
studyData[key] = this.getWorkbench().serialize();
return;
}
if (key === "ui") {
studyData[key] = this.getUi().serialize();
return;
}
const value = this.get(key);
studyData[key] = value;
});
return studyData;
},

serialize: function(clean = true) {
let jsonObject = {};
const propertyKeys = this.self().getProperties();
propertyKeys.forEach(key => {
if (this.self().IgnoreSerializationProps.includes(key)) {
return;
}
if (key === "workbench") {
jsonObject[key] = this.getWorkbench().serialize(clean);
return;
}
if (key === "ui") {
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;
}
});
return jsonObject;
},

patchStudy: function(fieldKey, value) {
patchStudy: function(studyChanges) {
return new Promise((resolve, reject) => {
const patchData = {};
patchData[fieldKey] = value;
const params = {
url: {
"studyId": this.getUuid()
},
data: patchData
data: studyChanges
};
osparc.data.Resources.fetch("studies", "patch", params)
.then(() => {
const upKey = qx.lang.String.firstUp(fieldKey);
const setter = "set" + upKey;
this[setter](value);
Object.keys(studyChanges).forEach(fieldKey => {
const upKey = qx.lang.String.firstUp(fieldKey);
const setter = "set" + upKey;
this[setter](studyChanges[fieldKey]);
})
// A bit hacky, but it's not sent back to the backend
this.set({
lastChangeDate: new Date()
});
const studyData = this.serializeStudyData();
const studyData = this.serialize();
resolve(studyData);
})
.catch(err => reject(err));
});
},

updateStudy: function(params, run = false) {
/**
* Call patch Study, but the changes were already applied on the frontend
* @param studyDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
*/
patchStudyDelayed: function(studyDiffs) {
const promises = [];
let workbenchDiffs = {};
if ("workbench" in studyDiffs) {
workbenchDiffs = studyDiffs["workbench"];
promises.push(this.getWorkbench().patchWorkbenchDelayed(workbenchDiffs));
delete studyDiffs["workbench"];
}
const fieldKeys = Object.keys(studyDiffs);
if (fieldKeys.length) {
const patchData = {};
const params = {
url: {
"studyId": this.getUuid()
},
data: patchData
};
fieldKeys.forEach(fieldKey => {
if (fieldKey === "ui") {
patchData[fieldKey] = this.getUi().serialize();
} else {
const upKey = qx.lang.String.firstUp(fieldKey);
const getter = "get" + upKey;
patchData[fieldKey] = this[getter](studyDiffs[fieldKey]);
}
promises.push(osparc.data.Resources.fetch("studies", "patch", params))
});
}
return Promise.all(promises)
.then(() => {
// A bit hacky, but it's not sent back to the backend
this.set({
lastChangeDate: new Date()
});
const studyData = this.serialize();
return studyData;
});
},

updateStudy: function(params) {
return new Promise((resolve, reject) => {
osparc.data.Resources.fetch("studies", "put", {
url: {
"studyId": this.getUuid(),
run
"studyId": this.getUuid()
},
data: {
...this.serialize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ qx.Class.define("osparc.data.model.StudyUI", {
},

properties: {
// stores position and/or marker
workbench: {
check: "Object",
init: {},
Expand Down Expand Up @@ -103,6 +104,11 @@ qx.Class.define("osparc.data.model.StudyUI", {
}
},

removeNode: function(nodeId) {
// remove it from slideshow
this.getSlideshow().removeNode(nodeId);
},

serialize: function() {
const currentStudy = osparc.store.Store.getInstance().getCurrentStudy();
let jsonObject = {};
Expand Down
Loading
Loading