Skip to content

Commit 5125753

Browse files
authored
✨ [Frontend] Create Functions (#7653)
1 parent 5a1666d commit 5125753

File tree

7 files changed

+446
-12
lines changed

7 files changed

+446
-12
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
336336
this.__getConversationsPage,
337337
this.__getPermissionsPage,
338338
this.__getSaveAsTemplatePage,
339+
this.__getCreateFunctionsPage,
339340
this.__getTagsPage,
340341
this.__getQualityPage,
341342
this.__getClassifiersPage,
@@ -688,7 +689,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
688689

689690
const id = "ServicesUpdate";
690691
const title = this.tr("Services Updates");
691-
const iconSrc = "@MaterialIcons/update/22";
692+
const iconSrc = "@MaterialIcons/update/24";
692693
const page = this.__servicesUpdatePage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
693694
this.__addOpenButton(page);
694695

@@ -801,6 +802,29 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
801802
return page;
802803
}
803804
return null;
805+
},
806+
807+
__getCreateFunctionsPage: function() {
808+
if (!osparc.utils.Resources.isStudy(this.__resourceData)) {
809+
return null;
810+
}
811+
812+
if (!osparc.study.Utils.canCreateFunction(this.__resourceData["workbench"])) {
813+
return null;
814+
}
815+
816+
const id = "CreateFunction";
817+
const iconSrc = "@MaterialIcons/functions/24";
818+
const title = this.tr("Create Function");
819+
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
820+
const createFunction = new osparc.study.CreateFunction(this.__resourceData);
821+
const createFunctionButton = createFunction.getCreateFunctionButton();
822+
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(createFunctionButton);
823+
const toolbar = this.self().createToolbar();
824+
toolbar.add(createFunctionButton);
825+
page.addToHeader(toolbar);
826+
page.addToContent(createFunction);
827+
return page;
804828
}
805829
}
806830
});

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,18 @@ qx.Class.define("osparc.data.Resources", {
586586
}
587587
}
588588
},
589+
/*
590+
* FUNCTIONS
591+
*/
592+
"functions": {
593+
useCache: false,
594+
endpoints: {
595+
getPage: {
596+
method: "POST",
597+
url: statics.API + "/functions"
598+
}
599+
}
600+
},
589601
/*
590602
* TASKS
591603
*/

services/static-webserver/client/source/class/osparc/form/renderer/PropForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ qx.Class.define("osparc.form.renderer.PropForm", {
8686
const supportedTypes = [];
8787
const paramsMD = osparc.store.Services.getParametersMetadata();
8888
paramsMD.forEach(paramMD => {
89-
supportedTypes.push(osparc.node.ParameterEditor.getParameterOutputTypeFromMD(paramMD));
89+
supportedTypes.push(osparc.service.Utils.getParameterType(paramMD));
9090
});
9191
return supportedTypes.includes(field.type);
9292
},

services/static-webserver/client/source/class/osparc/node/ParameterEditor.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,9 @@ qx.Class.define("osparc.node.ParameterEditor", {
2929
},
3030

3131
statics: {
32-
getParameterOutputTypeFromMD: function(metadata) {
33-
let type = metadata["outputs"]["out_1"]["type"];
34-
if (type === "ref_contentSchema") {
35-
type = metadata["outputs"]["out_1"]["contentSchema"]["type"];
36-
}
37-
return type;
38-
},
39-
4032
getParameterOutputType: function(node) {
4133
const metadata = node.getMetaData();
42-
return this.self().getParameterOutputTypeFromMD(metadata);
34+
return osparc.service.Utils.getParameterType(metadata);
4335
},
4436

4537
setParameterOutputValue: function(node, val) {

services/static-webserver/client/source/class/osparc/service/Utils.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,33 @@ qx.Class.define("osparc.service.Utils", {
240240
}
241241
});
242242
return services;
243-
}
243+
},
244+
245+
getParameterType: function(metadata) {
246+
let type = metadata["outputs"]["out_1"]["type"];
247+
if (type === "ref_contentSchema") {
248+
type = metadata["outputs"]["out_1"]["contentSchema"]["type"];
249+
}
250+
return type;
251+
},
252+
253+
getParameterValue: function(parameterData) {
254+
if (
255+
parameterData &&
256+
parameterData["outputs"] &&
257+
parameterData["outputs"]["out_1"]
258+
) {
259+
return parameterData["outputs"]["out_1"];
260+
}
261+
return null;
262+
},
263+
264+
getProbeType: function(metadata) {
265+
let type = metadata["inputs"]["in_1"]["type"];
266+
if (type === "ref_contentSchema") {
267+
type = metadata["inputs"]["in_1"]["contentSchema"]["type"];
268+
}
269+
return type;
270+
},
244271
}
245272
});

0 commit comments

Comments
 (0)