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

Fixes: Annotations #2946

Merged
merged 8 commits into from
Apr 5, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ qx.Class.define("osparc.component.widget.NodeTreeItem", {
case "node-id": {
control = new qx.ui.basic.Label().set({
maxWidth: 70,
alignY: "middle"
alignY: "middle",
cursor: "copy"
});
control.addListener("tap", () => osparc.utils.Utils.copyTextToClipboard(this.getNodeId()));
this.bind("nodeId", control, "value", {
converter: value => value && value.substring(0, 8)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,13 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
const studyUI = model.getStudy().getUi();
const initData = studyUI.getAnnotationsInitData();
const annotations = initData ? initData : studyUI.getAnnotations();
Object.entries(annotations).forEach(([annotationId, annotation]) => this.__addAnnotation(annotation, annotationId));
Object.entries(annotations).forEach(([annotationId, annotation]) => {
if (annotation instanceof osparc.component.workbench.Annotation) {
this.__addAnnotation(annotation.serialize(), annotationId);
} else {
this.__addAnnotation(annotation, annotationId);
}
});
if (initData) {
studyUI.nullAnnotationsInitData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ qx.Class.define("osparc.data.model.StudyUI", {
workbench: studyDataUI && studyDataUI.workbench ? studyDataUI.workbench : this.getWorkbench(),
slideshow: new osparc.data.model.Slideshow(studyDataUI && studyDataUI.slideshow ? studyDataUI.slideshow : this.getSlideshow()),
currentNodeId: studyDataUI && studyDataUI.currentNodeId ? studyDataUI.currentNodeId : this.initCurrentNodeId(),
mode: studyDataUI && studyDataUI.mode ? studyDataUI.mode : this.initMode()
mode: studyDataUI && studyDataUI.mode ? studyDataUI.mode : this.initMode(),
annotations: {}
});

if ("annotations" in studyDataUI) {
Expand Down
26 changes: 12 additions & 14 deletions services/web/client/source/class/osparc/desktop/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,23 @@ qx.Class.define("osparc.desktop.MainPage", {
}
},

__backToDashboard: function() {
__backToDashboard: async function() {
const dashboardBtn = this.__navBar.getChildControl("dashboard-button");
dashboardBtn.setFetching(true);
if (this.__studyEditor.didStudyChange()) {
await this.__studyEditor.updateStudyDocument(false);
}
const studyId = this.__studyEditor.getStudy().getUuid();
this.__studyEditor.updateStudyDocument(false)
this.__studyEditor.closeEditor();
this.__showDashboard();
this.__dashboard.getStudyBrowser().invalidateStudies();
this.__dashboard.getStudyBrowser().reloadResources();
this.__dashboard.getStudyBrowser().resetSelection();
this.__dashboard.getStudyBrowser().reloadStudy(studyId)
.then(() => {
this.__studyEditor.closeEditor();
this.__showDashboard();
this.__dashboard.getStudyBrowser().invalidateStudies();
this.__dashboard.getStudyBrowser().reloadResources();
this.__dashboard.getStudyBrowser().resetSelection();
this.__dashboard.getStudyBrowser().reloadStudy(studyId)
.then(() => {
this.__closeStudy(studyId);
});
})
.finally(() => {
dashboardBtn.setFetching(false);
this.__closeStudy(studyId);
});
dashboardBtn.setFetching(false);
},

__createMainStack: function() {
Expand Down
23 changes: 15 additions & 8 deletions services/web/client/source/class/osparc/desktop/StudyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
study.buildWorkbench();
study.openStudy()
.then(() => {
this.__lastSavedStudy = study.serialize();

this.__workbenchView.setStudy(study);
this.__slideshowView.setStudy(study);

Expand Down Expand Up @@ -540,7 +542,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
timer.start();
},

__checkStudyChanges: function() {
didStudyChange: function() {
const newObj = this.getStudy().serialize();
const diffPatcher = osparc.wrapper.JsonDiffPatch.getInstance();
const delta = diffPatcher.diff(this.__lastSavedStudy, newObj);
Expand All @@ -557,13 +559,18 @@ qx.Class.define("osparc.desktop.StudyEditor", {
}
});

if (deltaKeys.length > 0) {
if (this.__updatingStudy > 0) {
// throttle update
this.__updateThrottled = true;
} else {
this.updateStudyDocument(false);
}
return deltaKeys.length;
}
return false;
},

__checkStudyChanges: function() {
if (this.didStudyChange()) {
if (this.__updatingStudy > 0) {
// throttle update
this.__updateThrottled = true;
} else {
this.updateStudyDocument(false);
}
}
},
Expand Down