Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -960,14 +960,14 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
return;
}

if (!osparc.study.Utils.isPotentialFunction(this.__resourceData["workbench"])) {
return;
}
const isPotentialFunction = osparc.study.CreateFunction.isPotentialFunction(this.__resourceData["workbench"]);

const id = "CreateFunction";
const iconSrc = "@MaterialIcons/functions/24";
const title = this.tr("Create Function");
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
page.setEnabled(isPotentialFunction);
osparc.utils.Utils.toolTipTextOnDisabledWidget(page.getChildControl("button"), osparc.study.CreateFunction.CREATE_FUNCTION_TEXT);
const createFunction = new osparc.study.CreateFunction(this.__resourceData);
const createFunctionButton = createFunction.getCreateFunctionButton();
osparc.utils.Utils.setIdToWidget(createFunctionButton, "create_function_page_btn");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ qx.Class.define("osparc.data.Resources", {
endpoints: {
get: {
method: "GET",
url: "/{productName}/app-summary.json",
url: `/{productName}/app-summary.json?no-cache=${new Date().getTime()}`,
isJsonFile: true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,9 @@ qx.Class.define("osparc.form.renderer.PropForm", {
converter: label => label + ": " + fromPortLabel
});

// Hack: Show tooltip if element is disabled
const addToolTip = () => {
ctrlLink.getContentElement().removeAttribute("title");
const toolTipText = fromNode.getLabel() + ":\n" + fromPortLabel;
ctrlLink.getContentElement().setAttribute("title", toolTipText);
osparc.utils.Utils.toolTipTextOnDisabledWidget(ctrlLink, toolTipText);
};
fromNode.addListener("changeLabel", () => addToolTip());
addToolTip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,37 @@ qx.Class.define("osparc.study.CreateFunction", {
this.__buildLayout();
},

statics: {
CREATE_FUNCTION_TEXT: qx.locale.Manager.tr(`
In order to Create a Function, the pipeline needs:
- at least one parameter and one probe (numbers)
- at least one computational app
- no dynamic apps
`),

isPotentialFunction: function(workbench) {
// const filePickers = osparc.study.Utils.extractFilePickers(workbench);
// const parameters = osparc.study.Utils.extractParameters(workbench);
// const probes = osparc.study.Utils.extractProbes(workbench);
// return (filePickers.length + parameters.length) && probes.length;

const parameters = osparc.study.Utils.extractFunctionableParameters(workbench);
const probes = osparc.study.Utils.extractFunctionableProbes(workbench);
const computationals = osparc.study.Utils.extractComputationalServices(workbench);
const dynamics = osparc.study.Utils.extractDynamicServices(workbench);

return Boolean(
(parameters.length && probes.length) &&
computationals.length > 0 &&
dynamics.length === 0
);
},

checkExposedInputsOutputs: function(exposedInputs, exposedOutputs) {
return Boolean(Object.values(exposedInputs).some(exposedInputValue => exposedInputValue) && Object.values(exposedOutputs).some(exposedOutputValue => exposedOutputValue));
},
},

members: {
__studyData: null,
__form: null,
Expand Down Expand Up @@ -238,6 +269,12 @@ qx.Class.define("osparc.study.CreateFunction", {
},

__createFunction: function(defaultInputs, exposedInputs, exposedOutputs) {
if (!osparc.study.CreateFunction.checkExposedInputsOutputs(exposedInputs, exposedOutputs)) {
const msg = this.tr("Expose at least one input and one output");
osparc.FlashMessenger.logAs(msg, "ERROR");
return;
}

this.__createFunctionBtn.setFetching(true);

// first publish it as a hidden template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,6 @@ qx.Class.define("osparc.study.Utils", {
return parameters;
},

isPotentialFunction: function(workbench) {
// in order to create a function, the pipeline needs:
// - at least one parameter or one probe
// - for now, only float types are allowed
// - at least one computational service
// - no dynamic services

// const filePickers = osparc.study.Utils.extractFilePickers(workbench);
// const parameters = osparc.study.Utils.extractParameters(workbench);
// const probes = osparc.study.Utils.extractProbes(workbench);
// return (filePickers.length + parameters.length) && probes.length;

const parameters = osparc.study.Utils.extractFunctionableParameters(workbench);
const probes = osparc.study.Utils.extractFunctionableProbes(workbench);
const computationals = osparc.study.Utils.extractComputationalServices(workbench);
const dynamics = osparc.study.Utils.extractDynamicServices(workbench);

return (
(parameters.length || probes.length) &&
computationals.length > 0 &&
dynamics.length === 0
);
},

getCantReadServices: function(studyServices = []) {
return studyServices.filter(studyService => studyService["myAccessRights"]["execute"] === false);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ qx.Class.define("osparc.utils.Utils", {

FLOATING_Z_INDEX: 1000001 + 1,

toolTipTextOnDisabledWidget: function(widget, toolTipText) {
if (widget && widget.getContentElement()) {
const el = widget.getContentElement();
el.removeAttribute("title");
el.setAttribute("title", toolTipText);
}
},

errorsToForm: function(form, errors) {
const items = form.getItems();
// reset validity
Expand Down
Loading