add writeable checkbox to custom entities

This commit is contained in:
MichaelDvP
2023-04-15 10:45:41 +02:00
parent d86153a08e
commit a54f3f7085
12 changed files with 61 additions and 23 deletions

View File

@@ -320,7 +320,8 @@ const de: Translation = {
SCHEDULE_TIMER_2: 'jede Minute',
SCHEDULE_TIMER_3: 'jede Stunde',
CUSTOM_ENTITIES: 'Individuelle Entitäten',
ENTITIES_HELP_1: 'Abfrage von Werten auf dem EMS-Bus'
ENTITIES_HELP_1: 'Abfrage von Werten auf dem EMS-Bus',
WRITEABLE: 'Schreibbar'
};
export default de;

View File

@@ -320,7 +320,8 @@ const en: Translation = {
SCHEDULE_TIMER_2: 'every minute',
SCHEDULE_TIMER_3: 'every hour',
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable'
};
export default en;

View File

@@ -319,8 +319,9 @@ const fr: Translation = {
SCHEDULE_TIMER_1: 'on startup', // TODO translate
SCHEDULE_TIMER_2: 'every minute', // TODO translate
SCHEDULE_TIMER_3: 'every hour', // TODO translate
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
CUSTOM_ENTITIES: 'Custom entities', // TODO translate
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus', // TODO translate
WRITEABLE: 'Writeable' // TODO translate
};
export default fr;

View File

@@ -320,7 +320,8 @@ const nl: Translation = {
SCHEDULE_TIMER_2: 'every minute', // TODO translate
SCHEDULE_TIMER_3: 'every hour', // TODO translate
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable' // TODO translate
};
export default nl;

View File

@@ -320,7 +320,8 @@ const no: Translation = {
SCHEDULE_TIMER_2: 'hvert minutt',
SCHEDULE_TIMER_3: 'hver time',
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable' // TODO translate
};
export default no;

View File

@@ -320,7 +320,8 @@ const pl: BaseTranslation = {
SCHEDULE_TIMER_2: 'co minutę',
SCHEDULE_TIMER_3: 'co godzinę',
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable' // TODO translate
};
export default pl;

View File

@@ -320,7 +320,8 @@ const sv: Translation = {
SCHEDULE_TIMER_2: 'every minute', // TODO translate
SCHEDULE_TIMER_3: 'every hour', // TODO translate
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable' // TODO translate
};
export default sv;

View File

@@ -320,7 +320,8 @@ const tr: Translation = {
SCHEDULE_TIMER_2: 'every minute', // TODO translate
SCHEDULE_TIMER_3: 'every hour', // TODO translate
CUSTOM_ENTITIES: 'Custom entities',
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus'
ENTITIES_HELP_1: 'Fetch custom entities from the EMS-bus',
WRITEABLE: 'Writeable' // TODO translate
};
export default tr;

View File

@@ -10,8 +10,8 @@ import {
DialogActions,
DialogContent,
DialogTitle,
TextField,
MenuItem,
Checkbox,
InputAdornment
} from '@mui/material';
@@ -26,7 +26,14 @@ import CancelIcon from '@mui/icons-material/Cancel';
import DoneIcon from '@mui/icons-material/Done';
import AddIcon from '@mui/icons-material/Add';
import { ValidatedTextField, ButtonRow, FormLoader, SectionContent, BlockNavigation } from 'components';
import {
ValidatedTextField,
ButtonRow,
FormLoader,
SectionContent,
BlockNavigation,
BlockFormControlLabel
} from 'components';
import { DeviceValueUOM_s, EntityItem } from './types';
import { extractErrorMessage, updateValue } from 'utils';
@@ -54,6 +61,7 @@ const SettingsEntities: FC = () => {
uom: 0,
val_type: 2,
name: '',
write: false,
deleted: false
};
const [entity, setEntity] = useState<EntityItem[]>([emptyEntity]);
@@ -142,6 +150,7 @@ const SettingsEntities: FC = () => {
o_uom: ei.uom,
o_val_type: ei.val_type,
o_name: ei.name,
o_write: ei.write,
o_deleted: ei.deleted
}))
);
@@ -156,6 +165,7 @@ const SettingsEntities: FC = () => {
ei.uom !== ei.o_uom ||
ei.factor !== ei.o_factor ||
ei.val_type !== ei.o_val_type ||
ei.write !== ei.o_write ||
ei.deleted !== ei.o_deleted
);
}
@@ -181,7 +191,8 @@ const SettingsEntities: FC = () => {
factor: condensed_ei.factor,
val_type: condensed_ei.val_type,
uom: condensed_ei.uom,
name: condensed_ei.name
name: condensed_ei.name,
write: condensed_ei.write
};
})
});
@@ -306,7 +317,7 @@ const SettingsEntities: FC = () => {
<Box flexWrap="nowrap" whiteSpace="nowrap"></Box>
</Box>
<Grid container spacing={2}>
<Grid item xs={12}>
<Grid item xs={8}>
<ValidatedTextField
fieldErrors={fieldErrors}
name="name"
@@ -317,6 +328,14 @@ const SettingsEntities: FC = () => {
onChange={updateValue(setEntityItem)}
/>
</Grid>
<Grid item xs={4}>
<BlockFormControlLabel
control={
<Checkbox checked={entityItem.write} onChange={updateValue(setEntityItem)} name="write" />
}
label={LL.WRITEABLE()}
/>
</Grid>
<Grid item xs={4}>
<ValidatedTextField
name="device_id"

View File

@@ -356,6 +356,8 @@ export interface EntityItem {
o_val_type?: number;
deleted?: boolean; // optional
o_deleted?: boolean;
write: boolean;
o_write?: boolean;
}
export interface Entities {