move uploadURL as an action

This commit is contained in:
proddy
2024-09-29 11:08:49 +02:00
parent 93066e4836
commit ab040e120e
11 changed files with 70 additions and 67 deletions

View File

@@ -13,7 +13,7 @@ export const updateLogSettings = (data: LogSettings) =>
alovaInstance.Post('/rest/logSettings', data);
export const fetchLogES = () => alovaInstance.Get('/es/log');
// Get versions from github
// Get versions from GitHub
export const getStableVersion = () =>
alovaInstanceGH.Get('latest', {
transform(response: { data: { name: string } }) {
@@ -34,9 +34,3 @@ export const uploadFile = (file: File) => {
timeout: 60000 // override timeout for uploading firmware - 1 minute
});
};
export const uploadURL = (data: { url: string }) =>
alovaInstance.Post('/rest/uploadURL', data);
export const checkUpgrade = (data: { version: string }) =>
alovaInstance.Post('/rest/checkUpgrade', data);

View File

@@ -38,14 +38,17 @@ const Help = () => {
const [customSupportIMG, setCustomSupportIMG] = useState<string | null>(null);
const [customSupportHTML, setCustomSupportHTML] = useState<string | null>(null);
useRequest(() => callAction({ action: 'customSupport' })).onSuccess(
(event: { data: { img_url: string; html: string[] } }) => {
if (event.data) {
setCustomSupportIMG(event.data.img_url);
setCustomSupportHTML(event.data.html.join('<br/>'));
useRequest(() => callAction({ action: 'customSupport' })).onSuccess((event) => {
if (event && event.data && Object.keys(event.data).length !== 0) {
const data = event.data.Support;
if (data.img_url) {
setCustomSupportIMG(data.img_url);
}
if (data.html) {
setCustomSupportHTML(data.html.join('<br/>'));
}
}
);
});
const { send: sendExportAllValues } = useRequest(
() => callAction({ action: 'export', param: 'allvalues' }),
@@ -97,7 +100,7 @@ const Help = () => {
<Box
component="img"
sx={{
maxHeight: 250
maxHeight: { xs: 100, md: 250 }
}}
src={
customSupportIMG

View File

@@ -19,12 +19,7 @@ import Grid from '@mui/material/Grid2';
import * as SystemApi from 'api/system';
import { API, callAction } from 'api/app';
import {
checkUpgrade,
getDevVersion,
getStableVersion,
uploadURL
} from 'api/system';
import { getDevVersion, getStableVersion } from 'api/system';
import { dialogStyle } from 'CustomTheme';
import { useRequest } from 'alova/client';
@@ -81,7 +76,7 @@ const DownloadUpload = () => {
} = useRequest(SystemApi.readSystemStatus);
const { send: sendUploadURL } = useRequest(
(data: { url: string }) => uploadURL(data),
(url: string) => callAction({ action: 'uploadURL', param: url }),
{
immediate: false
}
@@ -143,7 +138,7 @@ const DownloadUpload = () => {
};
const installFirmwareURL = async (url: string) => {
await sendUploadURL({ url: url }).catch((error: Error) => {
await sendUploadURL(url).catch((error: Error) => {
toast.error(error.message);
});
setRestarting(true);