Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Adding select to config page
Browse files Browse the repository at this point in the history
  • Loading branch information
maakbaas committed Jun 16, 2021
1 parent 7d3da8d commit 419bccd
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 92 deletions.
2 changes: 2 additions & 0 deletions docs/config-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ An example of how this file could look is shown below:

Supported data types are: bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, float and char. The length argument is mandatory for datatype char to indicate the length of the string. Variable length strings are not supported. Also, arrays are not supported for now.

Adding the field `"control": "select",` will turn the item into a drop down menu, with the options defined as `"options": [1, 2, 3]`.

There are a few unique parameters:

* The configuration parameter `projectName` is unique in this framework. You can remove it, but if you use a parameter with this name, it will be shown as the header title in the web interface :).
Expand Down
33 changes: 21 additions & 12 deletions gui/js/comp/DashboardItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ const Control = styled.p`
max-width:calc(100% - 40px);
}
select {
width:450px;
padding: 0.3em;
max-width:100%;
}
button {
padding:0.4em 0.5em;
}
Expand Down Expand Up @@ -214,12 +208,27 @@ export function DashboardItems(props) {
break;

case "config":
confItems = <>{confItems}
<p>
<label htmlFor={props.items[i].name}><b>{props.items[i].label || props.items[i].name}</b>: {rangeInfo}</label>
<input type={inputType} id={props.items[i].name} name={props.items[i].name} value={value} {...conditionalAttributes} disabled={props.items[i].disabled} />
</p>
</>;
if (inputType == "select") {
let options;
for (let i = 0; i < conditionalAttributes.options.length; i++) {
options = <>{options}<option value={conditionalAttributes.options[i]}>{conditionalAttributes.options[i]}</option></>;
}
confItems = <>{confItems}
<p>
<label htmlFor={props.items[i].name}><b>{props.items[i].label || props.items[i].name}</b>: {rangeInfo}</label>
<select id={props.items[i].name} name={props.items[i].name} value={value} disabled={props.items[i].disabled}>
{options}
</select>
</p>
</>;
} else {
confItems = <>{confItems}
<p>
<label htmlFor={props.items[i].name}><b>{props.items[i].label || props.items[i].name}</b>: {rangeInfo}</label>
<input type={inputType} id={props.items[i].name} name={props.items[i].name} value={value} {...conditionalAttributes} disabled={props.items[i].disabled} />
</p>
</>;
}
break;

}
Expand Down
6 changes: 6 additions & 0 deletions gui/js/comp/UiComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ export const Form = styled.form`
padding:0.3em;
}
select {
width:450px;
padding: 0.3em;
max-width:100%;
}
input[type=checkbox] {
width: auto;
margin:12px 0px;
Expand Down
Loading

0 comments on commit 419bccd

Please sign in to comment.