Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Frontend: Dynamic input ports #4210

Merged
merged 29 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b7dff84
throw exceptions
odeimaiz May 10, 2023
c359ce1
first_name, lsat_name and tooltip on "Share with"
odeimaiz May 10, 2023
bd13666
makeInputsDynamic
odeimaiz May 10, 2023
a6c54ec
Merge branch 'master' into feature/dynamic-input-ports
odeimaiz May 11, 2023
b1cd232
log-in strong-button
odeimaiz May 11, 2023
1ad16e8
circular ellipses
odeimaiz May 11, 2023
d04c882
minors
odeimaiz May 11, 2023
271ab2d
minor
odeimaiz May 11, 2023
ee03cac
minor
odeimaiz May 11, 2023
9cdff60
[skip ci] old files
odeimaiz May 11, 2023
5f9cefd
[skip ci] minor
odeimaiz May 11, 2023
d27d5b5
one less confirmation setting
odeimaiz May 11, 2023
866579b
[skip ci] Experimental settings to Confirmations page
odeimaiz May 11, 2023
157d9e7
[skip ci] addPortButton
odeimaiz May 11, 2023
6e0ca35
[skip ci] getVisibleEmptyDataLastPort
odeimaiz May 11, 2023
b33d652
hide add button
odeimaiz May 11, 2023
7691045
Merge branch 'master' into feature/dynamic-input-ports
odeimaiz May 15, 2023
e72b187
renamings
odeimaiz May 15, 2023
806fdc1
renaming
odeimaiz May 15, 2023
7b42b2f
makeInputsDynamic
odeimaiz May 15, 2023
b50311c
simpler
odeimaiz May 15, 2023
4a3276f
getMinVisibleInputs
odeimaiz May 16, 2023
37bd76f
minVisibleInputs
odeimaiz May 16, 2023
c544886
minor
odeimaiz May 16, 2023
0b1bf8f
show field
odeimaiz May 16, 2023
4029c9b
Merge branch 'master' into feature/dynamic-input-ports
odeimaiz May 16, 2023
7c0e8d1
Merge branch 'master' into feature/dynamic-input-ports
odeimaiz May 16, 2023
4525c41
min-visible-inputs
odeimaiz May 16, 2023
592e519
Merge branch 'feature/dynamic-input-ports' of github.com:odeimaiz/osp…
odeimaiz May 16, 2023
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 @@ -213,7 +213,8 @@ qx.Class.define("osparc.Error", {
case "log-in-button": {
control = new qx.ui.form.Button().set({
icon: "@FontAwesome5Solid/sign-in-alt/14",
label: this.tr("Log in")
label: this.tr("Log in"),
appearance: "strong-button"
});
control.addListener("execute", () => this.__logIn(), this);
const actionsLayout = this.getChildControl("actions-layout");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,108 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
__ctrlLinkMap: null,
__linkUnlinkStackMap: null,
__fieldOptsBtnMap: null,
__addInputPortButton: null,

/*
* <-- Dynamic inputs -->
*/
__getEmptyDataLastPorts: function() {
let emptyDataPorts = [];
const minVisibleInputs = this.getNode().getMinVisibleInputs();
if (minVisibleInputs === null) {
return emptyDataPorts;
}
const portKeys = this.__getPortKeys();
// it will always show 1 more, so: -1
for (let i=minVisibleInputs-1; i<portKeys.length; i++) {
const portId = portKeys[i];
const ctrl = this._form.getControl(portId);
if (ctrl && ctrl.type.includes("data:") && !("link" in ctrl)) {
emptyDataPorts.push(portId);
} else {
emptyDataPorts = [];
}
}
return emptyDataPorts;
},

__getVisibleEmptyDataLastPort: function() {
let emptyDataPorts = null;
this.__getPortKeys().forEach(portId => {
const ctrl = this._form.getControl(portId);
const label = this._getLabelFieldChild(portId).child;
if (
ctrl && ctrl.type.includes("data:") && !("link" in ctrl) &&
label && label.isVisible()
) {
emptyDataPorts = portId;
}
});
return emptyDataPorts;
},

__addInputPortButtonClicked: function() {
const emptyDataPorts = this.__getEmptyDataLastPorts();
const lastEmptyDataPort = this.__getVisibleEmptyDataLastPort();
if (emptyDataPorts.length>1 && lastEmptyDataPort) {
const idx = emptyDataPorts.indexOf(lastEmptyDataPort);
if (idx+1 < emptyDataPorts.length) {
this.__showPort(emptyDataPorts[idx+1]);
}
this.__addInputPortButton.setVisibility(this.__checkAddInputPortButtonVisibility());
}
},

__checkAddInputPortButtonVisibility: function() {
const emptyDataPorts = this.__getEmptyDataLastPorts();
const lastEmptyDataPort = this.__getVisibleEmptyDataLastPort();
const idx = emptyDataPorts.indexOf(lastEmptyDataPort);
if (idx < emptyDataPorts.length-1) {
return "visible";
}
return "excluded";
},

__showPort: function(portId) {
const entry = this.self().GRID_POS;
Object.values(entry).forEach(entryPos => {
const layoutElement = this._getLayoutChild(portId, entryPos);
if (layoutElement && layoutElement.child) {
const control = layoutElement.child;
if (control) {
control.show();
}
}
});
},

__excludePort: function(portId) {
const entry = this.self().GRID_POS;
Object.values(entry).forEach(entryPos => {
const layoutElement = this._getLayoutChild(portId, entryPos);
if (layoutElement && layoutElement.child) {
const control = layoutElement.child;
if (control) {
control.exclude();
}
}
});
},

makeInputsDynamic: function() {
this.__getPortKeys().forEach(portId => this.__showPort(portId));

const emptyDataPorts = this.__getEmptyDataLastPorts();
for (let i=1; i<emptyDataPorts.length; i++) {
const hidePortId = emptyDataPorts[i];
this.__excludePort(hidePortId);
}

this.__addInputPortButton.setVisibility(this.__checkAddInputPortButtonVisibility());
},
/*
* <-- /Dynamic inputs -->
*/

__createLinkUnlinkStack: function(field) {
const linkUnlinkStack = new qx.ui.container.Stack();
Expand Down Expand Up @@ -343,6 +445,19 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {

row++;
}

// add port button
const addPortButton = this.__addInputPortButton = new qx.ui.form.Button().set({
icon: "@FontAwesome5Solid/plus/14",
toolTipText: this.tr("Add input"),
alignX: "center",
allowGrowX: false
});
addPortButton.addListener("execute", () => this.__addInputPortButtonClicked());
this._add(addPortButton, {
row,
column: this.self().GRID_POS.LABEL
});
},

// overridden
Expand Down Expand Up @@ -418,7 +533,7 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
for (let i=0; i<children.length; i++) {
let child = children[i];
const layoutProps = child.getLayoutProperties();
if (layoutProps.column === this.self().GRID_POS.retrieveStatus) {
if (layoutProps.column === this.self().GRID_POS.RETRIEVE_STATUS) {
this.__setRetrievingStatus(status, portId, i, layoutProps.row);
}
}
Expand Down Expand Up @@ -454,10 +569,14 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
}
}

this._addAt(icon, idx, {
row: row,
column: this.self().GRID_POS.RETRIEVE_STATUS
});
const label = this._getLabelFieldChild(portId).child;
if (label && label.isVisible()) {
this._getLabelFieldChild(portId);
this._addAt(icon, idx, {
row,
column: this.self().GRID_POS.RETRIEVE_STATUS
});
}
},

__arePortsCompatible: function(node1Id, port1Id, node2Id, port2Id) {
Expand Down Expand Up @@ -636,7 +755,7 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
if (layoutProps.column === this.self().GRID_POS.CTRL_FIELD) {
this._remove(child);
const item = this._form.getControl(portId);

item.show();
this._addAt(item, idx, {
row: layoutProps.row,
column: this.self().GRID_POS.CTRL_FIELD
Expand Down Expand Up @@ -765,6 +884,8 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {

this.__portLinkAdded(toPortId, fromNodeId, fromPortId);

this.makeInputsDynamic();

return true;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ qx.Class.define("osparc.component.share.CollaboratorsStudy", {

const groupData = await osparc.store.Store.getInstance().getGroup(groupId);
const isOrganization = (groupData && !("id" in groupData));
const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance();
if (isOrganization && preferencesSettings.getConfirmDemoteOrgnaization()) {
if (isOrganization) {
const msg = this.tr("Demoting to Viewer will remove write access to all the members of the Organization. Are you sure?");
const win = new osparc.ui.window.Confirmation(msg).set({
confirmAction: "delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,13 @@ qx.Class.define("osparc.dashboard.Dashboard", {
const tabButton = tabPage.getChildControl("button");
tabButton.set({
alignX: "center",
toolTipText: label,
minWidth: 50
});
tabButton.ttt = label;
tabButton.getChildControl("label").set({
font: "text-16",
alignX: "center"
font: "text-16"
});
tabButton.getChildControl("icon").set({
alignX: "center",
visibility: "excluded"
});
osparc.utils.Utils.setIdToWidget(tabButton, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
icon: "@FontAwesome5Solid/ellipsis-v/14",
focusable: false
});
// make it circular
control.getContentElement().setStyles({
"border-radius": parseInt(this.self().MENU_BTN_WIDTH/2) + "px"
});
osparc.utils.Utils.setIdToWidget(control, "studyItemMenuButton");
this._add(control, {
top: -2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
icon: "@FontAwesome5Solid/ellipsis-v/14",
focusable: false
});
// make it circular
control.getContentElement().setStyles({
"border-radius": parseInt(this.self().MENU_BTN_WIDTH/2) + "px"
});
osparc.utils.Utils.setIdToWidget(control, "studyItemMenuButton");
menuSelectionStack.addAt(control, 0);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
[
this.__getInfoPage,
this.__getPermissionsPage,
this.__getClassifiersPage,
this.__getQualityPage,
this.__getTagsPage,
this.__getServicesUpdatePage,
this.__getServicesBootOptionsPage,
this.__getQualityPage,
this.__getClassifiersPage,
this.__getSaveAsTemplatePage
].forEach(pageCallee => {
if (pageCallee) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ qx.Class.define("osparc.data.model.Node", {
return bootModeSB;
},

getMinVisibleInputs: function(metaData) {
return ("minVisibleInputs" in metaData) ? metaData["minVisibleInputs"] : null;
odeimaiz marked this conversation as resolved.
Show resolved Hide resolved
},

getOutput: function(outputs, outputKey) {
if (outputKey in outputs && "value" in outputs[outputKey]) {
return outputs[outputKey]["value"];
Expand Down Expand Up @@ -381,6 +385,10 @@ qx.Class.define("osparc.data.model.Node", {
return osparc.data.model.Node.hasBootModes(this.getMetaData());
},

getMinVisibleInputs: function() {
return osparc.data.model.Node.getMinVisibleInputs(this.getMetaData());
},

__applyNewMetaData: function() {
this.__metaData = osparc.utils.Services.getMetaData(this.getKey(), this.getVersion());
},
Expand Down Expand Up @@ -454,6 +462,9 @@ qx.Class.define("osparc.data.model.Node", {
this.__addSettings(metaData.inputs);
this.__addSettingsAccessLevelEditor(metaData.inputs);
}
if (this.getPropsForm()) {
this.getPropsForm().makeInputsDynamic();
}
}
if (metaData.outputs) {
this.setOutputs(metaData.outputs);
Expand Down Expand Up @@ -499,6 +510,9 @@ qx.Class.define("osparc.data.model.Node", {
this.__setInputData(nodeData.inputs);
this.__setInputUnits(nodeData.inputsUnits);
this.__setInputDataAccess(nodeData.inputAccess);
if (this.getPropsForm()) {
this.getPropsForm().makeInputsDynamic();
}
this.setOutputData(nodeData.outputs);
this.addInputNodes(nodeData.inputNodes);
this.addOutputNodes(nodeData.outputNodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ qx.Class.define("osparc.desktop.preferences.Preferences", {
event: "changeConfirmDeleteStudy"
},

confirmDemoteOrgnaization: {
nullable: false,
init: true,
check: "Boolean",
event: "changeConfirmDemoteOrgnaization"
},

confirmDeleteNode: {
nullable: false,
init: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ qx.Class.define("osparc.desktop.preferences.PreferencesWindow", {
tabView.add(tokensPage);
}

if (osparc.product.Utils.showPreferencesExperimental()) {
const expPage = new osparc.desktop.preferences.pages.ExperimentalPage();
const expBtn = expPage.getChildControl("button");
osparc.utils.Utils.setIdToWidget(expBtn, "preferencesExperimentalTabBtn");
tabView.add(expPage);
}

const confirmPage = new osparc.desktop.preferences.pages.ConfirmationsPage();
tabView.add(confirmPage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ qx.Class.define("osparc.desktop.preferences.pages.BasePage", {
construct: function(title, iconSrc = null) {
this.base(arguments, null, iconSrc);

this.setLayout(new qx.ui.layout.VBox(10).set({
this.setLayout(new qx.ui.layout.VBox(20).set({
spacing: 5,
alignX: "center"
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ qx.Class.define("osparc.desktop.preferences.pages.ConfirmationsPage", {
const title = this.tr("Confirmation Settings");
this.base(arguments, title, iconSrc);

const experimentalSettings = this.__createConfirmationsSettings();
this.add(experimentalSettings);
const confirmationSettings = this.__createConfirmationsSettings();
this.add(confirmationSettings);

if (osparc.product.Utils.showPreferencesExperimental()) {
const experimentalSettings = this.__createExperimentalSettings();
this.add(experimentalSettings);
}
},

members: {
Expand Down Expand Up @@ -72,11 +77,6 @@ qx.Class.define("osparc.desktop.preferences.pages.ConfirmationsPage", {
}, this);
box.add(cbConfirmDeleteStudy);

const cbConfirmDemoteOrgnaization = new qx.ui.form.CheckBox(this.tr("Demote Organization collaboration"));
preferencesSettings.bind("confirmDemoteOrgnaization", cbConfirmDemoteOrgnaization, "value");
cbConfirmDemoteOrgnaization.bind("value", preferencesSettings, "confirmDemoteOrgnaization");
box.add(cbConfirmDemoteOrgnaization);

if (!(osparc.product.Utils.isProduct("tis") || osparc.product.Utils.isProduct("s4llite"))) {
const cbConfirmDeleteNode = new qx.ui.form.CheckBox(this.tr("Delete a Node"));
preferencesSettings.bind("confirmDeleteNode", cbConfirmDeleteNode, "value");
Expand Down Expand Up @@ -110,6 +110,25 @@ qx.Class.define("osparc.desktop.preferences.pages.ConfirmationsPage", {
box.add(cbSnapNodeToGrid);
}

return box;
},

__createExperimentalSettings: function() {
// layout
const box = this._createSectionBox("Experimental preferences");

const label = this._createHelpLabel(this.tr(
"This is a list of experimental preferences"
));
box.add(label);

const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance();

const cbAutoPorts = new qx.ui.form.CheckBox(this.tr("Connect ports automatically"));
preferencesSettings.bind("autoConnectPorts", cbAutoPorts, "value");
cbAutoPorts.bind("value", preferencesSettings, "autoConnectPorts");
box.add(cbAutoPorts);

return box;
}
}
Expand Down
Loading