Skip to content

Commit bfd5872

Browse files
committed
create function tabPage
1 parent 2d0ae68 commit bfd5872

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

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

Lines changed: 18 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,22 @@ 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+
return page;
804821
}
805822
}
806823
});

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,35 @@ qx.Class.define("osparc.study.Utils", {
230230
return Array.from(services);
231231
},
232232

233+
extractFilePickers: function(workbench) {
234+
const parameters = Object.values(workbench).filter(srv => srv["key"].includes("simcore/services/frontend/file-picker"));
235+
return parameters;
236+
},
237+
238+
extractParameters: function(workbench) {
239+
const parameters = Object.values(workbench).filter(srv => srv["key"].includes("simcore/services/frontend/parameter/"));
240+
return parameters;
241+
},
242+
243+
extractProbes: function(workbench) {
244+
const parameters = Object.values(workbench).filter(srv => srv["key"].includes("simcore/services/frontend/iterator-consumer/probe/"));
245+
return parameters;
246+
},
247+
248+
canCreateFunction: function(workbench) {
249+
if (!osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled()) {
250+
return false;
251+
}
252+
253+
// in order to create a function, the pipeline needs:
254+
// - at least one parameter (or file-picker (file type parameter))
255+
// - at least one probe
256+
const filePickers = osparc.study.Utils.extractFilePickers(workbench);
257+
const parameters = osparc.study.Utils.extractParameters(workbench);
258+
const probes = osparc.study.Utils.extractProbes(workbench);
259+
return (filePickers.length + parameters.length) && probes.length;
260+
},
261+
233262
getCantExecuteServices: function(studyServices = []) {
234263
return studyServices.filter(studyService => studyService["myAccessRights"]["execute"] === false);
235264
},

0 commit comments

Comments
 (0)