diff --git a/src/app/components/MediaManager.tsx b/src/app/components/MediaManager.tsx index 47d8566..b65de38 100644 --- a/src/app/components/MediaManager.tsx +++ b/src/app/components/MediaManager.tsx @@ -509,6 +509,29 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi useEffect(() => { localStorage.setItem('fileManager.sortKey', sortKey); }, [sortKey]); useEffect(() => { localStorage.setItem('fileManager.sortAsc', String(sortAsc)); }, [sortAsc]); + // ── Folder config (.config) ────────────────────────────────────────────── + + const [folderConfig, setFolderConfig] = useState | null>(null); + + useEffect(() => { + let cancelled = false; + getFileContents(joinPath(path, '.config')) + .then(async blob => { + if (cancelled) return; + const cfg: Record = {}; + for (const line of (await blob.text()).split('\n')) { + const t = line.trim(); + if (!t || t.startsWith('#')) continue; + const eq = t.indexOf('='); + if (eq < 0) continue; + cfg[t.slice(0, eq).trim()] = t.slice(eq + 1).trim(); + } + setFolderConfig(cfg); + }) + .catch(() => { if (!cancelled) setFolderConfig(null); }); + return () => { cancelled = true; }; + }, [path]); + const navigateTo = (p: string) => { let norm = normalizePath(p); if (rootPath && !norm.startsWith(rootPath)) norm = rootPath; @@ -717,6 +740,8 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi } if (!dev.enabled) dev.enabled = 1; + if (folderConfig?.['cache'] === '.') dev.cache = splitPath(mountEntry.path).parent; + if (folderConfig?.['base_url']) dev.base_url = folderConfig['base_url']; setConfig(newConfig); setMountEntry(null); const deviceId = `${deviceType}-${key}`; @@ -825,22 +850,6 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi const pathParts = path.split('/').filter(Boolean); const selCount = selected.size; - const deviceBaseUrl = useMemo(() => { - if (!config?.iec?.devices) return null; - const groups = ['drive', 'meatloaf', 'printer', 'network', 'other']; - for (const t of groups) { - for (const dev of Object.values(config.iec.devices[t] ?? {}) as any[]) { - if (dev?.base_url && (path.startsWith(dev.base_url) || dev.base_url === rootPath)) - return dev.base_url as string; - } - } - for (const t of groups) { - for (const dev of Object.values(config.iec.devices[t] ?? {}) as any[]) { - if (dev?.base_url) return dev.base_url as string; - } - } - return null; - }, [config, path, rootPath]); // ── Render ─────────────────────────────────────────────────────────────── @@ -916,8 +925,10 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi ); })} - {deviceBaseUrl && ( -
Base: {deviceBaseUrl}
+ {(folderConfig?.['base_url']) && ( +
+ Base: {folderConfig?.['base_url']} +
)} {showNewFile && (