Skip to content

Commit f16f786

Browse files
committed
minors
1 parent be4a895 commit f16f786

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

services/static-webserver/client/source/class/osparc/data/model/Node.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ qx.Class.define("osparc.data.model.Node", {
6464

6565
properties: {
6666
initState: {
67-
check: [null, "metadata", "populated"],
67+
check: [null, "metadataPopulated", "metadataMissing", "dataPopulated"],
6868
init: null,
6969
nullable: true,
7070
event: "changeInitState"
@@ -486,14 +486,22 @@ qx.Class.define("osparc.data.model.Node", {
486486
fetchMetadataAndPopulate: function(nodeData, nodeUiData) {
487487
this.__initNodeData = nodeData;
488488
this.__initNodeUiData = nodeUiData;
489-
this.getService(this.getKey(), this.getVersion())
489+
return osparc.store.Services.getService(this.getKey(), this.getVersion())
490490
.then(serviceMetadata => {
491491
this.populateWithMetadata(serviceMetadata);
492+
this.setInitState("metadataPopulated");
492493
this.populateNodeData(nodeData);
493494
// old place to store the position
494495
this.populateNodeUIData(nodeData);
495496
// new place to store the position and marker
496497
this.populateNodeUIData(nodeUiData);
498+
this.setInitState("dataPopulated");
499+
})
500+
.catch(err => {
501+
console.log(err);
502+
const errorMsg = qx.locale.Manager.tr("Service metadata missing");
503+
osparc.FlashMessenger.logError(errorMsg);
504+
this.setInitState("metadataMissing");
497505
});
498506
},
499507

@@ -520,7 +528,7 @@ qx.Class.define("osparc.data.model.Node", {
520528
this.setOutputs({});
521529
}
522530
}
523-
this.setInitState("metadata");
531+
this.setInitState("metadataPopulated");
524532
},
525533

526534
populateNodeData: function(nodeData) {
@@ -542,7 +550,6 @@ qx.Class.define("osparc.data.model.Node", {
542550
this.__initLogger();
543551
this.initIframeHandler();
544552
}
545-
this.setInitState("populated");
546553
},
547554

548555
populateNodeUIData: function(nodeUIData) {
@@ -736,8 +743,8 @@ qx.Class.define("osparc.data.model.Node", {
736743

737744
__setInputData: function(inputs) {
738745
if (this.__settingsForm && inputs) {
739-
const inputData = {};
740746
const inputLinks = {};
747+
const inputData = {};
741748
const inputsCopy = osparc.utils.Utils.deepCloneObject(inputs);
742749
for (let key in inputsCopy) {
743750
if (osparc.utils.Ports.isDataALink(inputsCopy[key])) {

services/static-webserver/client/source/class/osparc/data/model/Workbench.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ qx.Class.define("osparc.data.model.Workbench", {
106106
buildWorkbench: function() {
107107
this.__nodes = {};
108108
this.__edges = {};
109-
this.__deserialize(this.__workbenchInitData, this.__workbenchUIInitData);
110-
// this.__deserializeAll(this.__workbenchInitData, this.__workbenchUIInitData);
111-
// OM: isn't this handled later?
112-
this.__workbenchInitData = null;
113-
this.__workbenchUIInitData = null;
109+
const newWay = true;
110+
if (newWay) {
111+
this.__deserializeAll(this.__workbenchInitData, this.__workbenchUIInitData);
112+
this.__workbenchInitData = null;
113+
this.__workbenchUIInitData = null;
114+
} else {
115+
this.__deserialize(this.__workbenchInitData, this.__workbenchUIInitData);
116+
this.__workbenchInitData = null;
117+
this.__workbenchUIInitData = null;
118+
}
114119
},
115120

116121
// starts the dynamic services
@@ -286,7 +291,7 @@ qx.Class.define("osparc.data.model.Workbench", {
286291
node.addListener("changeInputNodes", () => this.fireDataEvent("pipelineChanged"), this);
287292
node.addListener("reloadModel", () => this.fireEvent("reloadModel"), this);
288293
node.addListener("updateStudyDocument", () => this.fireEvent("updateStudyDocument"), this);
289-
osparc.utils.Utils.localCache.serviceToFavs(metadata.key);
294+
osparc.utils.Utils.localCache.serviceToFavs(metadata["key"]);
290295

291296
this.__initNodeSignals(node);
292297
this.__addNode(node);
@@ -295,7 +300,7 @@ qx.Class.define("osparc.data.model.Workbench", {
295300
},
296301

297302
__deserializeNode: function(key, version, nodeId, nodeData, nodeUiData) {
298-
const node = osparc.data.model.Node(this.getStudy(), key, version, nodeId);
303+
const node = new osparc.data.model.Node(this.getStudy(), key, version, nodeId);
299304
node.fetchMetadataAndPopulate(nodeData, nodeUiData);
300305
if (osparc.utils.Utils.eventDrivenPatch()) {
301306
node.listenToChanges();
@@ -305,7 +310,7 @@ qx.Class.define("osparc.data.model.Workbench", {
305310
node.addListener("changeInputNodes", () => this.fireDataEvent("pipelineChanged"), this);
306311
node.addListener("reloadModel", () => this.fireEvent("reloadModel"), this);
307312
node.addListener("updateStudyDocument", () => this.fireEvent("updateStudyDocument"), this);
308-
osparc.utils.Utils.localCache.serviceToFavs(metadata.key);
313+
osparc.utils.Utils.localCache.serviceToFavs(key);
309314

310315
this.__initNodeSignals(node);
311316
this.__addNode(node);
@@ -732,20 +737,25 @@ qx.Class.define("osparc.data.model.Workbench", {
732737
});
733738
},
734739

735-
__deserializeAll: function(workbenchData, uiData = {}) {
740+
__deserializeAll: function(workbenchInitData, uiData = {}) {
736741
const nodeDatas = {};
737742
const nodeUiDatas = {};
738-
for (const nodeId in workbenchData) {
739-
const nodeData = workbenchData[nodeId];
743+
for (const nodeId in workbenchInitData) {
744+
const nodeData = workbenchInitData[nodeId];
740745
nodeDatas[nodeId] = nodeData;
741746
if (uiData["workbench"] && nodeId in uiData["workbench"]) {
742747
nodeUiDatas[nodeId] = uiData["workbench"][nodeId];
743748
}
744749
}
745750
for (const nodeId in nodeDatas) {
746-
console.log("node", nodeId, nodeDatas[nodeId], nodeUiDatas[nodeId]);
747-
this.__deserializeNode(nodeId, nodeDatas[nodeId], nodeUiDatas[nodeId]);
748-
}
751+
const nodeData = nodeDatas[nodeId];
752+
const nodeUiData = nodeUiDatas[nodeId];
753+
this.__deserializeNode(nodeData["key"], nodeData["version"], nodeId, nodeData, nodeUiData);
754+
}
755+
setTimeout(() => {
756+
this.__deserializeEdges(workbenchInitData);
757+
this.setDeserialized(true);
758+
}, 2000);
749759
},
750760

751761
__deserializeNodes: function(workbenchData, workbenchUIData = {}) {

0 commit comments

Comments
 (0)