mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-27 00:31:35 +01:00
Compare commits
2 Commits
29e7ac4e34
...
9426c5a3bb
Author | SHA1 | Date | |
---|---|---|---|
|
9426c5a3bb | ||
|
cdf39345f1 |
|
@ -156,25 +156,25 @@ function DeviceForm({
|
||||||
|
|
||||||
<RadioSet
|
<RadioSet
|
||||||
name={`band-${deviceID}`}
|
name={`band-${deviceID}`}
|
||||||
label={_("Band")}
|
label="GHz"
|
||||||
choices={getBandChoices(formData)}
|
choices={getBandChoices(formData)}
|
||||||
value={formData.band}
|
value={formData.band}
|
||||||
helpText={HELP_TEXTS.band}
|
helpText={HELP_TEXTS.band}
|
||||||
inline
|
inline
|
||||||
onChange={setFormValue((value) => {
|
onChange={setFormValue((value) => {
|
||||||
// Find the selected band
|
// Get the last item in an array of available HT modes
|
||||||
const selectedBand = bnds.find(
|
const [best2] = bnds[0].available_htmodes.slice(-1);
|
||||||
(band) => band.band === value
|
const [best5] = bnds[1].available_htmodes.slice(-1);
|
||||||
);
|
|
||||||
// Get the last item in the available HT modes for the selected band
|
|
||||||
const bestHtmode =
|
|
||||||
selectedBand.available_htmodes.slice(-1)[0];
|
|
||||||
return {
|
return {
|
||||||
devices: {
|
devices: {
|
||||||
[deviceIndex]: {
|
[deviceIndex]: {
|
||||||
band: { $set: value },
|
band: { $set: value },
|
||||||
channel: { $set: "0" },
|
channel: { $set: "0" },
|
||||||
htmode: { $set: bestHtmode },
|
htmode: {
|
||||||
|
$set:
|
||||||
|
// Set HT mode depending on checked frequency
|
||||||
|
value === "11a" ? best5 : best2,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ function getHtmodeChoices(device) {
|
||||||
|
|
||||||
function getBandChoices(device) {
|
function getBandChoices(device) {
|
||||||
return device.available_bands.map((availableBand) => ({
|
return device.available_bands.map((availableBand) => ({
|
||||||
label: `${BANDS[availableBand.band]} GHz`,
|
label: BANDS[availableBand.band],
|
||||||
value: availableBand.band,
|
value: availableBand.band,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ describe("<WiFiSettings/>", () => {
|
||||||
it("Snapshot 2.4 GHz", () => {
|
it("Snapshot 2.4 GHz", () => {
|
||||||
fireEvent.click(getByText("Wi-Fi 1"));
|
fireEvent.click(getByText("Wi-Fi 1"));
|
||||||
const enabledRender = asFragment();
|
const enabledRender = asFragment();
|
||||||
fireEvent.click(getAllByText(/2.4/)[0]);
|
fireEvent.click(getAllByText("2.4")[0]);
|
||||||
expect(diffSnapshot(enabledRender, asFragment())).toMatchSnapshot();
|
expect(diffSnapshot(enabledRender, asFragment())).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ describe("<WiFiSettings/>", () => {
|
||||||
|
|
||||||
it("Post form: 2.4 GHz", () => {
|
it("Post form: 2.4 GHz", () => {
|
||||||
fireEvent.click(getByText("Wi-Fi 1"));
|
fireEvent.click(getByText("Wi-Fi 1"));
|
||||||
fireEvent.click(getAllByText(/2.4/)[0]);
|
fireEvent.click(getAllByText("2.4")[0]);
|
||||||
|
|
||||||
fireEvent.click(getByText("Save"));
|
fireEvent.click(getByText("Save"));
|
||||||
expect(mockAxios.post).toBeCalled();
|
expect(mockAxios.post).toBeCalled();
|
||||||
|
|
|
@ -555,7 +555,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
||||||
+ class="d-block"
|
+ class="d-block"
|
||||||
+ for="6"
|
+ for="6"
|
||||||
+ >
|
+ >
|
||||||
+ Band
|
+ GHz
|
||||||
+ </label>
|
+ </label>
|
||||||
+ <div
|
+ <div
|
||||||
+ class="mb-3 form-check form-check-inline"
|
+ class="mb-3 form-check form-check-inline"
|
||||||
|
@ -571,7 +571,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
||||||
+ class="form-check-label"
|
+ class="form-check-label"
|
||||||
+ for="band-0-0"
|
+ for="band-0-0"
|
||||||
+ >
|
+ >
|
||||||
+ 2.4 GHz
|
+ 2.4
|
||||||
+ </label>
|
+ </label>
|
||||||
+ </div>
|
+ </div>
|
||||||
+ <div
|
+ <div
|
||||||
|
@ -589,7 +589,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
||||||
+ class="form-check-label"
|
+ class="form-check-label"
|
||||||
+ for="band-0-1"
|
+ for="band-0-1"
|
||||||
+ >
|
+ >
|
||||||
+ 5 GHz
|
+ 5
|
||||||
+ </label>
|
+ </label>
|
||||||
+ </div>
|
+ </div>
|
||||||
+ <div
|
+ <div
|
||||||
|
|
Loading…
Reference in New Issue
Block a user