mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
alova - add interceptor
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { alovaInstance, startUploadFile } from './endpoints';
|
||||
import { alovaInstance, alovaInstanceGH, startUploadFile } from './endpoints';
|
||||
import type { FileUploadConfig } from './endpoints';
|
||||
import type { AxiosPromise } from 'axios';
|
||||
|
||||
import type { OTASettings, SystemStatus, LogSettings } from 'types';
|
||||
import type { OTASettings, SystemStatus, LogSettings, Version } from 'types';
|
||||
|
||||
// SystemStatus - also used to ping in Restart monitor
|
||||
export const readSystemStatus = () => alovaInstance.Get<SystemStatus>('/rest/systemStatus');
|
||||
@@ -21,6 +21,28 @@ 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
|
||||
// Get versions from github
|
||||
export const getStableVersion = () =>
|
||||
alovaInstanceGH.Get<Version>('releases/latest', {
|
||||
transformData(reponse: any) {
|
||||
return {
|
||||
version: reponse.data.name,
|
||||
url: reponse.data.assets[1].browser_download_url,
|
||||
changelog: reponse.data.assets[0].browser_download_url
|
||||
};
|
||||
}
|
||||
});
|
||||
export const getDevVersion = () =>
|
||||
alovaInstanceGH.Get<Version>('releases/tags/latest', {
|
||||
transformData(reponse: any) {
|
||||
return {
|
||||
version: reponse.data.name.split(/\s+/).splice(-1),
|
||||
url: reponse.data.assets[1].browser_download_url,
|
||||
changelog: reponse.data.assets[0].browser_download_url
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// TODO fileupload move to alova
|
||||
export const uploadFile = (file: File, config?: FileUploadConfig): AxiosPromise<void> =>
|
||||
startUploadFile('/uploadFile', file, config);
|
||||
|
||||
Reference in New Issue
Block a user