Skip to content

Commit c4b6e98

Browse files
committed
Function preview
1 parent 293819b commit c4b6e98

File tree

7 files changed

+72
-16
lines changed

7 files changed

+72
-16
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
394394
return;
395395
} else if (this.__resourceData["resourceType"] === "function") {
396396
this.__addInfoPage();
397-
// this.__addPreviewPage();
397+
this.__addPreviewPage();
398398
this.fireEvent("pagesAdded");
399399
return;
400400
}
@@ -575,7 +575,12 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
575575

576576
const lazyLoadContent = () => {
577577
const resourceModel = this.__resourceModel;
578-
const preview = new osparc.study.StudyPreview(resourceModel);
578+
let preview = null;
579+
if (osparc.utils.Resources.isFunction(this.__resourceData)) {
580+
preview = new osparc.study.FunctionPreview(resourceModel);
581+
} else {
582+
preview = new osparc.study.StudyPreview(resourceModel);
583+
}
579584
page.addToContent(preview);
580585
this.__widgets.push(preview);
581586
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ qx.Class.define("osparc.data.model.Function", {
4040
creationDate: functionData.creationDate ? new Date(functionData.creationDate) : this.getCreationDate(),
4141
lastChangeDate: functionData.lastChangeDate ? new Date(functionData.lastChangeDate) : this.getLastChangeDate(),
4242
thumbnail: functionData.thumbnail || this.getThumbnail(),
43+
workbenchData: functionData.workbench || this.getWorkbenchData(),
44+
functionUIData: functionData.ui || this.functionUIData(),
4345
});
44-
45-
const wbData = functionData.workbench || {};
46-
const wbUiData = functionData.ui || {};
47-
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview2(wbData, wbUiData);
48-
this.setWorkbenchUiPreview(workbenchUIPreview);
4946
},
5047

5148
properties: {
@@ -126,10 +123,16 @@ qx.Class.define("osparc.data.model.Function", {
126123
init: null
127124
},
128125

129-
workbenchUiPreview: {
130-
check: "osparc.workbench.WorkbenchUIPreview2",
126+
workbenchData: {
127+
check: "Object",
128+
nullable: false,
129+
init: {},
130+
},
131+
132+
functionUIData: {
133+
check: "Object",
131134
nullable: false,
132-
init: null,
135+
init: {},
133136
},
134137
},
135138

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ qx.Class.define("osparc.data.model.Node", {
577577
*/
578578
__addSettings: function(inputs) {
579579
const form = this.__settingsForm = new osparc.form.Auto(inputs);
580+
if (!this.getStudy()) {
581+
return;
582+
}
580583
const propsForm = new osparc.form.renderer.PropForm(form, this, this.getStudy());
581584
this.setPropsForm(propsForm);
582585
propsForm.addListener("linkFieldModified", e => {

services/static-webserver/client/source/class/osparc/store/Functions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ qx.Class.define("osparc.store.Functions", {
202202
},
203203
"thumbnail": "https://img.freepik.com/premium-vector/image-icon-design-vector-template_1309674-940.jpg",
204204
"workbench": {"50a50309-1dfc-5ad5-b2d9-c11697641f0b": {"key": "simcore/services/comp/itis/sleeper", "version": "2.1.6", "label": "sleeper", "inputs": {"input_2": 2, "input_3": false, "input_4": 0, "input_5": 0}, "inputsRequired": [], "inputNodes": ["2e348481-5042-5148-9196-590574747297", "69873032-770a-536b-adb6-0e6ea01720a4"]}, "2e348481-5042-5148-9196-590574747297": {"key": "simcore/services/frontend/parameter/number", "version": "1.0.0", "label": "X", "inputs": {}, "inputsRequired": [], "inputNodes": [], "outputs": {"out_1": 1}, "runHash": null}, "70e1de1a-a8b0-59e3-b19e-ea20f78765ce": {"key": "simcore/services/frontend/iterator-consumer/probe/number", "version": "1.0.0", "label": "Out 1", "inputs": {"in_1": 0}, "inputsRequired": [], "inputNodes": ["50a50309-1dfc-5ad5-b2d9-c11697641f0b"]}, "69873032-770a-536b-adb6-0e6ea01720a4": {"key": "simcore/services/frontend/parameter/number", "version": "1.0.0", "label": "Y", "inputs": {}, "inputsRequired": [], "inputNodes": [], "outputs": {"out_1": 1}, "runHash": null}, "24f856c3-408c-5ab4-ad01-e99630a355fe": {"key": "simcore/services/frontend/iterator-consumer/probe/number", "version": "1.0.0", "label": "Out_2", "inputs": {"in_1": 0}, "inputsRequired": [], "inputNodes": ["50a50309-1dfc-5ad5-b2d9-c11697641f0b"]}},
205-
"ui": {"24f856c3-408c-5ab4-ad01-e99630a355fe": {"position": {"x": 540, "y": 240}}, "2e348481-5042-5148-9196-590574747297": {"position": {"x": 120, "y": 140}}, "50a50309-1dfc-5ad5-b2d9-c11697641f0b": {"position": {"x": 300, "y": 180}}, "69873032-770a-536b-adb6-0e6ea01720a4": {"position": {"x": 120, "y": 240}}, "70e1de1a-a8b0-59e3-b19e-ea20f78765ce": {"position": {"x": 540, "y": 140}}},
205+
"ui": {
206+
"workbench": {"24f856c3-408c-5ab4-ad01-e99630a355fe": {"position": {"x": 540, "y": 240}}, "2e348481-5042-5148-9196-590574747297": {"position": {"x": 120, "y": 140}}, "50a50309-1dfc-5ad5-b2d9-c11697641f0b": {"position": {"x": 300, "y": 180}}, "69873032-770a-536b-adb6-0e6ea01720a4": {"position": {"x": 120, "y": 240}}, "70e1de1a-a8b0-59e3-b19e-ea20f78765ce": {"position": {"x": 540, "y": 140}}},
207+
"mode": "pipeline",
208+
},
206209
}],
207210
"_links": {
208211
"next": null,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 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+
qx.Class.define("osparc.study.FunctionPreview", {
19+
extend: qx.ui.core.Widget,
20+
21+
/**
22+
* @param func {osparc.data.model.Function} Function model
23+
*/
24+
construct: function(func) {
25+
this.base(arguments);
26+
27+
this._setLayout(new qx.ui.layout.VBox(5));
28+
29+
this.__buildPreview(func);
30+
},
31+
32+
members: {
33+
__buildPreview: function(func) {
34+
const wbData = func.getWorkbenchData();
35+
const functionUiData = func.getFunctionUIData();
36+
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview2(wbData, functionUiData["workbench"] || {});
37+
workbenchUIPreview.setMaxHeight(550);
38+
this._add(workbenchUIPreview);
39+
}
40+
}
41+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
418418

419419
nodeUI.addListener("appear", () => this.__updateNodeUIPos(nodeUI), this);
420420

421-
const isStudyReadOnly = this.getStudy().isReadOnly();
421+
const isStudyReadOnly = this.isPropertyInitialized("study") ? this.getStudy().isReadOnly() : true;
422422
nodeUI.set({
423423
movable: !isStudyReadOnly,
424424
selectable: !isStudyReadOnly,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ qx.Class.define("osparc.workbench.WorkbenchUIPreview2", {
4343
this.__wbData = wbData || {};
4444
this.__wbDataUi = wbDataUi || {};
4545

46-
this.__buildPreview();
46+
setTimeout(() => {
47+
this.__buildPreview();
48+
}, 200);
4749
},
4850

4951
members: {
@@ -70,11 +72,10 @@ qx.Class.define("osparc.workbench.WorkbenchUIPreview2", {
7072
this.resetSelection();
7173

7274
// create nodes
73-
const nodes = this.__wbData.nodes || {};
74-
Object.entries(nodes).forEach(([nodeId, nodeData]) => {
75+
Object.entries(this.__wbData).forEach(([nodeId, nodeData]) => {
7576
// we assume that the metadata was fetched before
7677
const serviceMetadata = osparc.store.Services.getMetadata(nodeData["key"], nodeData["version"]);
77-
const node = osparc.data.model.Node(null, serviceMetadata, nodeId);
78+
const node = new osparc.data.model.Node(null, serviceMetadata, nodeId);
7879
const nodeUI = new osparc.workbench.NodeUI(node);
7980
nodeUI.setIsMovable(false);
8081
this._addNodeUIToWorkbench(nodeUI, node.position);

0 commit comments

Comments
 (0)