Skip to content

Commit a73dfd9

Browse files
committed
WorkbenchUIPreview2
1 parent 8420c55 commit a73dfd9

File tree

2 files changed

+96
-10
lines changed

2 files changed

+96
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ qx.Class.define("osparc.data.model.Function", {
4242
thumbnail: functionData.thumbnail || this.getThumbnail(),
4343
});
4444

45-
const wbData = functionData.workbench || this.getWorkbench();
46-
const workbench = new osparc.data.model.Workbench(wbData, functionData.ui);
47-
this.setWorkbench(workbench);
48-
workbench.setFunction(this);
49-
50-
this.getWorkbench().buildWorkbench();
45+
const wbData = functionData.workbench || {};
46+
const wbUiData = functionData.ui || {};
47+
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview2(wbData, wbUiData);
48+
this.setWorkbenchUiPreview(workbenchUIPreview);
5149
},
5250

5351
properties: {
@@ -128,11 +126,10 @@ qx.Class.define("osparc.data.model.Function", {
128126
init: null
129127
},
130128

131-
workbench: {
132-
check: "osparc.data.model.Workbench",
129+
workbenchUiPreview: {
130+
check: "osparc.workbench.WorkbenchUIPreview2",
133131
nullable: false,
134-
event: "changeWorkbench",
135-
init: {}
132+
init: null,
136133
},
137134
},
138135

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2021 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
* @ignore(SVGElement)
20+
*/
21+
22+
/**
23+
* *Example*
24+
*
25+
* Here is a little example of how to use the widget.
26+
*
27+
* <pre class='javascript'>
28+
* let workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview();
29+
* this.getRoot().add(workbenchUIPreview);
30+
* </pre>
31+
*/
32+
33+
qx.Class.define("osparc.workbench.WorkbenchUIPreview2", {
34+
extend: osparc.workbench.WorkbenchUI,
35+
36+
construct: function(wbData, wbDataUi) {
37+
this.base(arguments);
38+
39+
this.set({
40+
backgroundColor: "background-main"
41+
});
42+
},
43+
44+
members: {
45+
// overridden
46+
_addItemsToLayout: function() {
47+
this._addWorkbenchLayer();
48+
},
49+
50+
// 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+
}
82+
},
83+
84+
// overridden
85+
_addEventListeners: function() {
86+
this.addListenerOnce("appear", this._listenToMouseWheel, this);
87+
}
88+
}
89+
});

0 commit comments

Comments
 (0)