fix(MediaManager, StatusPage): improve initial path handling and file manager navigation

This commit is contained in:
Jaime Idolpx 2026-06-11 12:27:53 -04:00
parent e122392cf2
commit 010cd68e3f
3 changed files with 5 additions and 5 deletions

View File

@ -116,7 +116,7 @@ export default function App() {
<div> <div>
<h2 className="text-lg font-semibold mb-4 text-blue-700">Management</h2> <h2 className="text-lg font-semibold mb-4 text-blue-700">Management</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4"> <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
<AppCard icon={<Folder className="w-7 h-7" />} label="Media Manager" onClick={() => setCurrentPage('file-manager')} /> <AppCard icon={<Folder className="w-7 h-7" />} label="Media Manager" onClick={() => { setFileManagerInitialPath(undefined); setCurrentPage('file-manager'); }} />
<AppCard icon={<Printer className="w-7 h-7" />} label="Print Manager" onClick={() => setCurrentPage('print-manager')} /> <AppCard icon={<Printer className="w-7 h-7" />} label="Print Manager" onClick={() => setCurrentPage('print-manager')} />
<AppCard icon={<Terminal className="w-7 h-7" />} label="Serial Console" onClick={() => setCurrentPage('serial-console')} /> <AppCard icon={<Terminal className="w-7 h-7" />} label="Serial Console" onClick={() => setCurrentPage('serial-console')} />
<AppCard icon={<Link className="w-7 h-7" />} label="Short Codes" onClick={() => setCurrentPage('serial-console')} /> <AppCard icon={<Link className="w-7 h-7" />} label="Short Codes" onClick={() => setCurrentPage('serial-console')} />

View File

@ -338,9 +338,9 @@ async function _getEntryBytes(entry: EntryInfo): Promise<Uint8Array> {
const FM_PATH_KEY = 'fileManager.path'; const FM_PATH_KEY = 'fileManager.path';
export default function MediaManager({ initialPath = '/', rootPath, title, config, setConfig, onBack, onNavigateToDevice }: MediaManagerProps) { export default function MediaManager({ initialPath, rootPath, title, config, setConfig, onBack, onNavigateToDevice }: MediaManagerProps) {
const pathKey = rootPath ? `fileManager.path:${rootPath}` : FM_PATH_KEY; const pathKey = rootPath ? `fileManager.path:${rootPath}` : FM_PATH_KEY;
const [path, setPath] = useState(() => normalizePath(localStorage.getItem(pathKey) || rootPath || initialPath)); const [path, setPath] = useState(() => normalizePath(initialPath ?? localStorage.getItem(pathKey) ?? rootPath ?? '/'));
const [entries, setEntries] = useState<EntryInfo[]>([]); const [entries, setEntries] = useState<EntryInfo[]>([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);

View File

@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { HardDrive, Activity, Wifi, Radio, Clock, RefreshCw, Loader2, Printer, Power, Computer, Download, Trash2, Eye, FolderOpen } from 'lucide-react'; import { HardDrive, Activity, Wifi, Radio, Clock, RefreshCw, Loader2, Printer, Power, Computer, Download, Trash2, Eye, FolderOpen } from 'lucide-react';
import { listDirectory, deletePath, getFileContents, getWebDAVBaseUrl, humanFileSize, type EntryInfo } from '../webdav'; import { listDirectory, deletePath, getFileContents, getWebDAVBaseUrl, humanFileSize, splitPath, type EntryInfo } from '../webdav';
import { toast } from 'sonner'; import { toast } from 'sonner';
import { MediaEntry } from './MediaEntry'; import { MediaEntry } from './MediaEntry';
import { useWs } from '../ws'; import { useWs } from '../ws';
@ -162,7 +162,7 @@ export default function StatusPage({ config, setConfig, onOpenFileManager }: Sta
</button> </button>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<button <button
onClick={() => onOpenFileManager?.(activeDevice.base_url || activeDevice.url || '/')} onClick={() => onOpenFileManager?.(activeDevice.base_url || (activeDevice.url ? splitPath(activeDevice.url).parent : '/'))}
className="p-2 rounded hover:bg-neutral-100" className="p-2 rounded hover:bg-neutral-100"
title="Browse files" title="Browse files"
> >