{!device.physical && (
)}
{device.type.charAt(0).toUpperCase() + device.type.slice(1)}
{
const path = getDevicePath();
updateDeviceSetting([...path, 'name'], v);
}}
onClear={() => updateDeviceSetting([...getDevicePath(), 'name'], '')}
className="px-3 py-2 border border-neutral-300 rounded-lg"
containerClassName="w-full"
/>
{!device.physical && <>
{
const path = getDevicePath();
updateDeviceSetting([...path, 'base_url'], v);
}}
onClear={() => updateDeviceSetting([...getDevicePath(), 'base_url'], '')}
containerClassName="flex-1"
className="px-3 py-2 border border-neutral-300 rounded-lg"
/>
{
const devicePath = getDevicePath();
const newConfig = JSON.parse(JSON.stringify(config));
let dev = newConfig;
for (const k of devicePath) dev = dev[k];
if (isOutsideBase(newUrl, dev.base_url || '')) clearBaseAndCache(dev);
dev.url = newUrl;
delete dev.media_set;
setConfig(newConfig);
if (newUrl) void detectMediaSet(newUrl);
}}
onClear={() => {
const devicePath = getDevicePath();
const newConfig = JSON.parse(JSON.stringify(config));
let dev = newConfig;
for (const k of devicePath) dev = dev[k];
delete dev.url;
delete dev.media_set;
setConfig(newConfig);
++detectTokenRef.current;
setMediaSetFiles(null);
}}
containerClassName="flex-1"
className="px-3 py-2 border border-neutral-300 rounded-lg"
/>
{mediaSetFiles && (
)}
{(deviceData.cache !== undefined ||
(deviceData.base_url ?? '').includes('://') ||
(deviceData.url ?? '').includes('://')) && (
{
const path = getDevicePath();
updateDeviceSetting([...path, 'cache'], v);
}}
onClear={() => updateDeviceSetting([...getDevicePath(), 'cache'], '')}
containerClassName="flex-1"
className="px-3 py-2 border border-neutral-300 rounded-lg"
/>
)}
>}
{deviceData.mode !== undefined && (
{device.physical
?
{(deviceData.mode ?? 0) === 0 ? 'Read Only' : 'Write Enabled'}
:
{([0, 1] as const).map((val, i) => (
))}
}
)}
{deviceData.baud !== undefined && (
{
const path = getDevicePath();
updateDeviceSetting([...path, 'baud'], parseInt(v));
}}
className="w-full px-3 py-2 border border-neutral-300 rounded-lg"
/>
)}