0.11.0 Multi LW
This commit is contained in:
@@ -6,6 +6,7 @@ import { InputNumber } from 'primereact/inputnumber';
|
||||
import { InputSwitch } from 'primereact/inputswitch';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import { Button } from 'primereact/button';
|
||||
|
||||
function normalizeText(value) {
|
||||
return String(value || '').trim().toLowerCase();
|
||||
@@ -87,6 +88,64 @@ function toBoolean(value) {
|
||||
return normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'on';
|
||||
}
|
||||
|
||||
function DriveDevicesEditor({ value, onChange, settingKey }) {
|
||||
const parseDevices = (val) => {
|
||||
try {
|
||||
const parsed = JSON.parse(val || '[]');
|
||||
return Array.isArray(parsed) ? parsed.map(String) : [];
|
||||
} catch (_e) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const devices = parseDevices(value);
|
||||
|
||||
const updateDevices = (newDevices) => {
|
||||
onChange?.(settingKey, JSON.stringify(newDevices));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="drive-devices-editor">
|
||||
{devices.length === 0 && (
|
||||
<p className="drive-devices-empty">Keine expliziten Laufwerke konfiguriert.</p>
|
||||
)}
|
||||
{devices.map((path, idx) => (
|
||||
<div key={idx} className="drive-device-row">
|
||||
<InputText
|
||||
value={path}
|
||||
placeholder="/dev/sr0"
|
||||
onChange={(e) => {
|
||||
const next = [...devices];
|
||||
next[idx] = e.target.value;
|
||||
updateDevices(next);
|
||||
}}
|
||||
className="drive-device-input"
|
||||
/>
|
||||
<Button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
text
|
||||
rounded
|
||||
size="small"
|
||||
onClick={() => updateDevices(devices.filter((_, i) => i !== idx))}
|
||||
type="button"
|
||||
aria-label="Laufwerk entfernen"
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
<Button
|
||||
icon="pi pi-plus"
|
||||
label="Laufwerk hinzufügen"
|
||||
severity="secondary"
|
||||
text
|
||||
size="small"
|
||||
onClick={() => updateDevices([...devices, ''])}
|
||||
type="button"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function shouldHideSettingByExpertMode(settingKey, expertModeEnabled) {
|
||||
const key = normalizeSettingKey(settingKey);
|
||||
if (!key) {
|
||||
@@ -245,7 +304,7 @@ function SettingField({
|
||||
</label>
|
||||
)}
|
||||
|
||||
{setting.type === 'string' || setting.type === 'path' ? (
|
||||
{(setting.type === 'string' || setting.type === 'path') && setting.key !== 'drive_devices' ? (
|
||||
<InputText
|
||||
id={setting.key}
|
||||
value={value ?? ''}
|
||||
@@ -253,6 +312,14 @@ function SettingField({
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{setting.key === 'drive_devices' ? (
|
||||
<DriveDevicesEditor
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
settingKey={setting.key}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{setting.type === 'number' ? (
|
||||
<InputNumber
|
||||
id={setting.key}
|
||||
|
||||
Reference in New Issue
Block a user