mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-10 17:59:53 +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 = [
|
||||
|
||||
Reference in New Issue
Block a user