Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ qx.Class.define("osparc.data.model.Node", {
},

events: {
"updateStudyDocument": "qx.event.type.Event",
"projectDocumentChanged": "qx.event.type.Data",
"reloadModel": "qx.event.type.Event",
"retrieveInputs": "qx.event.type.Data",
Expand Down Expand Up @@ -490,6 +489,7 @@ qx.Class.define("osparc.data.model.Node", {
this.populateNodeUIData(nodeData);
// new place to store the position and marker
this.populateNodeUIData(nodeUiData);
this.listenToChanges();
})
.catch(err => {
console.log(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ qx.Class.define("osparc.data.model.Workbench", {
},

events: {
"updateStudyDocument": "qx.event.type.Event",
"projectDocumentChanged": "qx.event.type.Data",
"restartAutoSaveTimer": "qx.event.type.Event",
"pipelineChanged": "qx.event.type.Event",
"nodeAdded": "qx.event.type.Data",
"nodeRemoved": "qx.event.type.Data",
Expand Down Expand Up @@ -352,7 +350,6 @@ qx.Class.define("osparc.data.model.Workbench", {
return null;
}

this.fireEvent("restartAutoSaveTimer");
// create the node in the backend first
const params = {
url: {
Expand All @@ -368,7 +365,6 @@ qx.Class.define("osparc.data.model.Workbench", {
const resp = await osparc.data.Resources.fetch("studies", "addNode", params);
const nodeId = resp["node_id"];

this.fireEvent("restartAutoSaveTimer");
const node = this.__createNode(key, version, nodeId);
node.fetchMetadataAndPopulate()
.then(() => {
Expand All @@ -394,15 +390,10 @@ qx.Class.define("osparc.data.model.Workbench", {
},

__initNodeSignals: function(node) {
if (osparc.utils.Utils.eventDrivenPatch()) {
node.listenToChanges();
node.addListener("projectDocumentChanged", e => this.fireDataEvent("projectDocumentChanged", e.getData()), this);
}
node.addListener("projectDocumentChanged", e => this.fireDataEvent("projectDocumentChanged", e.getData()), this);
node.addListener("keyChanged", () => this.fireEvent("reloadModel"), this);
node.addListener("changeInputNodes", () => this.fireDataEvent("pipelineChanged"), this);
node.addListener("reloadModel", () => this.fireEvent("reloadModel"), this);
node.addListener("updateStudyDocument", () => this.fireEvent("updateStudyDocument"), this);

node.addListener("showInLogger", e => this.fireDataEvent("showInLogger", e.getData()), this);
node.addListener("retrieveInputs", e => this.fireDataEvent("retrieveInputs", e.getData()), this);
node.addListener("fileRequested", e => this.fireDataEvent("fileRequested", e.getData()), this);
Expand Down Expand Up @@ -633,7 +624,6 @@ qx.Class.define("osparc.data.model.Workbench", {
return;
}

this.fireEvent("restartAutoSaveTimer");
let node = this.getNode(nodeId);
if (node) {
// remove the node in the backend first
Expand All @@ -645,8 +635,6 @@ qx.Class.define("osparc.data.model.Workbench", {
},

__nodeRemoved: function(nodeId) {
this.fireEvent("restartAutoSaveTimer");

delete this.__nodes[nodeId];

// remove first the connected edges
Expand Down Expand Up @@ -955,82 +943,5 @@ qx.Class.define("osparc.data.model.Workbench", {
node.updateNodeFromPatch(nodePatches);
});
},

/**
* @deprecated This method is deprecated and will be removed in a future release.
* Please use `__deserialize` instead for deserializing workbench data.
* Migration: Replace calls to `__deserializeOld` with `__deserialize`.
*/
__deserializeOld: function(workbenchInitData, workbenchUIInitData) {
this.__deserializeNodesOld(workbenchInitData, workbenchUIInitData)
.then(() => {
this.__deserializeEdges(workbenchInitData);
workbenchInitData = null;
workbenchUIInitData = null;
this.setDeserialized(true);
});
},

__deserializeNodesOld: function(workbenchData, workbenchUIData = {}) {
const nodeIds = Object.keys(workbenchData);
const serviceMetadataPromises = [];
nodeIds.forEach(nodeId => {
const nodeData = workbenchData[nodeId];
serviceMetadataPromises.push(osparc.store.Services.getService(nodeData.key, nodeData.version));
});
return Promise.allSettled(serviceMetadataPromises)
.then(results => {
const missing = results.filter(result => result.status === "rejected" || result.value === null)
if (missing.length) {
const errorMsg = qx.locale.Manager.tr("Service metadata missing");
osparc.FlashMessenger.logError(errorMsg);
return;
}
const values = results.map(result => result.value);
// Create first all the nodes
for (let i=0; i<nodeIds.length; i++) {
const metadata = values[i];
const nodeId = nodeIds[i];
this.__createNodeOld(metadata, nodeId);
}

// Then populate them (this will avoid issues of connecting nodes that might not be created yet)
this.__populateNodesDataOld(workbenchData, workbenchUIData);
});
},

__createNodeOld: function(metadata, nodeId) {
const node = new osparc.data.model.Node(this.getStudy(), metadata["key"], metadata["version"], nodeId);
node.setMetadata(metadata);
if (osparc.utils.Utils.eventDrivenPatch()) {
node.listenToChanges();
node.addListener("projectDocumentChanged", e => this.fireDataEvent("projectDocumentChanged", e.getData()), this);
}
node.addListener("keyChanged", () => this.fireEvent("reloadModel"), this);
node.addListener("changeInputNodes", () => this.fireDataEvent("pipelineChanged"), this);
node.addListener("reloadModel", () => this.fireEvent("reloadModel"), this);
node.addListener("updateStudyDocument", () => this.fireEvent("updateStudyDocument"), this);
osparc.utils.Utils.localCache.serviceToFavs(metadata["key"]);

this.__initNodeSignals(node);
this.__addNode(node);

return node;
},

__populateNodesDataOld: function(workbenchData, workbenchUIData) {
Object.entries(workbenchData).forEach(([nodeId, nodeData]) => {
this.getNode(nodeId).populateNodeData(nodeData);

if ("position" in nodeData) {
// old place to store the position
this.getNode(nodeId).populateNodeUIData(nodeData);
}
if (workbenchUIData && "workbench" in workbenchUIData && nodeId in workbenchUIData["workbench"]) {
// new place to store the position and marker
this.getNode(nodeId).populateNodeUIData(workbenchUIData["workbench"][nodeId]);
}
});
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
__viewsStack: null,
__workbenchView: null,
__slideshowView: null,
__autoSaveTimer: null,
__savingTimer: null,
__studyEditorIdlingTracker: null,
__lastSyncedProjectDocument: null,
__lastSyncedProjectVersion: null,
Expand Down Expand Up @@ -267,10 +265,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
}
}

if (osparc.data.model.Study.canIWrite(study.getAccessRights())) {
this.__startAutoSaveTimer();
this.__startSavingTimer();
} else {
if (!osparc.data.model.Study.canIWrite(study.getAccessRights())) {
const msg = this.self().READ_ONLY_TEXT;
osparc.FlashMessenger.logAs(msg, "WARNING");
}
Expand All @@ -292,13 +287,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
this.nodeSelected(nodeId);
}, this);

if (osparc.utils.Utils.eventDrivenPatch()) {
study.listenToChanges(); // this includes the listener on the workbench and ui
study.addListener("projectDocumentChanged", e => this.projectDocumentChanged(e.getData()), this);
} else {
workbench.addListener("updateStudyDocument", () => this.updateStudyDocument());
workbench.addListener("restartAutoSaveTimer", () => this.__restartAutoSaveTimer());
}
study.listenToChanges(); // this includes the listener on the workbench and ui
study.addListener("projectDocumentChanged", e => this.projectDocumentChanged(e.getData()), this);

if (osparc.utils.DisabledPlugins.isRTCEnabled()) {
this.__listenToProjectDocument();
Expand Down Expand Up @@ -953,67 +943,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
},
// ------------------ IDLING TRACKER ------------------

// ------------------ AUTO SAVER ------------------
__startAutoSaveTimer: function() {
if (osparc.utils.Utils.eventDrivenPatch()) {
// If event driven patch is enabled, auto save is not needed
return;
}

// Save every 3 seconds
const timer = this.__autoSaveTimer = new qx.event.Timer(this.self().AUTO_SAVE_INTERVAL);
timer.addListener("interval", () => {
if (!osparc.wrapper.WebSocket.getInstance().isConnected()) {
return;
}
this.__checkStudyChanges();
}, this);
timer.start();
},

__stopAutoSaveTimer: function() {
if (this.__autoSaveTimer && this.__autoSaveTimer.isEnabled()) {
this.__autoSaveTimer.stop();
this.__autoSaveTimer.setEnabled(false);
}
},

__restartAutoSaveTimer: function() {
if (this.__autoSaveTimer && this.__autoSaveTimer.isEnabled()) {
this.__autoSaveTimer.restart();
}
},
// ------------------ AUTO SAVER ------------------

// ---------------- SAVING TIMER ------------------
__startSavingTimer: function() {
if (osparc.utils.Utils.eventDrivenPatch()) {
// If event driven patch is enabled, saving timer indicator is not needed
return;
}

const timer = this.__savingTimer = new qx.event.Timer(this.self().DIFF_CHECK_INTERVAL);
timer.addListener("interval", () => {
if (!osparc.wrapper.WebSocket.getInstance().isConnected()) {
return;
}
this.getStudy().setSavePending(this.didStudyChange());
}, this);
timer.start();
},

__stopSavingTimer: function() {
if (this.__savingTimer && this.__savingTimer.isEnabled()) {
this.__savingTimer.stop();
this.__savingTimer.setEnabled(false);
}
},
// ---------------- SAVING TIMER ------------------

__stopTimers: function() {
this.__stopIdlingTracker();
this.__stopAutoSaveTimer();
this.__stopSavingTimer();
},

__getStudyDiffs: function() {
Expand All @@ -1040,17 +971,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
return changed;
},

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

/**
* @param {JSON Patch} data It will soon be used to patch the project document https://datatracker.ietf.org/doc/html/rfc6902
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ qx.Class.define("osparc.node.BootOptionsView", {
"boot_mode": newBootModeId
};
node.setBootOptions(data);
node.fireEvent("updateStudyDocument");
node.fireDataEvent("projectDocumentChanged", {
"op": "replace",
"path": `/workbench/${nodeId}/bootOptions`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ qx.Class.define("osparc.node.LifeCycleView", {
newData["version"] = latestCompatible["version"];
}
node.set(newData);
node.fireEvent("updateStudyDocument");
const nodeId = node.getNodeId();
node.fireDataEvent("projectDocumentChanged", [{
"op": "replace",
"path": `/workbench/${nodeId}/key`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,6 @@ qx.Class.define("osparc.utils.Utils", {
return (["dev", "master"].includes(platformName));
},

eventDrivenPatch: function() {
return osparc.utils.DisabledPlugins.isRTCEnabled();
},

getEditButton: function(isVisible = true) {
return new qx.ui.form.Button(null, "@FontAwesome5Solid/pencil-alt/12").set({
appearance: "form-button-outlined",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {

nodeUI.addListener("dbltap", e => {
this.fireDataEvent("nodeSelected", nodeUI.getNodeId());
if (nodeUI.getNode().canNodeStart()) {
if (nodeUI.getNode().canNodeStart() && !nodeUI.getNode().getStudy().getDisableServiceAutoStart()) {
nodeUI.getNode().requestStartNode();
}
e.stopPropagation();
Expand Down
Loading