fix eslint warnings

This commit is contained in:
Proddy
2023-04-29 15:35:54 +02:00
parent 90a719561b
commit 2254bf9c16
10 changed files with 31 additions and 26 deletions

View File

@@ -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) {

View File

@@ -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
}; };

View File

@@ -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) => {
try { if (!deviceValueDialogOpen) {
setDeviceData((await EMSESP.readDeviceData({ id })).data); try {
} catch (error) { setDeviceData((await EMSESP.readDeviceData({ id })).data);
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING())); } catch (error) {
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 {

View File

@@ -102,16 +102,18 @@ const DashboardSensors: FC = () => {
]); ]);
const fetchSensorData = useCallback(async () => { const fetchSensorData = useCallback(async () => {
try { if (!analogDialogOpen && !temperatureDialogOpen) {
setSensorData((await EMSESP.readSensorData()).data); try {
} catch (error) { setSensorData((await EMSESP.readSensorData()).data);
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING())); } catch (error) {
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);

View File

@@ -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}

View File

@@ -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;

View File

@@ -130,7 +130,7 @@ const SettingsEntities: FC = () => {
useEffect(() => { useEffect(() => {
void fetchEntities(); void fetchEntities();
}, []); }, [fetchEntities]);
const saveEntities = async () => { const saveEntities = async () => {
if (entities) { if (entities) {

View File

@@ -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) => {

View File

@@ -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]);

View File

@@ -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');
}); });