mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-26 00:21:36 +01:00
Set best Wi-Fi HT mode depending on the checked frequency
This commit is contained in:
parent
52cdaf5bc5
commit
b95cfb664d
|
@ -64,6 +64,7 @@ DeviceForm.propTypes = {
|
||||||
channel: PropTypes.string.isRequired,
|
channel: PropTypes.string.isRequired,
|
||||||
guest_wifi: PropTypes.object.isRequired,
|
guest_wifi: PropTypes.object.isRequired,
|
||||||
encryption: PropTypes.string.isRequired,
|
encryption: PropTypes.string.isRequired,
|
||||||
|
available_bands: PropTypes.array.isRequired,
|
||||||
}),
|
}),
|
||||||
formErrors: PropTypes.object.isRequired,
|
formErrors: PropTypes.object.isRequired,
|
||||||
setFormValue: PropTypes.func.isRequired,
|
setFormValue: PropTypes.func.isRequired,
|
||||||
|
@ -87,6 +88,7 @@ function DeviceForm({
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const deviceID = formData.id;
|
const deviceID = formData.id;
|
||||||
|
const bnds = formData.available_bands;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -159,18 +161,24 @@ function DeviceForm({
|
||||||
value={formData.hwmode}
|
value={formData.hwmode}
|
||||||
helpText={HELP_TEXTS.hwmode}
|
helpText={HELP_TEXTS.hwmode}
|
||||||
inline
|
inline
|
||||||
onChange={setFormValue((value) => ({
|
onChange={setFormValue((value) => {
|
||||||
devices: {
|
// Get the last item in an array of available HT modes
|
||||||
[deviceIndex]: {
|
const [best2] = bnds[0].available_htmodes.slice(-1);
|
||||||
hwmode: { $set: value },
|
const [best5] = bnds[1].available_htmodes.slice(-1);
|
||||||
channel: { $set: "0" },
|
return {
|
||||||
htmode: {
|
devices: {
|
||||||
$set:
|
[deviceIndex]: {
|
||||||
value === "11a" ? "VHT80" : "HT20",
|
hwmode: { $set: value },
|
||||||
|
channel: { $set: "0" },
|
||||||
|
htmode: {
|
||||||
|
$set:
|
||||||
|
// Set HT mode depending on checked frequency
|
||||||
|
value === "11a" ? best5 : best2,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
}))}
|
})}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user