fix wifi settings
This commit is contained in:
@ -26,7 +26,8 @@ interface WiFiState {
|
||||
selectedSecured: boolean,
|
||||
foundWiFis: WiFiNetwork[],
|
||||
scanning: boolean,
|
||||
status: status
|
||||
status: status,
|
||||
password: string,
|
||||
}
|
||||
|
||||
type status = "NONE" | "SELECTION_FAILURE" | "CONNECTING" | "PASSWORD_NEEDED" | "FAILURE" | "CONNECTED" | 'SCAN_FAILURE';
|
||||
@ -41,6 +42,7 @@ export default class WiFi extends Component<{}, WiFiState> {
|
||||
foundWiFis: [],
|
||||
scanning: false,
|
||||
status: "NONE",
|
||||
password: "",
|
||||
};
|
||||
}
|
||||
|
||||
@ -100,7 +102,7 @@ export default class WiFi extends Component<{}, WiFiState> {
|
||||
...prevState,
|
||||
status: "CONNECTING"
|
||||
}));
|
||||
window.api.request('WIFI_CONNECT', {data: this.state.currentSelection}).then((answer: IPCAnswer) => {
|
||||
window.api.request('WIFI_CONNECT', {data: {ssid: this.state.currentSelection, psk: this.state.password}}).then((answer: IPCAnswer) => {
|
||||
this.setState((prevState) => ({
|
||||
...prevState,
|
||||
status: answer.status ? "CONNECTED" : "FAILURE"
|
||||
@ -149,9 +151,10 @@ export default class WiFi extends Component<{}, WiFiState> {
|
||||
</Typography>
|
||||
<Typography id="transition-modal-description" sx={{mt: 2}}>
|
||||
<Alert variant={this.state.status == "FAILURE" ? "filled" : "standard"}
|
||||
severity={this.state.status.includes("FAILURE") ? "error" : "info"}>
|
||||
severity={this.state.status.includes("FAILURE") ? "error" : (this.state.status == "CONNECTED" ? "success" : "info")}>
|
||||
{this.state.status == "NONE" && "Bitte wählen Sie eins der folgenden Netzwerke aus"}
|
||||
{this.state.status == "CONNECTING" && "Verbinden..." }
|
||||
{this.state.status == "CONNECTED" && "Verbunden!" }
|
||||
{this.state.status == "SCAN_FAILURE" && "Das Scannen ist fehlgeschlagen. - Möglicherweise fehlen Berechtigungen, um Netzwerke zu scannen, oder es befindet sich kein WLAN-Interface auf diesem Gerät." }
|
||||
{this.state.status == "FAILURE" && "Verbindungsfehler!" }
|
||||
{this.state.status == "SELECTION_FAILURE" && "Bitte zunächst ein Netzwerk auswählen!" }
|
||||
@ -193,7 +196,10 @@ export default class WiFi extends Component<{}, WiFiState> {
|
||||
</FormControl>
|
||||
|
||||
<FormControl sx={{m: 1, minWidth: '70%'}}>
|
||||
<TextField id="password" label="Passwort" disabled={this.state.scanning || !this.state.selectedSecured} variant="outlined" />
|
||||
<TextField id="password" value={this.state.password} onChange={evt => this.setState(prev => ({
|
||||
...prev,
|
||||
password: evt.target.value
|
||||
}))} label="Passwort" disabled={this.state.scanning || !this.state.selectedSecured} variant="outlined" />
|
||||
|
||||
</FormControl>
|
||||
|
||||
@ -219,7 +225,7 @@ export default class WiFi extends Component<{}, WiFiState> {
|
||||
<FormControl sx={{ml: 2, minWidth: '20%'}}>
|
||||
<Button variant="contained" disabled={this.state.status == "CONNECTING"}
|
||||
onClick={() => this.handleClose()}
|
||||
color="error">Abbrechen</Button>
|
||||
color="secondary">Schließen</Button>
|
||||
</FormControl>
|
||||
</Typography>
|
||||
</Box>
|
||||
|
Reference in New Issue
Block a user