mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix eslint warnings
This commit is contained in:
@@ -31,7 +31,7 @@ const useWindowSize = () => {
|
|||||||
return size;
|
return size;
|
||||||
};
|
};
|
||||||
|
|
||||||
const LogEntryLine = styled('div')(({ theme }) => ({
|
const LogEntryLine = styled('div')(() => ({
|
||||||
color: '#bbbbbb',
|
color: '#bbbbbb',
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
@@ -125,7 +125,7 @@ const SystemLog: FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void fetchLog();
|
void fetchLog();
|
||||||
}, []);
|
}, [fetchLog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const es = new EventSource(addAccessTokenParameter(LOG_EVENTSOURCE_URL));
|
const es = new EventSource(addAccessTokenParameter(LOG_EVENTSOURCE_URL));
|
||||||
@@ -138,7 +138,7 @@ const SystemLog: FC = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
es.close();
|
es.close();
|
||||||
};
|
};
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
const saveSettings = async () => {
|
const saveSettings = async () => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Locales, Formatters } from './i18n-types';
|
import type { Locales, Formatters } from './i18n-types';
|
||||||
import type { FormattersInitializer } from 'typesafe-i18n';
|
import type { FormattersInitializer } from 'typesafe-i18n';
|
||||||
|
|
||||||
export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => {
|
export const initFormatters: FormattersInitializer<Locales, Formatters> = () => {
|
||||||
const formatters: Formatters = {
|
const formatters: Formatters = {
|
||||||
// add your formatter functions here
|
// add your formatter functions here
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { useRowSelect } from '@table-library/react-table-library/select';
|
|||||||
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
|
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
|
||||||
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
||||||
import { useTheme } from '@table-library/react-table-library/theme';
|
import { useTheme } from '@table-library/react-table-library/theme';
|
||||||
import { useState, useContext, useEffect } from 'react';
|
import { useState, useContext, useEffect, useCallback } from 'react';
|
||||||
|
|
||||||
import { IconContext } from 'react-icons';
|
import { IconContext } from 'react-icons';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
@@ -183,24 +183,26 @@ const DashboardDevices: FC = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fetchDeviceData = async (id: number) => {
|
const fetchDeviceData = async (id: number) => {
|
||||||
|
if (!deviceValueDialogOpen) {
|
||||||
try {
|
try {
|
||||||
setDeviceData((await EMSESP.readDeviceData({ id })).data);
|
setDeviceData((await EMSESP.readDeviceData({ id })).data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchCoreData = async () => {
|
const fetchCoreData = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
setCoreData((await EMSESP.readCoreData()).data);
|
setCoreData((await EMSESP.readCoreData()).data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||||
}
|
}
|
||||||
};
|
}, [LL]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void fetchCoreData();
|
void fetchCoreData();
|
||||||
}, []);
|
}, [fetchCoreData]);
|
||||||
|
|
||||||
const refreshData = () => {
|
const refreshData = () => {
|
||||||
if (selectedDevice) {
|
if (selectedDevice) {
|
||||||
@@ -280,7 +282,7 @@ const DashboardDevices: FC = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
};
|
};
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
const deviceValueDialogSave = async (dv: DeviceValue) => {
|
const deviceValueDialogSave = async (dv: DeviceValue) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -102,16 +102,18 @@ const DashboardSensors: FC = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const fetchSensorData = useCallback(async () => {
|
const fetchSensorData = useCallback(async () => {
|
||||||
|
if (!analogDialogOpen && !temperatureDialogOpen) {
|
||||||
try {
|
try {
|
||||||
setSensorData((await EMSESP.readSensorData()).data);
|
setSensorData((await EMSESP.readSensorData()).data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||||
}
|
}
|
||||||
}, [LL]);
|
}
|
||||||
|
}, [LL, analogDialogOpen, temperatureDialogOpen]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void fetchSensorData();
|
void fetchSensorData();
|
||||||
}, []);
|
}, [fetchSensorData]);
|
||||||
|
|
||||||
const getSortIcon = (state: any, sortKey: any) => {
|
const getSortIcon = (state: any, sortKey: any) => {
|
||||||
if (state.sortKey === sortKey && state.reverse) {
|
if (state.sortKey === sortKey && state.reverse) {
|
||||||
@@ -160,11 +162,11 @@ const DashboardSensors: FC = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setInterval(() => fetchSensorData(), 60000);
|
const timer = setInterval(() => fetchSensorData(), 30000);
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
};
|
};
|
||||||
}, [fetchSensorData]);
|
});
|
||||||
|
|
||||||
const formatDurationMin = (duration_min: number) => {
|
const formatDurationMin = (duration_min: number) => {
|
||||||
const days = Math.trunc((duration_min * 60000) / 86400000);
|
const days = Math.trunc((duration_min * 60000) / 86400000);
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ const DashboardSensorsAnalogDialog = ({
|
|||||||
name="f"
|
name="f"
|
||||||
label={LL.FREQ()}
|
label={LL.FREQ()}
|
||||||
value={numberValue(editItem.f)}
|
value={numberValue(editItem.f)}
|
||||||
// fullWidth
|
fullWidth
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
@@ -228,7 +228,7 @@ const DashboardSensorsAnalogDialog = ({
|
|||||||
name="o"
|
name="o"
|
||||||
label={LL.DUTY_CYCLE()}
|
label={LL.DUTY_CYCLE()}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
// fullWidth
|
fullWidth
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ const DashboardStatus: FC = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
};
|
};
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
const showName = (id: any) => {
|
const showName = (id: any) => {
|
||||||
const name: keyof Translation['STATUS_NAMES'] = id;
|
const name: keyof Translation['STATUS_NAMES'] = id;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ const SettingsEntities: FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void fetchEntities();
|
void fetchEntities();
|
||||||
}, []);
|
}, [fetchEntities]);
|
||||||
|
|
||||||
const saveEntities = async () => {
|
const saveEntities = async () => {
|
||||||
if (entities) {
|
if (entities) {
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ const SettingsScheduler: FC = () => {
|
|||||||
}
|
}
|
||||||
}, [LL]);
|
}, [LL]);
|
||||||
|
|
||||||
// on mount
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' });
|
const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' });
|
||||||
const days = [1, 2, 3, 4, 5, 6, 7].map((day) => {
|
const days = [1, 2, 3, 4, 5, 6, 7].map((day) => {
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ export const useWs = <D>(wsUrl: string, wsThrottle = 100) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ws.current = instance;
|
ws.current = instance;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
return instance.close;
|
return instance.close;
|
||||||
}, [wsUrl, onMessage]);
|
}, [wsUrl, onMessage]);
|
||||||
|
|
||||||
|
|||||||
@@ -826,6 +826,7 @@ const emsesp_deviceentities_4 = [
|
|||||||
// LOG
|
// LOG
|
||||||
rest_server.get(FETCH_LOG_ENDPOINT, (req, res) => {
|
rest_server.get(FETCH_LOG_ENDPOINT, (req, res) => {
|
||||||
const encoded = msgpack.encode(fetch_log);
|
const encoded = msgpack.encode(fetch_log);
|
||||||
|
console.log('fetchlog');
|
||||||
res.write(encoded, 'binary');
|
res.write(encoded, 'binary');
|
||||||
res.end(null, 'binary');
|
res.end(null, 'binary');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user