alova - refactor wifi scan

This commit is contained in:
Proddy
2023-06-18 10:46:50 +02:00
parent ed55a96b80
commit b1d666d7b9
14 changed files with 58 additions and 60 deletions

View File

@@ -35,9 +35,10 @@ export const alovaInstance = createAlova({
responded: {
onSuccess: async (response) => {
if (response.status === 202) {
throw new Error('Wait');
} else if (response.status === 205) {
// if (response.status === 202) {
// throw new Error('Wait'); // wifi scan in progress
// } else
if (response.status === 205) {
throw new Error('Reboot required');
} else if (response.status === 400) {
throw new Error('Request Failed');

View File

@@ -4,7 +4,10 @@ import type { WiFiNetworkList, NetworkSettings, NetworkStatus } from 'types';
export const readNetworkStatus = () => alovaInstance.Get<NetworkStatus>('/rest/networkStatus');
export const scanNetworks = () => alovaInstance.Get('/rest/scanNetworks');
export const listNetworks = () => alovaInstance.Get<WiFiNetworkList>('/rest/listNetworks');
export const listNetworks = () =>
alovaInstance.Get<WiFiNetworkList>('/rest/listNetworks', {
name: 'listNetworks'
});
export const readNetworkSettings = () =>
alovaInstance.Get<NetworkSettings>('/rest/networkSettings', { name: 'networkSettings' });
export const updateNetworkSettings = (wifiSettings: NetworkSettings) =>

View File

@@ -3,7 +3,7 @@ import type { AxiosPromise } from 'axios';
import type { SecuritySettings, Token } from 'types';
// TODO move to Alova
// TODO move these 3 to Alova
export function readSecuritySettings(): AxiosPromise<SecuritySettings> {
return AXIOS.get('/securitySettings');
}

View File

@@ -4,10 +4,8 @@ import type { AxiosPromise } from 'axios';
import type { OTASettings, SystemStatus, LogSettings } from 'types';
export const readSystemStatus = (timeout?: number) =>
alovaInstance.Get<SystemStatus>('/rest/systemStatus', {
params: { timeout }
});
// SystemStatus - also used to ping in Restart monitor
export const readSystemStatus = () => alovaInstance.Get<SystemStatus>('/rest/systemStatus');
// commands
export const restart = () => alovaInstance.Post('/rest/restart');
@@ -23,5 +21,6 @@ export const readLogSettings = () => alovaInstance.Get<LogSettings>(`/rest/logSe
export const updateLogSettings = (data: any) => alovaInstance.Post('/rest/logSettings', data);
export const fetchLog = () => alovaInstance.Post('/rest/fetchLog');
// TODO fileupload move to Alova
export const uploadFile = (file: File, config?: FileUploadConfig): AxiosPromise<void> =>
startUploadFile('/uploadFile', file, config);