Fixed wifi signal quality display when there are multiple copies of the same ssid.

Also ensured that all dialogs set their InitialFocus correctly.
This commit is contained in:
David Carley
2022-08-31 05:57:47 +00:00
parent 3a68076022
commit 6a63bd7a12
9 changed files with 37 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import TextField from "@smui/textfield"; import TextField from "@smui/textfield";
import MessageDialog from "$dialogs/MessageDialog.svelte"; import MessageDialog from "$dialogs/MessageDialog.svelte";
@@ -73,7 +73,10 @@
<Content id="change-hostname-dialog-content"> <Content id="change-hostname-dialog-content">
<TextField <TextField
bind:value={hostname} bind:value={hostname}
use={[[virtualKeyboardChange, (newValue) => (hostname = newValue)]]} use={[
InitialFocus,
[virtualKeyboardChange, (newValue) => (hostname = newValue)],
]}
label="New Hostname" label="New Hostname"
spellcheck="false" spellcheck="false"
variant="filled" variant="filled"

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import TextField from "@smui/textfield"; import TextField from "@smui/textfield";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import { ControllerMethods } from "$lib/RegisterControllerMethods"; import { ControllerMethods } from "$lib/RegisterControllerMethods";
@@ -31,7 +31,10 @@
label="Absolute" label="Absolute"
type="number" type="number"
bind:value bind:value
use={[[virtualKeyboardChange, (newValue) => (value = newValue)]]} use={[
InitialFocus,
[virtualKeyboardChange, (newValue) => (value = newValue)],
]}
variant="filled" variant="filled"
style="width: 100%;" style="width: 100%;"
/> />

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
export let open: boolean; export let open: boolean;
@@ -23,7 +23,7 @@
{#if !noaction} {#if !noaction}
<Actions> <Actions>
<Button defaultAction> <Button defaultAction use={[InitialFocus]}>
<Label>OK</Label> <Label>OK</Label>
</Button> </Button>
</Actions> </Actions>

View File

@@ -1,5 +1,5 @@
<script type="ts"> <script type="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import Radio from "@smui/radio"; import Radio from "@smui/radio";
import FormField from "@smui/form-field"; import FormField from "@smui/form-field";
@@ -53,7 +53,7 @@
</Content> </Content>
<Actions> <Actions>
<Button> <Button use={[InitialFocus]}>
<Label>Cancel</Label> <Label>Cancel</Label>
</Button> </Button>
<Button <Button

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import TextField from "@smui/textfield"; import TextField from "@smui/textfield";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import { ControllerMethods } from "$lib/RegisterControllerMethods"; import { ControllerMethods } from "$lib/RegisterControllerMethods";
@@ -43,7 +43,10 @@
label="Position" label="Position"
type="number" type="number"
bind:value bind:value
use={[[virtualKeyboardChange, (newValue) => (value = newValue)]]} use={[
InitialFocus,
[virtualKeyboardChange, (newValue) => (value = newValue)],
]}
spellcheck="false" spellcheck="false"
variant="filled" variant="filled"
style="width: 100%;" style="width: 100%;"

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import TextField from "@smui/textfield"; import TextField from "@smui/textfield";
import CircularProgress from "@smui/circular-progress"; import CircularProgress from "@smui/circular-progress";
@@ -154,7 +154,10 @@
<Label>Date & Time</Label> <Label>Date & Time</Label>
<TextField <TextField
bind:value bind:value
use={[[virtualKeyboardChange, (newValue) => (value = newValue)]]} use={[
InitialFocus,
[virtualKeyboardChange, (newValue) => (value = newValue)],
]}
label="Time" label="Time"
type="datetime-local" type="datetime-local"
variant="filled" variant="filled"

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog"; import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button"; import Button, { Label } from "@smui/button";
import LinearProgress from "@smui/linear-progress"; import LinearProgress from "@smui/linear-progress";
@@ -71,7 +71,7 @@
</Content> </Content>
<Actions> <Actions>
<Button on:click={onCancel}> <Button on:click={onCancel} use={[InitialFocus]}>
<Label>Cancel</Label> <Label>Cancel</Label>
</Button> </Button>
</Actions> </Actions>

View File

@@ -58,7 +58,10 @@
{#if needPassword} {#if needPassword}
<TextField <TextField
bind:value={password} bind:value={password}
use={[[virtualKeyboardChange, (newValue) => (password = newValue)]]} use={[
InitialFocus,
[virtualKeyboardChange, (newValue) => (password = newValue)],
]}
label="Password" label="Password"
spellcheck="false" spellcheck="false"
variant="filled" variant="filled"
@@ -91,7 +94,6 @@
<Button <Button
defaultAction defaultAction
use={[InitialFocus]}
on:click={onConfirm} on:click={onConfirm}
disabled={needPassword && (password.length < 8 || password.length > 128)} disabled={needPassword && (password.length < 8 || password.length > 128)}
> >

View File

@@ -43,7 +43,13 @@ export function processNetworkInfo(rawNetworkInfo: NetworkInfo) {
if (network.Name) { if (network.Name) {
network.lastSeen = now; network.lastSeen = now;
network.active = rawNetworkInfo.wifi.ssid === network.Name; network.active = rawNetworkInfo.wifi.ssid === network.Name;
networksByName[network.Name] = network;
// There can be many entries for the same ssid, so
// we want to take the one with the highest quality
const currentNetwork = networksByName[network.Name] ?? { Quality: 0 };
if (network.Quality >= currentNetwork.Quality) {
networksByName[network.Name] = network;
}
} }
} }