mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
updates #3
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
"@types/react": "^18.2.8",
|
"@types/react": "^18.2.8",
|
||||||
"@types/react-dom": "^18.2.4",
|
"@types/react-dom": "^18.2.4",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"alova": "^2.5.4",
|
"alova": "^2.5.5",
|
||||||
"async-validator": "^4.2.5",
|
"async-validator": "^4.2.5",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { xhrRequestAdapter } from '@alova/adapter-xhr';
|
import { xhrRequestAdapter } from '@alova/adapter-xhr';
|
||||||
import { createAlova, useRequest } from 'alova';
|
import { createAlova } from 'alova';
|
||||||
import GlobalFetch from 'alova/GlobalFetch';
|
import GlobalFetch from 'alova/GlobalFetch';
|
||||||
import ReactHook from 'alova/react';
|
import ReactHook from 'alova/react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import { formatValue } from './deviceValue';
|
|||||||
|
|
||||||
import { DeviceValueUOM_s, DeviceEntityMask, DeviceType } from './types';
|
import { DeviceValueUOM_s, DeviceEntityMask, DeviceType } from './types';
|
||||||
import { deviceValueItemValidation } from './validators';
|
import { deviceValueItemValidation } from './validators';
|
||||||
import type { Device, CoreData, DeviceData, DeviceValue } from './types';
|
import type { Device, DeviceValue } from './types';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { ButtonRow, SectionContent, MessageBox } from 'components';
|
import { ButtonRow, SectionContent, MessageBox } from 'components';
|
||||||
import { AuthenticatedContext } from 'contexts/authentication';
|
import { AuthenticatedContext } from 'contexts/authentication';
|
||||||
@@ -74,10 +74,9 @@ const DashboardDevices: FC = () => {
|
|||||||
devices: []
|
devices: []
|
||||||
},
|
},
|
||||||
force: true,
|
force: true,
|
||||||
immediate: false
|
immediate: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO prevent firing when page is loaded
|
|
||||||
const { data: deviceData, send: readDeviceData } = useRequest((id) => EMSESP.readDeviceData(id), {
|
const { data: deviceData, send: readDeviceData } = useRequest((id) => EMSESP.readDeviceData(id), {
|
||||||
initialData: {
|
initialData: {
|
||||||
data: []
|
data: []
|
||||||
@@ -86,7 +85,6 @@ const DashboardDevices: FC = () => {
|
|||||||
immediate: false
|
immediate: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO prevent firing when page is loaded
|
|
||||||
const { loading: submitting, send: writeDeviceValue } = useRequest(
|
const { loading: submitting, send: writeDeviceValue } = useRequest(
|
||||||
(id: number, deviceValue: DeviceValue) => EMSESP.writeDeviceValue(id, deviceValue),
|
(id: number, deviceValue: DeviceValue) => EMSESP.writeDeviceValue(id, deviceValue),
|
||||||
{
|
{
|
||||||
@@ -251,8 +249,6 @@ const DashboardDevices: FC = () => {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
async function onSelectChange(action: any, state: any) {
|
async function onSelectChange(action: any, state: any) {
|
||||||
// TODO check if still needed
|
|
||||||
// setDeviceData({ data: [] });
|
|
||||||
setSelectedDevice(state.id);
|
setSelectedDevice(state.id);
|
||||||
if (action.type === 'ADD_BY_ID_EXCLUSIVELY') {
|
if (action.type === 'ADD_BY_ID_EXCLUSIVELY') {
|
||||||
await readDeviceData(state.id);
|
await readDeviceData(state.id);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import type {
|
|||||||
DeviceEntity,
|
DeviceEntity,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
CustomEntities,
|
CustomEntities,
|
||||||
WriteDeviceValue,
|
|
||||||
WriteTemperatureSensor,
|
WriteTemperatureSensor,
|
||||||
WriteAnalogSensor,
|
WriteAnalogSensor,
|
||||||
SensorData,
|
SensorData,
|
||||||
@@ -37,7 +36,9 @@ export const readDeviceData = (id: number) =>
|
|||||||
export const writeDeviceValue = (id: number, devicevalue: DeviceValue) =>
|
export const writeDeviceValue = (id: number, devicevalue: DeviceValue) =>
|
||||||
alovaInstance.Post('/writeDeviceValue', { id, devicevalue });
|
alovaInstance.Post('/writeDeviceValue', { id, devicevalue });
|
||||||
|
|
||||||
// TODO to change to alova
|
//
|
||||||
|
// TODO change below to use alova
|
||||||
|
//
|
||||||
|
|
||||||
export function restart(): AxiosPromise<void> {
|
export function restart(): AxiosPromise<void> {
|
||||||
return AXIOS.post('/restart');
|
return AXIOS.post('/restart');
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ export interface DeviceValue {
|
|||||||
x?: number; // max, optional
|
x?: number; // max, optional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO can be refacvtored to DeviceValue[]?
|
||||||
export interface DeviceData {
|
export interface DeviceData {
|
||||||
data: DeviceValue[];
|
data: DeviceValue[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1543,7 +1543,7 @@ __metadata:
|
|||||||
"@typescript-eslint/eslint-plugin": ^5.59.8
|
"@typescript-eslint/eslint-plugin": ^5.59.8
|
||||||
"@typescript-eslint/parser": ^5.59.8
|
"@typescript-eslint/parser": ^5.59.8
|
||||||
"@vitejs/plugin-react-swc": ^3.3.2
|
"@vitejs/plugin-react-swc": ^3.3.2
|
||||||
alova: ^2.5.4
|
alova: ^2.5.5
|
||||||
async-validator: ^4.2.5
|
async-validator: ^4.2.5
|
||||||
axios: ^1.4.0
|
axios: ^1.4.0
|
||||||
eslint: ^8.42.0
|
eslint: ^8.42.0
|
||||||
@@ -1647,10 +1647,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"alova@npm:^2.5.4":
|
"alova@npm:^2.5.5":
|
||||||
version: 2.5.4
|
version: 2.5.5
|
||||||
resolution: "alova@npm:2.5.4"
|
resolution: "alova@npm:2.5.5"
|
||||||
checksum: f58698009419025a50653a9c64a0d497e3cd64448877bfa64f9907878a09eb9f965609fc5950c93b85e37c67099445c28e39ee677d98e6ec665eab5f66a359cd
|
checksum: 028c24678fd91a5e2350b6c9c930475dd650fb766efad4d3dd8cd15d1ca85b2424e0857ba41d8f6eb2ad60999424269d8488b4aec66a4f74c98efd3378f21427
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user