🛜 Simplify wifi services
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
async function scanNetworks() {
|
async function scanNetworks() {
|
||||||
scanActive = true;
|
scanActive = true;
|
||||||
await api.get('/api/scanNetworks');
|
|
||||||
if ((await pollingResults()) == false) {
|
if ((await pollingResults()) == false) {
|
||||||
pollingId = setInterval(() => pollingResults(), 1000);
|
pollingId = setInterval(() => pollingResults(), 1000);
|
||||||
}
|
}
|
||||||
@@ -41,8 +40,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function pollingResults() {
|
async function pollingResults() {
|
||||||
const result = await api.get<NetworkList>('/api/listNetworks');
|
|
||||||
if (result.isErr()){
|
if (result.isErr()){
|
||||||
|
await api.get('/api/wifi/scan');
|
||||||
|
const result = await api.get<NetworkList>('/api/wifi/networks');
|
||||||
console.error(`Error occurred while fetching: `, result.inner);
|
console.error(`Error occurred while fetching: `, result.inner);
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
let formErrorhostname = false;
|
let formErrorhostname = false;
|
||||||
|
|
||||||
async function getWifiStatus() {
|
async function getWifiStatus() {
|
||||||
const result = await api.get<WifiStatus>('/api/wifiStatus');
|
|
||||||
if (result.isErr()) {
|
if (result.isErr()) {
|
||||||
console.error(`Error occurred while fetching: `, result.inner);
|
console.error(`Error occurred while fetching: `, result.inner);
|
||||||
return;
|
return;
|
||||||
@@ -87,7 +86,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getWifiSettings() {
|
async function getWifiSettings() {
|
||||||
const result = await api.get<WifiSettings>('/api/wifiSettings');
|
|
||||||
if (result.isErr()) {
|
if (result.isErr()) {
|
||||||
console.error(`Error occurred while fetching: `, result.inner);
|
console.error(`Error occurred while fetching: `, result.inner);
|
||||||
return;
|
return;
|
||||||
@@ -107,7 +105,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function postWiFiSettings(data: WifiSettings) {
|
async function postWiFiSettings(data: WifiSettings) {
|
||||||
const result = await api.post<WifiSettings>('/api/wifiSettings', data);
|
|
||||||
if (result.isErr()) {
|
if (result.isErr()) {
|
||||||
console.error(`Error occurred while fetching: `, result.inner);
|
console.error(`Error occurred while fetching: `, result.inner);
|
||||||
notifications.error('User not authorized.', 3000);
|
notifications.error('User not authorized.', 3000);
|
||||||
@@ -285,6 +282,9 @@
|
|||||||
dndNetworkList = reorder(dndNetworkList, from.index, to.index);
|
dndNetworkList = reorder(dndNetworkList, from.index, to.index);
|
||||||
console.log(dndNetworkList);
|
console.log(dndNetworkList);
|
||||||
}
|
}
|
||||||
|
const result = await api.get<WifiStatus>('/api/wifi/status');
|
||||||
|
const result = await api.get<WifiSettings>('/api/wifi/settings');
|
||||||
|
const result = await api.post<WifiSettings>('/api/wifi/settings', data);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SettingsCard collapsible={false}>
|
<SettingsCard collapsible={false}>
|
||||||
|
|||||||
Reference in New Issue
Block a user