sonarlint improvements

This commit is contained in:
Proddy
2024-10-02 13:32:51 +02:00
parent 1eaa16995b
commit 8e6434cf7f
28 changed files with 459 additions and 610 deletions

View File

@@ -277,7 +277,7 @@ const CustomEntitiesDialog = ({
select
>
{DeviceValueUOM_s.map((val, i) => (
<MenuItem key={i} value={i}>
<MenuItem key={val} value={i}>
{val}
</MenuItem>
))}

View File

@@ -310,7 +310,7 @@ const Devices = () => {
}, [escFunction]);
const customize = () => {
if (selectedDevice == 99) {
if (selectedDevice === 99) {
navigate('/customentities');
} else {
navigate('/customizations', { state: selectedDevice });

View File

@@ -162,7 +162,7 @@ const DevicesDialog = ({
value={editItem.v}
disabled={!writeable}
sx={{ width: '30ch' }}
multiline={editItem.u ? false : true}
multiline={!editItem.u}
onChange={updateFormValue}
/>
)}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 = [

View File

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

View File

@@ -18,7 +18,7 @@ import type { Stat } from '../main/types';
const SystemActivity = () => {
const {
data: data,
data,
send: loadData,
error
} = useAutoRequest(readActivity, { pollingTime: 2000 });

View File

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

View File

@@ -55,7 +55,7 @@ export const mqttQueueHighlight = (
const MqttStatus = () => {
const {
data: data,
data,
send: loadData,
error
} = useAutoRequest(MqttApi.readMqttStatus, { pollingTime: 5000 });

View File

@@ -37,7 +37,7 @@ import { formatDateTime, formatLocalDateTime } from 'utils';
const NTPStatus = () => {
const {
data: data,
data,
send: loadData,
error
} = useAutoRequest(NTPApi.readNTPStatus, { pollingTime: 5000 });

View File

@@ -82,7 +82,7 @@ const IPs = (status: NetworkStatusType) => {
const NetworkStatus = () => {
const {
data: data,
data,
send: loadData,
error
} = useAutoRequest(NetworkApi.readNetworkStatus, { pollingTime: 5000 });

View File

@@ -60,7 +60,7 @@ const SystemStatus = () => {
});
const {
data: data,
data,
send: loadData,
error
} = useAutoRequest(readSystemStatus, {

View File

@@ -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)}&nbsp;</span>
<span>{paddedIDLabel(e.i)} </span>