Alova 3 now working

This commit is contained in:
proddy
2024-08-10 11:39:31 +02:00
parent bb98042957
commit a718f8ed0d
31 changed files with 117 additions and 409 deletions

View File

@@ -19,8 +19,7 @@ import {
Table
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
import { updateState, useRequest } from 'alova';
// import { updateState, useRequest } from 'alova/client'; // TODO replace when Alova 3 is released
import { updateState, useRequest } from 'alova/client';
import {
BlockNavigation,
ButtonRow,

View File

@@ -39,8 +39,7 @@ import {
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
import { dialogStyle } from 'CustomTheme';
import { useRequest } from 'alova';
// import { useRequest } from 'alova/client' // TODO replace when Alova 3 is released
import { useRequest } from 'alova/client';
import RestartMonitor from 'app/status/RestartMonitor';
import {
BlockNavigation,
@@ -111,25 +110,13 @@ const Customizations = () => {
}
);
// TODO Alova 3 code...
// const { send: sendDeviceEntities } = useRequest(
// (data: number) => readDeviceEntities(data),
// {
// initialData: [],
// immediate: false
// }
// ).onSuccess((event) => {
// setOriginalSettings(event.data);
// });
const { send: sendDeviceEntities, onSuccess } = useRequest(
const { send: sendDeviceEntities } = useRequest(
(data: number) => readDeviceEntities(data),
{
initialData: [],
immediate: false
}
);
onSuccess((event) => {
).onSuccess((event) => {
setOriginalSettings(event.data);
});

View File

@@ -56,8 +56,7 @@ import {
import { useTheme } from '@table-library/react-table-library/theme';
import type { Action, State } from '@table-library/react-table-library/types/common';
import { dialogStyle } from 'CustomTheme';
// import { useRequest } from 'alova/client' // TODO replace when Alova 3 is released
import { useRequest } from 'alova';
import { useRequest } from 'alova/client';
import { ButtonRow, MessageBox, SectionContent, useLayoutTitle } from 'components';
import { AuthenticatedContext } from 'contexts/authentication';
import { useI18nContext } from 'i18n/i18n-react';

View File

@@ -17,8 +17,7 @@ import {
Typography
} from '@mui/material';
// import { useRequest } from 'alova/client' // TODO replace when Alova 3 is released
import { useRequest } from 'alova';
import { useRequest } from 'alova/client';
import { SectionContent, useLayoutTitle } from 'components';
import { useI18nContext } from 'i18n/i18n-react';
@@ -29,44 +28,23 @@ const Help = () => {
const { LL } = useI18nContext();
useLayoutTitle(LL.HELP_OF(''));
const { send: getAPI, onSuccess: onGetAPI } = useRequest(
(data: APIcall) => API(data),
{
immediate: false
}
);
onGetAPI((event) => {
const { send: getAPI } = useRequest((data: APIcall) => API(data), {
immediate: false
}).onSuccess((event) => {
const anchor = document.createElement('a');
anchor.href = URL.createObjectURL(
new Blob([JSON.stringify(event.data, null, 2)], {
type: 'text/plain'
})
);
anchor.download =
'emsesp_' + event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt';
'emsesp_' + event.args[0].device + '_' + event.args[0].entity + '.txt';
anchor.click();
URL.revokeObjectURL(anchor.href);
toast.info(LL.DOWNLOAD_SUCCESSFUL());
});
// Alova 3 code...
// const { send: getAPI } = useRequest((data: APIcall) => API(data), {
// immediate: false
// }).onSuccess((event) => {
// const anchor = document.createElement('a');
// anchor.href = URL.createObjectURL(
// new Blob([JSON.stringify(event.data, null, 2)], {
// type: 'text/plain'
// })
// );
//
// anchor.download =
// 'emsesp_' + event.args[0].device + '_' + event.args[0].entity + '.txt';
// anchor.click();
// URL.revokeObjectURL(anchor.href);
// toast.info(LL.DOWNLOAD_SUCCESSFUL());
// });
const callAPI = async (device: string, entity: string) => {
await getAPI({ device, entity, id: 0 }).catch((error: Error) => {
toast.error(error.message);

View File

@@ -17,8 +17,7 @@ import {
Table
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
import { updateState, useRequest } from 'alova';
// import { updateState, useRequest } from 'alova/client'; // TODO replace when Alova 3 is released
import { updateState, useRequest } from 'alova/client';
import {
BlockNavigation,
ButtonRow,

View File

@@ -18,8 +18,7 @@ import {
Table
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
// import { updateState, useRequest } from 'alova/client'; // TODO replace when Alova 3 is released
import { updateState, useRequest } from 'alova';
import { updateState, useRequest } from 'alova/client';
import {
BlockNavigation,
ButtonRow,

View File

@@ -20,8 +20,7 @@ import {
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
import type { State } from '@table-library/react-table-library/types/common';
// import { useRequest } from 'alova/client' // TODO replace when Alova 3 is released
import { useRequest } from 'alova';
import { useRequest } from 'alova/client';
import { ButtonRow, SectionContent, useLayoutTitle } from 'components';
import { AuthenticatedContext } from 'contexts/authentication';
import { useI18nContext } from 'i18n/i18n-react';