Skip to content

Commit 1169f27

Browse files
committed
exposedInputs, exposedOutputs
1 parent bf01de4 commit 1169f27

File tree

1 file changed

+90
-37
lines changed

1 file changed

+90
-37
lines changed

services/static-webserver/client/source/class/osparc/study/CreateFunction.js

Lines changed: 90 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,9 @@ qx.Class.define("osparc.study.CreateFunction", {
5656
});
5757
form.add(description, this.tr("Description"), null, "description");
5858

59-
const createFunctionBtn = this.__createFunctionBtn = new osparc.ui.form.FetchButton().set({
60-
appearance: "strong-button",
61-
label: this.tr("Create"),
62-
allowGrowX: false,
63-
alignX: "right"
64-
});
65-
createFunctionBtn.addListener("execute", () => {
66-
if (this.__form.validate()) {
67-
this.__createFunction();
68-
}
69-
}, this);
7059

60+
const exposedInputs = {};
61+
const exposedOutputs = {};
7162

7263
// INPUTS
7364
const inGrid = new qx.ui.layout.Grid(10, 6);
@@ -128,10 +119,12 @@ qx.Class.define("osparc.study.CreateFunction", {
128119
row,
129120
column,
130121
});
122+
exposedInputs[filePicker["label"]] = true;
123+
fpExposed.addListener("changeValue", e => exposedInputs[filePicker["label"]] = e.getData());
131124
column++;
132125

133126
const outputValue = osparc.file.FilePicker.getOutput(filePicker);
134-
const fpDefaultValue = new qx.ui.basic.Label(outputValue && outputValue["path"] ? outputValue["path"] : null);
127+
const fpDefaultValue = new qx.ui.basic.Label(outputValue && outputValue["path"] ? outputValue["path"] : "");
135128
inputsLayout.add(fpDefaultValue, {
136129
row,
137130
column,
@@ -166,6 +159,8 @@ qx.Class.define("osparc.study.CreateFunction", {
166159
row,
167160
column,
168161
});
162+
exposedInputs[parameter["label"]] = true;
163+
parameterExposed.addListener("changeValue", e => exposedInputs[parameter["label"]] = e.getData());
169164
column++;
170165

171166
const parameterDefaultValue = new qx.ui.basic.Label(String(osparc.service.Utils.getParameterValue(parameter)));
@@ -179,6 +174,7 @@ qx.Class.define("osparc.study.CreateFunction", {
179174
row++;
180175
});
181176

177+
182178
// OUTPUTS
183179
const outGrid = new qx.ui.layout.Grid(10, 6);
184180
const outputsLayout = new qx.ui.container.Composite(outGrid).set({
@@ -189,24 +185,75 @@ qx.Class.define("osparc.study.CreateFunction", {
189185
this._add(outputsLayout);
190186

191187
// header
188+
row = 0;
189+
column = 0;
192190
const nameLabel2 = new qx.ui.basic.Label(this.tr("Output"));
193191
outputsLayout.add(nameLabel2, {
194-
row: 0,
195-
column: 0,
192+
row,
193+
column,
196194
});
195+
column++;
197196
const typeLabel2 = new qx.ui.basic.Label(this.tr("Type"));
198197
outputsLayout.add(typeLabel2, {
199-
row: 0,
200-
column: 1,
198+
row,
199+
column,
201200
});
201+
column++;
202202
const exposedLabel2 = new qx.ui.basic.Label(this.tr("Exposed"));
203203
outputsLayout.add(exposedLabel2, {
204-
row: 0,
205-
column: 2,
204+
row,
205+
column,
206+
});
207+
column++;
208+
column = 0;
209+
row++;
210+
211+
const probes = osparc.study.Utils.extractProbes(this.__studyData["workbench"]);
212+
probes.forEach(probe => {
213+
const parameterLabel = new qx.ui.basic.Label(probe["label"]);
214+
outputsLayout.add(parameterLabel, {
215+
row,
216+
column,
217+
});
218+
column++;
219+
220+
const probeMetadata = osparc.store.Services.getMetadata(probe["key"], probe["version"]);
221+
if (probeMetadata) {
222+
const probeType = new qx.ui.basic.Label(osparc.service.Utils.getProbeType(probeMetadata));
223+
outputsLayout.add(probeType, {
224+
row,
225+
column,
226+
});
227+
}
228+
column++;
229+
230+
const probeExposed = new qx.ui.form.CheckBox().set({ value: true });
231+
outputsLayout.add(probeExposed, {
232+
row,
233+
column,
234+
});
235+
exposedOutputs[probe["label"]] = true;
236+
probeExposed.addListener("changeValue", e => exposedOutputs[probe["label"]] = e.getData());
237+
column++;
238+
239+
column = 0;
240+
row++;
241+
});
242+
243+
const createFunctionBtn = this.__createFunctionBtn = new osparc.ui.form.FetchButton().set({
244+
appearance: "strong-button",
245+
label: this.tr("Create"),
246+
allowGrowX: false,
247+
alignX: "right"
206248
});
249+
createFunctionBtn.addListener("execute", () => {
250+
if (this.__form.validate()) {
251+
this.__createFunction(exposedInputs, exposedOutputs);
252+
}
253+
}, this);
207254
},
208255

209-
__createFunction: function() {
256+
__createFunction: function(exposedInputs, exposedOutputs) {
210257
this.__createFunctionBtn.setFetching(true);
211258

212259
// first publish it as a template
@@ -225,7 +272,7 @@ qx.Class.define("osparc.study.CreateFunction", {
225272
.then(task => {
226273
task.addListener("resultReceived", e => {
227274
const templateData = e.getData();
228-
this.__doCreateFunction(templateData);
275+
this.__doCreateFunction(templateData, exposedInputs, exposedOutputs);
229276
});
230277
})
231278
.catch(err => {
@@ -234,7 +281,7 @@ qx.Class.define("osparc.study.CreateFunction", {
234281
});
235282
},
236283

237-
__doCreateFunction: function(templateData) {
284+
__doCreateFunction: function(templateData, exposedInputs, exposedOutputs) {
238285
const nameField = this.__form.getItem("name");
239286
const descriptionField = this.__form.getItem("description");
240287

@@ -261,33 +308,39 @@ qx.Class.define("osparc.study.CreateFunction", {
261308
const filePickers = osparc.study.Utils.extractFilePickers(templateData["workbench"]);
262309
filePickers.forEach(filePicker => {
263310
const fpLabel = filePicker["label"];
264-
functionData["input_schema"]["schema_dict"]["properties"][fpLabel] = {
265-
"type": "FileID",
266-
};
267-
const outputValue = osparc.file.FilePicker.getOutput(filePicker);
268-
functionData["default_inputs"][fpLabel] = outputValue && outputValue["path"] ? outputValue["path"] : null;
311+
if (exposedInputs[fpLabel]) {
312+
functionData["input_schema"]["schema_dict"]["properties"][fpLabel] = {
313+
"type": "FileID",
314+
};
315+
const outputValue = osparc.file.FilePicker.getOutput(filePicker);
316+
functionData["default_inputs"][fpLabel] = outputValue && outputValue["path"] ? outputValue["path"] : null;
317+
}
269318
});
270319

271320
const parameters = osparc.study.Utils.extractParameters(templateData["workbench"]);
272321
parameters.forEach(parameter => {
273322
const parameterLabel = parameter["label"];
274-
const parameterMetadata = osparc.store.Services.getMetadata(parameter["key"], parameter["version"]);
275-
if (parameterMetadata) {
276-
functionData["input_schema"]["schema_dict"]["properties"][parameterLabel] = {
277-
"type": osparc.service.Utils.getParameterType(parameterMetadata),
278-
};
323+
if (exposedInputs[parameterLabel]) {
324+
const parameterMetadata = osparc.store.Services.getMetadata(parameter["key"], parameter["version"]);
325+
if (parameterMetadata) {
326+
functionData["input_schema"]["schema_dict"]["properties"][parameterLabel] = {
327+
"type": osparc.service.Utils.getParameterType(parameterMetadata),
328+
};
329+
}
330+
functionData["default_inputs"][parameterLabel] = osparc.service.Utils.getParameterValue(parameter);
279331
}
280-
functionData["default_inputs"][parameterLabel] = osparc.service.Utils.getParameterValue(parameter);
281332
});
282333

283334
const probes = osparc.study.Utils.extractProbes(templateData["workbench"]);
284335
probes.forEach(probe => {
285336
const probeLabel = probe["label"];
286-
const probeMetadata = osparc.store.Services.getMetadata(probe["key"], probe["version"]);
287-
if (probeMetadata) {
288-
functionData["output_schema"]["schema_dict"]["properties"][probeLabel] = {
289-
"type": osparc.service.Utils.getProbeType(probeMetadata),
290-
};
337+
if (exposedOutputs[probeLabel]) {
338+
const probeMetadata = osparc.store.Services.getMetadata(probe["key"], probe["version"]);
339+
if (probeMetadata) {
340+
functionData["output_schema"]["schema_dict"]["properties"][probeLabel] = {
341+
"type": osparc.service.Utils.getProbeType(probeMetadata),
342+
};
343+
}
291344
}
292345
});
293346

0 commit comments

Comments
 (0)