add placeholders to text editors FrigateHostsPage.tsx

This commit is contained in:
NlightN22 2024-11-30 15:14:28 +07:00
parent 49b1f03ca9
commit 720f6de6fd
5 changed files with 44 additions and 16 deletions

View File

@ -83,11 +83,15 @@ const en = {
hostsConfig: 'Frigate servers', hostsConfig: 'Frigate servers',
acessSettings: 'Access settings', acessSettings: 'Access settings',
}, },
hostArr: { frigateHostTableTitles: {
host: 'Host', host: 'Хост',
name: 'Host name', name: 'Имя хоста',
url: 'Address', url: 'Адрес',
enabled: 'Enabled', enabled: 'Включен',
},
frigateHostTablePlaceholders: {
host: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
name: 'YourFrigateHostName',
}, },
player: { player: {
startVideo: 'Enable Video', startVideo: 'Enable Video',

View File

@ -81,12 +81,16 @@ const ru = {
hostsConfig: 'Серверы Frigate', hostsConfig: 'Серверы Frigate',
acessSettings: 'Настройка доступа', acessSettings: 'Настройка доступа',
}, },
hostArr: { frigateHostTableTitles: {
host: 'Хост', host: 'Хост',
name: 'Имя хоста', name: 'Имя хоста',
url: 'Адрес', url: 'Адрес',
enabled: 'Включен', enabled: 'Включен',
}, },
frigateHostTablePlaceholders: {
host: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
name: 'YourFrigateHostName',
},
player: { player: {
startVideo: 'Вкл. Видео', startVideo: 'Вкл. Видео',
stopVideo: 'Выкл. Видео', stopVideo: 'Выкл. Видео',

View File

@ -60,7 +60,7 @@ const SelectedHostList = ({
return ( return (
<Flex w='100%' h='100%' direction='column' align='center'> <Flex w='100%' h='100%' direction='column' align='center'>
<Text>{t('hostArr.host')}: {camerasQuery[0].frigateHost?.name}</Text> <Text>{t('frigateHostTableTitles.host')}: {camerasQuery[0].frigateHost?.name}</Text>
<Accordion <Accordion
mt='1rem' mt='1rem'
variant='separated' variant='separated'

View File

@ -30,7 +30,7 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
useEffect(() => { useEffect(() => {
setTableData(data); setTableData(data);
}, [data]); }, [data]);
useEffect(() => { useEffect(() => {
if (!isProduction) console.log('TableData', tableData) if (!isProduction) console.log('TableData', tableData)
@ -48,9 +48,9 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
} }
const headTitle = [ const headTitle = [
{ propertyName: 'name', title: t('hostArr.host') }, { propertyName: 'name', title: t('frigateHostTableTitles.host') },
{ propertyName: 'host', title: t('hostArr.url') }, { propertyName: 'host', title: t('frigateHostTableTitles.url') },
{ propertyName: 'enabled', title: t('hostArr.enabled') }, { propertyName: 'enabled', title: t('frigateHostTableTitles.enabled') },
{ title: '', sorting: false }, { title: '', sorting: false },
] ]
@ -108,8 +108,22 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
const rows = tableData.map(item => { const rows = tableData.map(item => {
return ( return (
<tr key={item.id}> <tr key={item.id}>
<TextInputCell text={item.name} width='40%' id={item.id} propertyName='name' onChange={handleTextChange} /> <TextInputCell
<TextInputCell text={item.host} width='40%' id={item.id} propertyName='host' onChange={handleTextChange} /> text={item.name}
width='40%'
id={item.id}
propertyName='name'
onChange={handleTextChange}
placeholder={t('frigateHostTablePlaceholders.name')}
/>
<TextInputCell
text={item.host}
width='40%'
id={item.id}
propertyName='host'
onChange={handleTextChange}
placeholder={t('frigateHostTablePlaceholders.host')}
/>
<SwitchCell value={item.enabled} width='5%' id={item.id} propertyName='enabled' toggle={handleSwitchChange} /> <SwitchCell value={item.enabled} width='5%' id={item.id} propertyName='enabled' toggle={handleSwitchChange} />
<StateCell id={item.id} width='5%' /> <StateCell id={item.id} width='5%' />
<td align='right' style={{ width: '10%', padding: '0', }}> <td align='right' style={{ width: '10%', padding: '0', }}>

View File

@ -12,9 +12,10 @@ interface TextImputCellProps {
propertyName: string, propertyName: string,
value?: string | number | boolean, value?: string | number | boolean,
) => void, ) => void,
placeholder?: string | undefined
} }
const TextInputCell = ({ text, width, id, propertyName, onChange }: TextImputCellProps) => { const TextInputCell = ({ text, width, id, propertyName, onChange, placeholder }: TextImputCellProps) => {
const [value, setValue] = useState(text); const [value, setValue] = useState(text);
const [debouncedValue] = useDebouncedValue(value, 300) const [debouncedValue] = useDebouncedValue(value, 300)
useEffect(() => { useEffect(() => {
@ -28,7 +29,12 @@ const TextInputCell = ({ text, width, id, propertyName, onChange }: TextImputCel
} }
return ( return (
<td style={{ width: width, textAlign: 'center' }}> <td style={{ width: width, textAlign: 'center' }}>
<TextInput onChange={handleChange} size='sm' value={String(value)} /> <TextInput
onChange={handleChange}
size='sm'
value={String(value)}
placeholder={placeholder}
/>
</td> </td>
) )
} }