mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
sonarlint improvements
This commit is contained in:
@@ -277,7 +277,7 @@ const CustomEntitiesDialog = ({
|
||||
select
|
||||
>
|
||||
{DeviceValueUOM_s.map((val, i) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
<MenuItem key={val} value={i}>
|
||||
{val}
|
||||
</MenuItem>
|
||||
))}
|
||||
|
||||
@@ -310,7 +310,7 @@ const Devices = () => {
|
||||
}, [escFunction]);
|
||||
|
||||
const customize = () => {
|
||||
if (selectedDevice == 99) {
|
||||
if (selectedDevice === 99) {
|
||||
navigate('/customentities');
|
||||
} else {
|
||||
navigate('/customizations', { state: selectedDevice });
|
||||
|
||||
@@ -162,7 +162,7 @@ const DevicesDialog = ({
|
||||
value={editItem.v}
|
||||
disabled={!writeable}
|
||||
sx={{ width: '30ch' }}
|
||||
multiline={editItem.u ? false : true}
|
||||
multiline={!editItem.u}
|
||||
onChange={updateFormValue}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -29,7 +29,7 @@ import { useI18nContext } from 'i18n/i18n-react';
|
||||
|
||||
import { readModules, writeModules } from '../../api/app';
|
||||
import ModulesDialog from './ModulesDialog';
|
||||
import type { ModuleItem, Modules } from './types';
|
||||
import type { ModuleItem } from './types';
|
||||
|
||||
const Modules = () => {
|
||||
const { LL } = useI18nContext();
|
||||
@@ -39,6 +39,8 @@ const Modules = () => {
|
||||
const [selectedModuleItem, setSelectedModuleItem] = useState<ModuleItem>();
|
||||
const [dialogOpen, setDialogOpen] = useState<boolean>(false);
|
||||
|
||||
useLayoutTitle(LL.MODULES());
|
||||
|
||||
const {
|
||||
data: modules,
|
||||
send: fetchModules,
|
||||
@@ -155,8 +157,6 @@ const Modules = () => {
|
||||
return <FormLoader onRetry={fetchModules} errorMessage={error?.message} />;
|
||||
}
|
||||
|
||||
useLayoutTitle(LL.MODULES());
|
||||
|
||||
if (modules.length === 0) {
|
||||
return (
|
||||
<Typography variant="body2" color="error">
|
||||
|
||||
@@ -43,6 +43,8 @@ const Scheduler = () => {
|
||||
const [creating, setCreating] = useState<boolean>(false);
|
||||
const [dialogOpen, setDialogOpen] = useState<boolean>(false);
|
||||
|
||||
useLayoutTitle(LL.SCHEDULER());
|
||||
|
||||
const {
|
||||
data: schedule,
|
||||
send: fetchSchedule,
|
||||
@@ -243,8 +245,6 @@ const Scheduler = () => {
|
||||
</Box>
|
||||
);
|
||||
|
||||
useLayoutTitle(LL.SCHEDULER());
|
||||
|
||||
return (
|
||||
<Table
|
||||
data={{
|
||||
|
||||
@@ -292,9 +292,7 @@ const SchedulerDialog = ({
|
||||
? LL.TIMER(1)
|
||||
: LL.TIME(1)
|
||||
}
|
||||
value={
|
||||
editItem.time == '' ? (editItem.time = '00:00') : editItem.time
|
||||
}
|
||||
value={editItem.time === '' ? '00:00' : editItem.time}
|
||||
margin="normal"
|
||||
onChange={updateFormValue}
|
||||
/>
|
||||
@@ -318,9 +316,7 @@ const SchedulerDialog = ({
|
||||
}
|
||||
multiline
|
||||
fullWidth
|
||||
value={
|
||||
editItem.time == '00:00' ? (editItem.time = '') : editItem.time
|
||||
}
|
||||
value={editItem.time === '00:00'}
|
||||
margin="normal"
|
||||
onChange={updateFormValue}
|
||||
/>
|
||||
|
||||
@@ -150,6 +150,56 @@ const Sensors = () => {
|
||||
}
|
||||
]);
|
||||
|
||||
const RenderTemperatureSensors = () => (
|
||||
<Table
|
||||
data={{ nodes: sensorData.ts }}
|
||||
theme={temperature_theme}
|
||||
sort={temperature_sort}
|
||||
layout={{ custom: true }}
|
||||
>
|
||||
{(tableList: TemperatureSensor[]) => (
|
||||
<>
|
||||
<Header>
|
||||
<HeaderRow>
|
||||
<HeaderCell resize>
|
||||
<Button
|
||||
fullWidth
|
||||
style={{ fontSize: '14px', justifyContent: 'flex-start' }}
|
||||
endIcon={getSortIcon(temperature_sort.state, 'NAME')}
|
||||
onClick={() =>
|
||||
temperature_sort.fns.onToggleSort({ sortKey: 'NAME' })
|
||||
}
|
||||
>
|
||||
{LL.NAME(0)}
|
||||
</Button>
|
||||
</HeaderCell>
|
||||
<HeaderCell stiff>
|
||||
<Button
|
||||
fullWidth
|
||||
style={{ fontSize: '14px', justifyContent: 'flex-end' }}
|
||||
endIcon={getSortIcon(temperature_sort.state, 'VALUE')}
|
||||
onClick={() =>
|
||||
temperature_sort.fns.onToggleSort({ sortKey: 'VALUE' })
|
||||
}
|
||||
>
|
||||
{LL.VALUE(0)}
|
||||
</Button>
|
||||
</HeaderCell>
|
||||
</HeaderRow>
|
||||
</Header>
|
||||
<Body>
|
||||
{tableList.map((ts: TemperatureSensor) => (
|
||||
<Row key={ts.id} item={ts} onClick={() => updateTemperatureSensor(ts)}>
|
||||
<Cell>{ts.n}</Cell>
|
||||
<Cell>{formatValue(ts.t, ts.u)}</Cell>
|
||||
</Row>
|
||||
))}
|
||||
</Body>
|
||||
</>
|
||||
)}
|
||||
</Table>
|
||||
);
|
||||
|
||||
const getSortIcon = (state: State, sortKey: unknown) => {
|
||||
if (state.sortKey === sortKey && state.reverse) {
|
||||
return <KeyboardArrowDownOutlinedIcon />;
|
||||
@@ -332,56 +382,6 @@ const Sensors = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const RenderTemperatureSensors = () => (
|
||||
<Table
|
||||
data={{ nodes: sensorData.ts }}
|
||||
theme={temperature_theme}
|
||||
sort={temperature_sort}
|
||||
layout={{ custom: true }}
|
||||
>
|
||||
{(tableList: TemperatureSensor[]) => (
|
||||
<>
|
||||
<Header>
|
||||
<HeaderRow>
|
||||
<HeaderCell resize>
|
||||
<Button
|
||||
fullWidth
|
||||
style={{ fontSize: '14px', justifyContent: 'flex-start' }}
|
||||
endIcon={getSortIcon(temperature_sort.state, 'NAME')}
|
||||
onClick={() =>
|
||||
temperature_sort.fns.onToggleSort({ sortKey: 'NAME' })
|
||||
}
|
||||
>
|
||||
{LL.NAME(0)}
|
||||
</Button>
|
||||
</HeaderCell>
|
||||
<HeaderCell stiff>
|
||||
<Button
|
||||
fullWidth
|
||||
style={{ fontSize: '14px', justifyContent: 'flex-end' }}
|
||||
endIcon={getSortIcon(temperature_sort.state, 'VALUE')}
|
||||
onClick={() =>
|
||||
temperature_sort.fns.onToggleSort({ sortKey: 'VALUE' })
|
||||
}
|
||||
>
|
||||
{LL.VALUE(0)}
|
||||
</Button>
|
||||
</HeaderCell>
|
||||
</HeaderRow>
|
||||
</Header>
|
||||
<Body>
|
||||
{tableList.map((ts: TemperatureSensor) => (
|
||||
<Row key={ts.id} item={ts} onClick={() => updateTemperatureSensor(ts)}>
|
||||
<Cell>{ts.n}</Cell>
|
||||
<Cell>{formatValue(ts.t, ts.u)}</Cell>
|
||||
</Row>
|
||||
))}
|
||||
</Body>
|
||||
</>
|
||||
)}
|
||||
</Table>
|
||||
);
|
||||
|
||||
const RenderAnalogSensors = () => (
|
||||
<Table
|
||||
data={{ nodes: sensorData.as }}
|
||||
|
||||
@@ -126,7 +126,7 @@ const SensorsAnalogDialog = ({
|
||||
onChange={updateFormValue}
|
||||
>
|
||||
{AnalogTypeNames.map((val, i) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
<MenuItem key={val} value={i}>
|
||||
{val}
|
||||
</MenuItem>
|
||||
))}
|
||||
@@ -143,7 +143,7 @@ const SensorsAnalogDialog = ({
|
||||
onChange={updateFormValue}
|
||||
>
|
||||
{DeviceValueUOM_s.map((val, i) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
<MenuItem key={val} value={i}>
|
||||
{val}
|
||||
</MenuItem>
|
||||
))}
|
||||
|
||||
@@ -206,15 +206,15 @@ export const DeviceValueUOM_s = [
|
||||
export enum AnalogType {
|
||||
REMOVED = -1,
|
||||
NOTUSED = 0,
|
||||
DIGITAL_IN,
|
||||
COUNTER,
|
||||
ADC,
|
||||
TIMER,
|
||||
RATE,
|
||||
DIGITAL_OUT,
|
||||
PWM_0,
|
||||
PWM_1,
|
||||
PWM_2
|
||||
DIGITAL_IN = 1,
|
||||
COUNTER = 2,
|
||||
ADC = 3,
|
||||
TIMER = 4,
|
||||
RATE = 5,
|
||||
DIGITAL_OUT = 6,
|
||||
PWM_0 = 7,
|
||||
PWM_1 = 8,
|
||||
PWM_2 = 9
|
||||
}
|
||||
|
||||
export const AnalogTypeNames = [
|
||||
|
||||
@@ -35,7 +35,7 @@ export const apStatusHighlight = ({ status }: APStatusType, theme: Theme) => {
|
||||
|
||||
const APStatus = () => {
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(APApi.readAPStatus, { pollingTime: 5000 });
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { Stat } from '../main/types';
|
||||
|
||||
const SystemActivity = () => {
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(readActivity, { pollingTime: 2000 });
|
||||
|
||||
@@ -33,7 +33,7 @@ const HardwareStatus = () => {
|
||||
useLayoutTitle(LL.STATUS_OF(LL.HARDWARE()));
|
||||
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(SystemApi.readSystemStatus, { pollingTime: 2000 });
|
||||
@@ -50,6 +50,7 @@ const HardwareStatus = () => {
|
||||
{data.model ? (
|
||||
<Avatar sx={{ bgcolor: '#003289', color: 'white' }}>
|
||||
<img
|
||||
alt="BBQKees"
|
||||
src={BBQKeesIcon}
|
||||
style={{ width: 16, verticalAlign: 'middle' }}
|
||||
/>
|
||||
@@ -93,7 +94,7 @@ const HardwareStatus = () => {
|
||||
' (rev.' +
|
||||
data.cpu_rev +
|
||||
', ' +
|
||||
(data.cpu_cores == 1 ? 'single-core)' : 'dual-core)') +
|
||||
(data.cpu_cores === 1 ? 'single-core)' : 'dual-core)') +
|
||||
' @ ' +
|
||||
data.cpu_freq_mhz +
|
||||
' Mhz'
|
||||
|
||||
@@ -55,7 +55,7 @@ export const mqttQueueHighlight = (
|
||||
|
||||
const MqttStatus = () => {
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(MqttApi.readMqttStatus, { pollingTime: 5000 });
|
||||
|
||||
@@ -37,7 +37,7 @@ import { formatDateTime, formatLocalDateTime } from 'utils';
|
||||
|
||||
const NTPStatus = () => {
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(NTPApi.readNTPStatus, { pollingTime: 5000 });
|
||||
|
||||
@@ -82,7 +82,7 @@ const IPs = (status: NetworkStatusType) => {
|
||||
|
||||
const NetworkStatus = () => {
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(NetworkApi.readNetworkStatus, { pollingTime: 5000 });
|
||||
|
||||
@@ -60,7 +60,7 @@ const SystemStatus = () => {
|
||||
});
|
||||
|
||||
const {
|
||||
data: data,
|
||||
data,
|
||||
send: loadData,
|
||||
error
|
||||
} = useAutoRequest(readSystemStatus, {
|
||||
|
||||
@@ -250,7 +250,7 @@ const SystemLog = () => {
|
||||
}}
|
||||
>
|
||||
{logEntries.map((e) => (
|
||||
<div style={{ font: '14px monospace', whiteSpace: 'nowrap' }}>
|
||||
<div key={e.i} style={{ font: '14px monospace', whiteSpace: 'nowrap' }}>
|
||||
<span>{e.t}</span>
|
||||
<span>{paddedLevelLabel(e.l)} </span>
|
||||
<span>{paddedIDLabel(e.i)} </span>
|
||||
|
||||
Reference in New Issue
Block a user