Skip to content

Commit 293819b

Browse files
committed
__buildPreview
1 parent c31f73f commit 293819b

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

services/static-webserver/client/source/class/osparc/workbench/WorkbenchUIPreview2.js

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,51 +39,54 @@ qx.Class.define("osparc.workbench.WorkbenchUIPreview2", {
3939
this.set({
4040
backgroundColor: "background-main"
4141
});
42+
43+
this.__wbData = wbData || {};
44+
this.__wbDataUi = wbDataUi || {};
45+
46+
this.__buildPreview();
4247
},
4348

4449
members: {
50+
__wbData: null,
51+
__wbDataUi: null,
52+
4553
// overridden
4654
_addItemsToLayout: function() {
4755
this._addWorkbenchLayer();
4856
},
4957

5058
// overridden
51-
_loadModel: function(model) {
52-
this._clearAll();
53-
this.resetSelection();
54-
this._currentModel = model;
55-
if (model) {
56-
qx.ui.core.queue.Visibility.flush();
57-
58-
// create nodes
59-
const nodes = model.getNodes();
60-
for (const nodeId in nodes) {
61-
const node = nodes[nodeId];
62-
const nodeUI = this._createNodeUI(nodeId);
63-
nodeUI.setIsMovable(false);
64-
this._addNodeUIToWorkbench(nodeUI, node.getPosition());
65-
}
66-
qx.ui.core.queue.Layout.flush();
67-
68-
// create edges
69-
for (const nodeId in nodes) {
70-
const node = nodes[nodeId];
71-
const inputNodeIDs = node.getInputNodes();
72-
inputNodeIDs.forEach(inputNodeId => {
73-
if (inputNodeId in nodes) {
74-
this._createEdgeBetweenNodes(inputNodeId, nodeId, false);
75-
}
76-
});
77-
}
78-
79-
const maxScale = 0.7;
80-
this._fitScaleToNodes(maxScale);
81-
}
59+
_loadModel: function() {
60+
return; // no model to load, this is a preview
8261
},
8362

8463
// overridden
8564
_addEventListeners: function() {
8665
this.addListenerOnce("appear", this._listenToMouseWheel, this);
87-
}
66+
},
67+
68+
__buildPreview: function() {
69+
this._clearAll();
70+
this.resetSelection();
71+
72+
// create nodes
73+
const nodes = this.__wbData.nodes || {};
74+
Object.entries(nodes).forEach(([nodeId, nodeData]) => {
75+
// we assume that the metadata was fetched before
76+
const serviceMetadata = osparc.store.Services.getMetadata(nodeData["key"], nodeData["version"]);
77+
const node = osparc.data.model.Node(null, serviceMetadata, nodeId);
78+
const nodeUI = new osparc.workbench.NodeUI(node);
79+
nodeUI.setIsMovable(false);
80+
this._addNodeUIToWorkbench(nodeUI, node.position);
81+
});
82+
qx.ui.core.queue.Layout.flush();
83+
84+
// create edges
85+
const edges = this.__wbData.edges || {};
86+
for (const edgeId in edges) {
87+
const edge = edges[edgeId];
88+
this._createEdge(edge.from, edge.to, edgeId);
89+
}
90+
},
8891
}
8992
});

0 commit comments

Comments
 (0)