ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(9): Add FileManager disk usage visualization and analysis
Juan Denis135f0536bea1
diff --git a/frontend/dist/index.html b/frontend/dist/index.htmlindex e2b045a3..339a6c99 100644--- a/frontend/dist/index.html+++ b/frontend/dist/index.html@@ -6,8 +6,8 @@<link rel="icon" type="image/svg+xml" href="/vite.svg" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>React Dashboard Template</title>- <script type="module" crossorigin src="/assets/index-Ct52KPKJ.js"></script>- <link rel="stylesheet" crossorigin href="/assets/index-Ca2DPnGF.css">+ <script type="module" crossorigin src="/assets/index-Do3Z2i83.js"></script>+ <link rel="stylesheet" crossorigin href="/assets/index-B4xiQifC.css"></head><body>diff --git a/frontend/src/pages/FileManager.jsx b/frontend/src/pages/FileManager.jsxindex a24babf9..ddcc68c7 100644--- a/frontend/src/pages/FileManager.jsx+++ b/frontend/src/pages/FileManager.jsx@@ -3,6 +3,18 @@ import { api } from '../services/api';import { useToast } from '../contexts/ToastContext';import Spinner from '../components/Spinner';import ConfirmDialog from '../components/ConfirmDialog';+import {+ Folder, File, FileCode, FileText, FileImage, FileVideo, FileAudio,+ FileArchive, Database, Terminal, Upload, FolderPlus, FilePlus,+ ArrowLeft, Search, X, RefreshCw, Eye, EyeOff, Download, Edit3,+ Trash2, Lock, BarChart3, ChevronDown, ChevronRight, HardDrive,+ PieChart, Clock, PanelRightClose, PanelRightOpen+} from 'lucide-react';+import { PieChart as RechartsPie, Pie, Cell, ResponsiveContainer, Tooltip, Legend } from 'recharts';++// LocalStorage keys+const SIDEBAR_VISIBLE_KEY = 'serverkit-fm-sidebar';+const DISK_COLLAPSED_KEY = 'serverkit-fm-disk-collapsed';function FileManager() {const [currentPath, setCurrentPath] = useState('/home');@@ -12,7 +24,6 @@ function FileManager() {const [showHidden, setShowHidden] = useState(false);const [searchQuery, setSearchQuery] = useState('');const [searchResults, setSearchResults] = useState(null);- const [diskUsage, setDiskUsage] = useState(null);const [selectedFile, setSelectedFile] = useState(null);const [fileContent, setFileContent] = useState('');const [editingFile, setEditingFile] = useState(null);@@ -31,14 +42,43 @@ function FileManager() {const fileInputRef = useRef(null);const toast = useToast();+ // Sidebar and disk usage state+ const [sidebarVisible, setSidebarVisible] = useState(() => {+ const saved = localStorage.getItem(SIDEBAR_VISIBLE_KEY);+ return saved !== null ? saved === 'true' : true;+ });+ const [diskCollapsed, setDiskCollapsed] = useState(() => {+ const saved = localStorage.getItem(DISK_COLLAPSED_KEY);+ return saved !== null ? saved === 'true' : false;+ });+ const [diskMounts, setDiskMounts] = useState([]);+ const [diskLastUpdated, setDiskLastUpdated] = useState(null);+ const [diskLoading, setDiskLoading] = useState(false);++ // Analysis state+ const [analysisLoading, setAnalysisLoading] = useState(false);+ const [directoryAnalysis, setDirectoryAnalysis] = useState(null);+ const [typeBreakdown, setTypeBreakdown] = useState(null);+ const [analysisView, setAnalysisView] = useState('directories'); // 'directories' | 'files'+useEffect(() => {loadDirectory(currentPath);- loadDiskUsage();+ loadDiskMounts();}, [currentPath, showHidden]);+ useEffect(() => {+ localStorage.setItem(SIDEBAR_VISIBLE_KEY, sidebarVisible);+ }, [sidebarVisible]);++ useEffect(() => {+ localStorage.setItem(DISK_COLLAPSED_KEY, diskCollapsed);+ }, [diskCollapsed]);+const loadDirectory = async (path) => {setLoading(true);setSearchResults(null);+ setDirectoryAnalysis(null);+ setTypeBreakdown(null);try {const data = await api.browseFiles(path, showHidden);setEntries(data.entries || []);@@ -51,15 +91,40 @@ function FileManager() {}};- const loadDiskUsage = async () => {+ const loadDiskMounts = async () => {+ setDiskLoading(true);+ try {+ const data = await api.getAllDiskMounts();+ setDiskMounts(data.mounts || []);+ setDiskLastUpdated(new Date());+ } catch (error) {+ console.error('Failed to load disk mounts:', error);+ } finally {+ setDiskLoading(false);+ }+ };++ const analyzeDirectory = async () => {+ setAnalysisLoading(true);try {- const data = await api.getDiskUsage(currentPath);- setDiskUsage(data);+ const [analysisData, breakdownData] = await Promise.all([+ api.analyzeDirectory(currentPath, 2, 15),+ api.getFileTypeBreakdown(currentPath, 3)+ ]);+ setDirectoryAnalysis(analysisData);+ setTypeBreakdown(breakdownData);} catch (error) {- console.error('Failed to load disk usage:', error);+ toast.error(`Analysis failed: ${error.message}`);+ } finally {+ setAnalysisLoading(false);}};+ const closeAnalysis = () => {+ setDirectoryAnalysis(null);+ setTypeBreakdown(null);+ };+const handleSearch = async () => {if (!searchQuery.trim()) {setSearchResults(null);@@ -230,26 +295,39 @@ function FileManager() {};const getFileIcon = (entry) => {- if (entry.is_dir) return 'folder';+ if (entry.is_dir) return <Folder size={18} className="file-icon-svg folder" />;+const ext = entry.name.split('.').pop().toLowerCase();- const iconMap = {- js: 'javascript', jsx: 'javascript', ts: 'javascript', tsx: 'javascript',- py: 'python', rb: 'ruby', php: 'php', java: 'java',- html: 'html', css: 'css', less: 'css', scss: 'css',- json: 'json', xml: 'xml', yaml: 'yaml', yml: 'yaml',- md: 'markdown', txt: 'text', log: 'text',- sh: 'terminal', bash: 'terminal',- jpg: 'image', jpeg: 'image', png: 'image', gif: 'image', svg: 'image',- pdf: 'pdf', doc: 'document', docx: 'document',- zip: 'archive', tar: 'archive', gz: 'archive', rar: 'archive'- };- return iconMap[ext] || 'file';+ const codeExts = ['js', 'jsx', 'ts', 'tsx', 'py', 'rb', 'php', 'java', 'c', 'cpp', 'h', 'go', 'rs'];+ const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'ico'];+ const videoExts = ['mp4', 'avi', 'mkv', 'mov', 'wmv', 'webm'];+ const audioExts = ['mp3', 'wav', 'flac', 'aac', 'ogg', 'wma'];+ const archiveExts = ['zip', 'tar', 'gz', 'rar', '7z', 'bz2'];+ const dataExts = ['json', 'xml', 'yaml', 'yml', 'csv', 'db', 'sqlite', 'sql'];+ const textExts = ['txt', 'md', 'log', 'ini', 'conf', 'cfg'];++ if (codeExts.includes(ext)) return <FileCode size={18} className="file-icon-svg code" />;+ if (imageExts.includes(ext)) return <FileImage size={18} className="file-icon-svg image" />;+ if (videoExts.includes(ext)) return <FileVideo size={18} className="file-icon-svg video" />;+ if (audioExts.includes(ext)) return <FileAudio size={18} className="file-icon-svg audio" />;+ if (archiveExts.includes(ext)) return <FileArchive size={18} className="file-icon-svg archive" />;+ if (dataExts.includes(ext)) return <Database size={18} className="file-icon-svg data" />;+ if (textExts.includes(ext)) return <FileText size={18} className="file-icon-svg text" />;+ if (['sh', 'bash', 'zsh'].includes(ext)) return <Terminal size={18} className="file-icon-svg terminal" />;++ return <File size={18} className="file-icon-svg" />;+ };++ const getDiskColor = (percent) => {+ if (percent >= 90) return 'critical';+ if (percent >= 70) return 'warning';+ return 'healthy';};const displayedEntries = searchResults || entries;return (- <div className="file-manager">+ <div className={`file-manager ${sidebarVisible ? 'sidebar-open' : ''}`}><div className="page-header"><div className="page-header-content"><h1>File Manager</h1>@@ -257,12 +335,15 @@ function FileManager() {</div><div className="page-header-actions"><button className="btn btn-secondary" onClick={() => fileInputRef.current?.click()}>+ <Upload size={16} />Upload</button><button className="btn btn-secondary" onClick={() => setShowNewFolderModal(true)}>+ <FolderPlus size={16} />New Folder</button><button className="btn btn-primary" onClick={() => setShowNewFileModal(true)}>+ <FilePlus size={16} />New File</button><input@@ -290,12 +371,13 @@ function FileManager() {onClick={() => parentPath && setCurrentPath(parentPath)}disabled={!parentPath}>- <span className="icon">arrow_back</span>+ <ArrowLeft size={16} /></button><span className="current-path">{currentPath}</span></div><div className="toolbar-actions"><div className="search-box">+ <Search size={16} className="search-icon" /><inputtype="text"placeholder="Search files..."@@ -303,164 +385,377 @@ function FileManager() {onChange={(e) => setSearchQuery(e.target.value)}onKeyDown={(e) => e.key === 'Enter' && handleSearch()}/>- <button className="btn btn-icon" onClick={handleSearch}>- <span className="icon">search</span>- </button>{searchResults && (- <button className="btn btn-icon" onClick={() => setSearchResults(null)}>- <span className="icon">close</span>+ <button className="btn btn-icon btn-sm" onClick={() => setSearchResults(null)}>+ <X size={14} /></button>)}</div>+ <button+ className="btn btn-secondary btn-sm"+ onClick={analyzeDirectory}+ disabled={analysisLoading}+ title="Analyze directory sizes"+ >+ <BarChart3 size={14} />+ Analyze+ </button><label className="checkbox-label"><inputtype="checkbox"checked={showHidden}onChange={(e) => setShowHidden(e.target.checked)}/>- Show hidden+ {showHidden ? <Eye size={14} /> : <EyeOff size={14} />}+ Hidden</label>- <button className="btn btn-icon" onClick={() => loadDirectory(currentPath)}>- <span className="icon">refresh</span>+ <button className="btn btn-icon" onClick={() => loadDirectory(currentPath)} title="Refresh">+ <RefreshCw size={16} />+ </button>+ <button+ className="btn btn-icon"+ onClick={() => setSidebarVisible(!sidebarVisible)}+ title={sidebarVisible ? 'Hide sidebar' : 'Show sidebar'}+ >+ {sidebarVisible ? <PanelRightClose size={16} /> : <PanelRightOpen size={16} />}</button></div></div>- {diskUsage && (- <div className="disk-usage-bar">- <div className="disk-usage-info">- <span>Disk Usage: {diskUsage.used_human} / {diskUsage.total_human}</span>- <span>{diskUsage.percent}% used</span>- </div>- <div className="disk-progress">- <div- className={`disk-progress-fill ${diskUsage.percent > 90 ? 'critical' : diskUsage.percent > 75 ? 'warning' : ''}`}- style={{ width: `${diskUsage.percent}%` }}- ></div>- </div>- </div>- )}-- <div className="file-manager-content">- <div className="file-list-container">- {loading ? (- <div className="loading-state">- <Spinner />- </div>- ) : displayedEntries.length === 0 ? (- <div className="empty-state">- <span className="icon">folder_open</span>- <p>{searchResults ? 'No files found matching your search' : 'This directory is empty'}</p>+ <div className="file-manager-layout">+ <div className="file-manager-main">+ <div className="file-manager-content">+ <div className="file-list-container">+ {loading ? (+ <div className="loading-state">+ <Spinner />+ </div>+ ) : displayedEntries.length === 0 ? (+ <div className="empty-state">+ <Folder size={48} strokeWidth={1.5} />+ <p>{searchResults ? 'No files found matching your search' : 'This directory is empty'}</p>+ </div>+ ) : (+ <div className="file-list">+ <div className="file-list-header">+ <span className="col-name">Name</span>+ <span className="col-size">Size</span>+ <span className="col-modified">Modified</span>+ <span className="col-permissions">Permissions</span>+ <span className="col-actions">Actions</span>+ </div>+ {displayedEntries.map((entry) => (+ <div+ key={entry.path}+ className={`file-item ${selectedFile?.path === entry.path ? 'selected' : ''}`}+ onClick={() => handleNavigate(entry)}+ >+ <span className="col-name">+ {getFileIcon(entry)}+ {entry.name}+ {entry.is_link && <span className="link-indicator">→</span>}+ </span>+ <span className="col-size">{entry.is_dir ? '-' : entry.size_human}</span>+ <span className="col-modified">+ {new Date(entry.modified).toLocaleDateString()}+ </span>+ <span className="col-permissions">{entry.permissions}</span>+ <span className="col-actions" onClick={(e) => e.stopPropagation()}>+ {!entry.is_dir && (+ <button+ className="btn btn-icon btn-sm"+ onClick={() => handleDownload(entry)}+ title="Download"+ >+ <Download size={14} />+ </button>+ )}+ <button+ className="btn btn-icon btn-sm"+ onClick={() => openRenameModal(entry)}+ title="Rename"+ >+ <Edit3 size={14} />+ </button>+ <button+ className="btn btn-icon btn-sm"+ onClick={() => openPermissionsModal(entry)}+ title="Permissions"+ >+ <Lock size={14} />+ </button>+ <button+ className="btn btn-icon btn-sm btn-danger"+ onClick={() => handleDelete(entry)}+ title="Delete"+ >+ <Trash2 size={14} />+ </button>+ </span>+ </div>+ ))}+ </div>+ )}</div>- ) : (- <div className="file-list">- <div className="file-list-header">- <span className="col-name">Name</span>- <span className="col-size">Size</span>- <span className="col-modified">Modified</span>- <span className="col-permissions">Permissions</span>- <span className="col-actions">Actions</span>- </div>- {displayedEntries.map((entry) => (- <div- key={entry.path}- className={`file-item ${selectedFile?.path === entry.path ? 'selected' : ''}`}- onClick={() => handleNavigate(entry)}- >- <span className="col-name">- <span className={`file-icon ${getFileIcon(entry)}`}></span>- {entry.name}- {entry.is_link && <span className="link-indicator">→</span>}- </span>- <span className="col-size">{entry.is_dir ? '-' : entry.size_human}</span>- <span className="col-modified">- {new Date(entry.modified).toLocaleDateString()}- </span>- <span className="col-permissions">{entry.permissions}</span>- <span className="col-actions" onClick={(e) => e.stopPropagation()}>- {!entry.is_dir && (- <button- className="btn btn-icon btn-sm"- onClick={() => handleDownload(entry)}- title="Download"- >- <span className="icon">download</span>++ {selectedFile && !selectedFile.is_dir && (+ <div className="file-preview">+ <div className="preview-header">+ <h3>{selectedFile.name}</h3>+ <div className="preview-actions">+ {selectedFile.is_editable && !editingFile && (+ <button className="btn btn-primary btn-sm" onClick={handleEditFile}>+ <Edit3 size={14} />+ Edit</button>)}- <button- className="btn btn-icon btn-sm"- onClick={() => openRenameModal(entry)}- title="Rename"- >- <span className="icon">edit</span>+ {editingFile && (+ <>+ <button className="btn btn-secondary btn-sm" onClick={() => setEditingFile(null)}>+ Cancel+ </button>+ <button className="btn btn-primary btn-sm" onClick={handleSaveFile}>+ Save+ </button>+ </>+ )}+ <button className="btn btn-icon btn-sm" onClick={() => setSelectedFile(null)}>+ <X size={16} /></button>- <button- className="btn btn-icon btn-sm"- onClick={() => openPermissionsModal(entry)}- title="Permissions"- >- <span className="icon">lock</span>+ </div>+ </div>+ <div className="preview-info">+ <span>Size: {selectedFile.size_human}</span>+ <span>Owner: {selectedFile.owner}</span>+ <span>Group: {selectedFile.group}</span>+ {selectedFile.mime_type && <span>Type: {selectedFile.mime_type}</span>}+ </div>+ {selectedFile.is_editable ? (+ <textarea+ className="file-editor"+ value={fileContent}+ onChange={(e) => setFileContent(e.target.value)}+ readOnly={!editingFile}+ spellCheck={false}+ />+ ) : (+ <div className="preview-unavailable">+ <EyeOff size={48} strokeWidth={1.5} />+ <p>Preview not available for this file type</p>+ <button className="btn btn-primary" onClick={() => handleDownload(selectedFile)}>+ <Download size={16} />+ Download File</button>+ </div>+ )}+ </div>+ )}+ </div>+ </div>++ {/* Sidebar */}+ {sidebarVisible && (+ <div className="file-manager-sidebar">+ {/* Disk Usage Section */}+ <div className="sidebar-section">+ <button+ className="sidebar-section-header"+ onClick={() => setDiskCollapsed(!diskCollapsed)}+ >+ <HardDrive size={16} />+ <span>Disk Usage</span>+ {diskCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />}+ </button>++ {!diskCollapsed && (+ <div className="sidebar-section-content">+ <div className="disk-header-row">+ {diskLastUpdated && (+ <span className="disk-updated">+ <Clock size={12} />+ {diskLastUpdated.toLocaleTimeString()}+ </span>+ )}<button- className="btn btn-icon btn-sm btn-danger"- onClick={() => handleDelete(entry)}- title="Delete"+ className="btn btn-icon btn-sm"+ onClick={loadDiskMounts}+ disabled={diskLoading}+ title="Refresh">- <span className="icon">delete</span>+ <RefreshCw size={12} className={diskLoading ? 'spinning' : ''} /></button>- </span>+ </div>++ {diskMounts.map((mount, idx) => (+ <div key={idx} className="disk-mount-item">+ <div className="disk-mount-header">+ <span className="disk-mount-point">{mount.mountpoint}</span>+ <span className={`disk-percent ${getDiskColor(mount.percent)}`}>+ {mount.percent}%+ </span>+ </div>+ <div className={`disk-progress ${getDiskColor(mount.percent)}`}>+ <div+ className="disk-progress-fill"+ style={{ width: `${mount.percent}%` }}+ />+ </div>+ <div className="disk-mount-info">+ <span>{mount.used_human} / {mount.total_human}</span>+ <span className="disk-device">{mount.device}</span>+ </div>+ </div>+ ))}</div>- ))}+ )}</div>- )}- </div>- {selectedFile && !selectedFile.is_dir && (- <div className="file-preview">- <div className="preview-header">- <h3>{selectedFile.name}</h3>- <div className="preview-actions">- {selectedFile.is_editable && !editingFile && (- <button className="btn btn-primary btn-sm" onClick={handleEditFile}>- Edit+ {/* Analysis Section */}+ {(directoryAnalysis || analysisLoading) && (+ <div className="sidebar-section analysis-section">+ <div className="sidebar-section-header static">+ <BarChart3 size={16} />+ <span>Directory Analysis</span>+ <button+ className="btn btn-icon btn-sm close-btn"+ onClick={closeAnalysis}+ >+ <X size={14} /></button>- )}- {editingFile && (- <>- <button className="btn btn-secondary btn-sm" onClick={() => setEditingFile(null)}>- Cancel- </button>- <button className="btn btn-primary btn-sm" onClick={handleSaveFile}>- Save- </button>- </>- )}- <button className="btn btn-icon btn-sm" onClick={() => setSelectedFile(null)}>- <span className="icon">close</span>- </button>+ </div>++ <div className="sidebar-section-content">+ {analysisLoading ? (+ <div className="analysis-loading">+ <Spinner />+ <span>Analyzing...</span>+ </div>+ ) : (+ <>+ <div className="analysis-total">+ Total: {directoryAnalysis.total_size_human}+ </div>++ {/* View Toggle */}+ <div className="analysis-tabs">+ <button+ className={`analysis-tab ${analysisView === 'directories' ? 'active' : ''}`}+ onClick={() => setAnalysisView('directories')}+ >+ <Folder size={14} />+ Directories+ </button>+ <button+ className={`analysis-tab ${analysisView === 'files' ? 'active' : ''}`}+ onClick={() => setAnalysisView('files')}+ >+ <File size={14} />+ Files+ </button>+ </div>++ {/* Directory Sizes */}+ {analysisView === 'directories' && (+ <div className="analysis-bars">+ {directoryAnalysis.directories.slice(0, 10).map((dir, idx) => (+ <div+ key={idx}+ className="analysis-bar-item"+ onClick={() => setCurrentPath(dir.path)}+ >+ <div className="analysis-bar-header">+ <span className="analysis-bar-name">+ <Folder size={12} />+ {dir.name}+ </span>+ <span className="analysis-bar-size">{dir.size_human}</span>+ </div>+ <div className="analysis-bar-track">+ <div+ className="analysis-bar-fill"+ style={{ width: `${dir.percent}%` }}+ />+ </div>+ </div>+ ))}+ {directoryAnalysis.directories.length === 0 && (+ <div className="analysis-empty">No subdirectories</div>+ )}+ </div>+ )}++ {/* Largest Files */}+ {analysisView === 'files' && (+ <div className="analysis-files">+ {directoryAnalysis.largest_files.slice(0, 10).map((file, idx) => (+ <div+ key={idx}+ className="analysis-file-item"+ onClick={() => handleFileClick(file)}+ >+ <File size={12} />+ <span className="analysis-file-name">{file.name}</span>+ <span className="analysis-file-size">{file.size_human}</span>+ </div>+ ))}+ {directoryAnalysis.largest_files.length === 0 && (+ <div className="analysis-empty">No files</div>+ )}+ </div>+ )}+ </>+ )}+ </div></div>- </div>- <div className="preview-info">- <span>Size: {selectedFile.size_human}</span>- <span>Owner: {selectedFile.owner}</span>- <span>Group: {selectedFile.group}</span>- {selectedFile.mime_type && <span>Type: {selectedFile.mime_type}</span>}- </div>- {selectedFile.is_editable ? (- <textarea- className="file-editor"- value={fileContent}- onChange={(e) => setFileContent(e.target.value)}- readOnly={!editingFile}- spellCheck={false}- />- ) : (- <div className="preview-unavailable">- <span className="icon">visibility_off</span>- <p>Preview not available for this file type</p>- <button className="btn btn-primary" onClick={() => handleDownload(selectedFile)}>- Download File- </button>+ )}++ {/* Type Breakdown Section */}+ {typeBreakdown && typeBreakdown.breakdown && typeBreakdown.breakdown.length > 0 && (+ <div className="sidebar-section">+ <div className="sidebar-section-header static">+ <PieChart size={16} />+ <span>File Types</span>+ </div>+ <div className="sidebar-section-content">+ <div className="type-breakdown-chart">+ <ResponsiveContainer width="100%" height={180}>+ <RechartsPie>+ <Pie+ data={typeBreakdown.breakdown}+ dataKey="size"+ nameKey="name"+ cx="50%"+ cy="50%"+ outerRadius={60}+ innerRadius={35}+ paddingAngle={2}+ >+ {typeBreakdown.breakdown.map((entry, idx) => (+ <Cell key={idx} fill={entry.color} />+ ))}+ </Pie>+ <Tooltip+ formatter={(value, name) => [+ typeBreakdown.breakdown.find(b => b.name === name)?.size_human || value,+ name+ ]}+ />+ </RechartsPie>+ </ResponsiveContainer>+ </div>+ <div className="type-breakdown-legend">+ {typeBreakdown.breakdown.map((cat, idx) => (+ <div key={idx} className="type-legend-item">+ <span+ className="type-legend-color"+ style={{ background: cat.color }}+ />+ <span className="type-legend-name">{cat.name}</span>+ <span className="type-legend-size">{cat.size_human}</span>+ </div>+ ))}+ </div>+ </div></div>)}</div>@@ -474,7 +769,7 @@ function FileManager() {<div className="modal-header"><h2>Create New File</h2><button className="btn btn-icon" onClick={() => setShowNewFileModal(false)}>- <span className="icon">close</span>+ <X size={20} /></button></div><div className="modal-body">@@ -509,7 +804,7 @@ function FileManager() {<div className="modal-header"><h2>Create New Folder</h2><button className="btn btn-icon" onClick={() => setShowNewFolderModal(false)}>- <span className="icon">close</span>+ <X size={20} /></button></div><div className="modal-body">@@ -544,7 +839,7 @@ function FileManager() {<div className="modal-header"><h2>Rename {renameTarget?.is_dir ? 'Folder' : 'File'}</h2><button className="btn btn-icon" onClick={() => setShowRenameModal(false)}>- <span className="icon">close</span>+ <X size={20} /></button></div><div className="modal-body">@@ -577,7 +872,7 @@ function FileManager() {<div className="modal-header"><h2>Change Permissions</h2><button className="btn btn-icon" onClick={() => setShowPermissionsModal(false)}>- <span className="icon">close</span>+ <X size={20} /></button></div><div className="modal-body">diff --git a/frontend/src/services/api.js b/frontend/src/services/api.jsindex 0fe58a02..ed3de254 100644--- a/frontend/src/services/api.js+++ b/frontend/src/services/api.js@@ -1580,6 +1580,20 @@ class ApiService {return this.request(`/files/disk-usage?path=${encodeURIComponent(path)}`);}+ async getAllDiskMounts() {+ return this.request('/files/disk-mounts');+ }++ async analyzeDirectory(path = '/home', depth = 2, limit = 20) {+ const params = new URLSearchParams({ path, depth, limit });+ return this.request(`/files/analyze?${params}`);+ }++ async getFileTypeBreakdown(path = '/home', maxDepth = 3) {+ const params = new URLSearchParams({ path, max_depth: maxDepth });+ return this.request(`/files/type-breakdown?${params}`);+ }+async downloadFile(path) {const token = this.getToken();const url = `${this.baseUrl}/files/download?path=${encodeURIComponent(path)}`;diff --git a/frontend/src/styles/pages/_file-manager.less b/frontend/src/styles/pages/_file-manager.lessindex 0cfe3698..37e282c4 100644--- a/frontend/src/styles/pages/_file-manager.less+++ b/frontend/src/styles/pages/_file-manager.less@@ -1,60 +1,69 @@// File Manager Page Styles.file-manager {+ display: flex;+ flex-direction: column;+ gap: @space-4;+.page-header {display: flex;justify-content: space-between;align-items: flex-start;- margin-bottom: 24px;flex-wrap: wrap;- gap: 16px;+ gap: @space-4;.page-header-content {h1 {- font-size: 24px;- font-weight: 600;- margin: 0 0 4px 0;+ font-size: @font-size-2xl;+ font-weight: @font-weight-semibold;+ margin: 0 0 @space-1 0;}.page-description {- color: var(--text-secondary);+ color: @text-secondary;margin: 0;}}.page-header-actions {display: flex;- gap: 8px;+ gap: @space-2;+ flex-wrap: wrap;++ .btn {+ display: flex;+ align-items: center;+ gap: @space-2;+ }}}.upload-progress {display: flex;align-items: center;- gap: 12px;- padding: 12px 16px;- background: var(--card-bg);- border-radius: 8px;- margin-bottom: 16px;+ gap: @space-3;+ padding: @space-3 @space-4;+ background: @bg-card;+ border-radius: @radius-lg;.progress-bar {flex: 1;height: 8px;- background: var(--border-color);- border-radius: 4px;+ background: @border-default;+ border-radius: @radius-sm;overflow: hidden;.progress-fill {height: 100%;- background: var(--primary);- transition: width 0.3s ease;+ background: @accent-primary;+ .transition(width);}}span {- font-size: 13px;- font-weight: 500;- color: var(--text-secondary);+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;+ color: @text-secondary;min-width: 40px;}}@@ -63,47 +72,58 @@display: flex;justify-content: space-between;align-items: center;- padding: 12px 16px;- background: var(--card-bg);- border-radius: 8px;- margin-bottom: 16px;- gap: 16px;+ padding: @space-3 @space-4;+ background: @bg-card;+ border-radius: @radius-lg;+ gap: @space-4;flex-wrap: wrap;.path-breadcrumb {display: flex;align-items: center;- gap: 8px;+ gap: @space-2;.current-path {- font-family: var(--font-mono);- font-size: 13px;- color: var(--text-primary);- background: var(--bg-tertiary);- padding: 6px 12px;- border-radius: 4px;+ font-family: @font-mono;+ font-size: @font-size-sm;+ color: @text-primary;+ background: @bg-tertiary;+ padding: @space-2 @space-3;+ border-radius: @radius-md;}}.toolbar-actions {display: flex;align-items: center;- gap: 12px;+ gap: @space-3;+ flex-wrap: wrap;.search-box {display: flex;align-items: center;- gap: 4px;- background: var(--bg-tertiary);- border-radius: 6px;- padding: 0 4px;+ gap: @space-2;+ background: @bg-tertiary;+ border-radius: @radius-md;+ padding: 0 @space-2;+ position: relative;++ .search-icon {+ color: @text-tertiary;+ flex-shrink: 0;+ }input {background: transparent;border: none;- padding: 8px 12px;- font-size: 13px;- width: 200px;+ padding: @space-2 @space-3;+ font-size: @font-size-sm;+ width: 180px;+ color: @text-primary;++ &::placeholder {+ color: @text-tertiary;+ }&:focus {outline: none;@@ -114,68 +134,393 @@.checkbox-label {display: flex;align-items: center;- gap: 6px;- font-size: 13px;- color: var(--text-secondary);+ gap: @space-2;+ font-size: @font-size-sm;+ color: @text-secondary;cursor: pointer;input[type="checkbox"] {width: 16px;height: 16px;}++ svg {+ color: @text-tertiary;+ }}}}- .disk-usage-bar {- padding: 12px 16px;- background: var(--card-bg);- border-radius: 8px;- margin-bottom: 16px;+ // Main layout with sidebar+ .file-manager-layout {+ display: flex;+ gap: @space-4;+ min-height: 0;+ }++ .file-manager-main {+ flex: 1;+ min-width: 0;+ }- .disk-usage-info {- display: flex;- justify-content: space-between;- font-size: 13px;- color: var(--text-secondary);- margin-bottom: 8px;+ .file-manager-content {+ display: grid;+ grid-template-columns: 1fr 400px;+ gap: @space-4;++ @media (max-width: @breakpoint-xl) {+ grid-template-columns: 1fr;}+ }- .disk-progress {- height: 6px;- background: var(--border-color);- border-radius: 3px;- overflow: hidden;+ // Sidebar+ .file-manager-sidebar {+ width: 320px;+ flex-shrink: 0;+ display: flex;+ flex-direction: column;+ gap: @space-4;+ .transition(all);++ @media (max-width: @breakpoint-lg) {+ position: fixed;+ right: 0;+ top: 64px;+ bottom: 0;+ width: 100%;+ max-width: 360px;+ background: @bg-body;+ padding: @space-4;+ z-index: @z-modal;+ box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);+ overflow-y: auto;+ }+ }- .disk-progress-fill {- height: 100%;- background: var(--primary);- transition: width 0.3s ease;+ &:not(.sidebar-open) .file-manager-sidebar {+ @media (max-width: @breakpoint-lg) {+ transform: translateX(100%);+ }+ }- &.warning {- background: var(--warning);- }+ .sidebar-section {+ background: @bg-card;+ border-radius: @radius-lg;+ overflow: hidden;+ }- &.critical {- background: var(--danger);- }+ .sidebar-section-header {+ display: flex;+ align-items: center;+ gap: @space-2;+ padding: @space-3 @space-4;+ background: @bg-elevated;+ border: none;+ width: 100%;+ text-align: left;+ cursor: pointer;+ color: @text-primary;+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;+ .transition(background);++ &:hover {+ background: @bg-tertiary;+ }++ &.static {+ cursor: default;++ &:hover {+ background: @bg-elevated;}}++ span {+ flex: 1;+ }++ .close-btn {+ margin-left: auto;+ }}- .file-manager-content {- display: grid;- grid-template-columns: 1fr 400px;- gap: 16px;+ .sidebar-section-content {+ padding: @space-3 @space-4;+ }- @media (max-width: 1200px) {- grid-template-columns: 1fr;+ // Disk usage section+ .disk-header-row {+ display: flex;+ justify-content: space-between;+ align-items: center;+ margin-bottom: @space-3;+ }++ .disk-updated {+ display: flex;+ align-items: center;+ gap: @space-1;+ font-size: @font-size-xs;+ color: @text-tertiary;+ }++ .disk-mount-item {+ padding: @space-3 0;+ border-bottom: 1px solid @border-subtle;++ &:last-child {+ border-bottom: none;+ padding-bottom: 0;+ }++ &:first-child {+ padding-top: 0;+ }+ }++ .disk-mount-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ margin-bottom: @space-2;+ }++ .disk-mount-point {+ font-family: @font-mono;+ font-size: @font-size-sm;+ color: @text-primary;+ }++ .disk-percent {+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;++ &.healthy { color: @success; }+ &.warning { color: @warning; }+ &.critical { color: @danger; }+ }++ .disk-progress {+ height: 6px;+ background: @border-default;+ border-radius: @radius-sm;+ overflow: hidden;+ margin-bottom: @space-2;++ .disk-progress-fill {+ height: 100%;+ .transition(width);+ }++ &.healthy .disk-progress-fill { background: @success; }+ &.warning .disk-progress-fill { background: @warning; }+ &.critical .disk-progress-fill { background: @danger; }+ }++ .disk-mount-info {+ display: flex;+ justify-content: space-between;+ font-size: @font-size-xs;+ color: @text-tertiary;+ }++ .disk-device {+ font-family: @font-mono;+ }++ // Analysis section+ .analysis-loading {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-2;+ padding: @space-6 0;+ color: @text-secondary;+ font-size: @font-size-sm;+ }++ .analysis-total {+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;+ color: @text-primary;+ margin-bottom: @space-3;+ }++ .analysis-tabs {+ display: flex;+ gap: @space-2;+ margin-bottom: @space-3;+ }++ .analysis-tab {+ flex: 1;+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-1;+ padding: @space-2;+ background: @bg-tertiary;+ border: 1px solid transparent;+ border-radius: @radius-md;+ font-size: @font-size-xs;+ color: @text-secondary;+ cursor: pointer;+ .transition(all);++ &:hover {+ background: @bg-hover;+ }++ &.active {+ background: @accent-glow;+ border-color: fade(@accent-primary, 30%);+ color: @accent-primary;+ }+ }++ .analysis-bars {+ display: flex;+ flex-direction: column;+ gap: @space-2;+ }++ .analysis-bar-item {+ cursor: pointer;+ padding: @space-2;+ border-radius: @radius-md;+ .transition(background);++ &:hover {+ background: @bg-hover;+ }+ }++ .analysis-bar-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ margin-bottom: @space-1;+ }++ .analysis-bar-name {+ display: flex;+ align-items: center;+ gap: @space-1;+ font-size: @font-size-xs;+ color: @text-primary;+ .truncate();++ svg {+ color: @warning;+ flex-shrink: 0;}}+ .analysis-bar-size {+ font-size: @font-size-xs;+ color: @text-tertiary;+ font-family: @font-mono;+ }++ .analysis-bar-track {+ height: 4px;+ background: @border-default;+ border-radius: @radius-sm;+ overflow: hidden;+ }++ .analysis-bar-fill {+ height: 100%;+ background: @accent-primary;+ .transition(width);+ }++ .analysis-files {+ display: flex;+ flex-direction: column;+ gap: @space-1;+ }++ .analysis-file-item {+ display: flex;+ align-items: center;+ gap: @space-2;+ padding: @space-2;+ border-radius: @radius-md;+ cursor: pointer;+ .transition(background);++ &:hover {+ background: @bg-hover;+ }++ svg {+ color: @text-tertiary;+ flex-shrink: 0;+ }+ }++ .analysis-file-name {+ flex: 1;+ font-size: @font-size-xs;+ color: @text-primary;+ .truncate();+ }++ .analysis-file-size {+ font-size: @font-size-xs;+ color: @text-tertiary;+ font-family: @font-mono;+ }++ .analysis-empty {+ padding: @space-4 0;+ text-align: center;+ color: @text-tertiary;+ font-size: @font-size-sm;+ }++ // Type breakdown chart+ .type-breakdown-chart {+ margin-bottom: @space-3;+ }++ .type-breakdown-legend {+ display: flex;+ flex-direction: column;+ gap: @space-2;+ }++ .type-legend-item {+ display: flex;+ align-items: center;+ gap: @space-2;+ }++ .type-legend-color {+ width: 10px;+ height: 10px;+ border-radius: @radius-sm;+ flex-shrink: 0;+ }++ .type-legend-name {+ flex: 1;+ font-size: @font-size-xs;+ color: @text-primary;+ }++ .type-legend-size {+ font-size: @font-size-xs;+ color: @text-tertiary;+ font-family: @font-mono;+ }++ // File list.file-list-container {- background: var(--card-bg);- border-radius: 8px;+ background: @bg-card;+ border-radius: @radius-lg;overflow: hidden;.loading-state,@@ -184,12 +529,15 @@flex-direction: column;align-items: center;justify-content: center;- padding: 48px;- color: var(--text-tertiary);+ padding: @space-12;+ color: @text-tertiary;- .icon {- font-size: 48px;- margin-bottom: 16px;+ svg {+ margin-bottom: @space-4;+ }++ p {+ margin: 0;}}}@@ -198,105 +546,65 @@.file-list-header {display: grid;grid-template-columns: 1fr 100px 120px 120px 120px;- padding: 12px 16px;- background: var(--bg-tertiary);- font-size: 12px;- font-weight: 600;+ padding: @space-3 @space-4;+ background: @bg-tertiary;+ font-size: @font-size-xs;+ font-weight: @font-weight-semibold;text-transform: uppercase;- color: var(--text-tertiary);- border-bottom: 1px solid var(--border-color);+ color: @text-tertiary;+ border-bottom: 1px solid @border-default;}.file-item {display: grid;grid-template-columns: 1fr 100px 120px 120px 120px;- padding: 12px 16px;- border-bottom: 1px solid var(--border-color);+ padding: @space-3 @space-4;+ border-bottom: 1px solid @border-default;cursor: pointer;- transition: background 0.2s;+ .transition(background);&:hover {- background: var(--bg-tertiary);+ background: @bg-hover;}&.selected {- background: rgba(var(--primary-rgb), 0.1);+ background: @accent-glow;}.col-name {display: flex;align-items: center;- gap: 8px;+ gap: @space-2;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;- .file-icon {- width: 20px;- height: 20px;- display: flex;- align-items: center;- justify-content: center;-- &.folder::before {- content: "📁";- }-- &.file::before {- content: "📄";- }-- &.javascript::before {- content: "📜";- }-- &.python::before {- content: "🐍";- }-- &.image::before {- content: "🖼️";- }-- &.text::before {- content: "📝";- }-- &.archive::before {- content: "📦";- }-- &.terminal::before {- content: "⚡";- }- }-.link-indicator {- color: var(--text-tertiary);- font-size: 12px;+ color: @text-tertiary;+ font-size: @font-size-sm;}}.col-size,.col-modified,.col-permissions {- font-size: 13px;- color: var(--text-secondary);+ font-size: @font-size-sm;+ color: @text-secondary;}.col-permissions {- font-family: var(--font-mono);- font-size: 12px;+ font-family: @font-mono;+ font-size: @font-size-xs;}.col-actions {display: flex;- gap: 4px;+ gap: @space-1;justify-content: flex-end;.btn-icon {opacity: 0;- transition: opacity 0.2s;+ .transition(opacity);}}@@ -306,9 +614,26 @@}}+ // File icons+ .file-icon-svg {+ flex-shrink: 0;+ color: @text-tertiary;++ &.folder { color: @warning; }+ &.code { color: #8b5cf6; }+ &.image { color: @success; }+ &.video { color: #ec4899; }+ &.audio { color: @warning; }+ &.archive { color: @danger; }+ &.data { color: #14b8a6; }+ &.text { color: @text-secondary; }+ &.terminal { color: @success; }+ }++ // File preview.file-preview {- background: var(--card-bg);- border-radius: 8px;+ background: @bg-card;+ border-radius: @radius-lg;display: flex;flex-direction: column;max-height: calc(100vh - 300px);@@ -317,13 +642,13 @@display: flex;justify-content: space-between;align-items: center;- padding: 16px;- border-bottom: 1px solid var(--border-color);+ padding: @space-4;+ border-bottom: 1px solid @border-default;h3 {margin: 0;- font-size: 14px;- font-weight: 600;+ font-size: @font-size-base;+ font-weight: @font-weight-semibold;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;@@ -331,37 +656,37 @@.preview-actions {display: flex;- gap: 8px;+ gap: @space-2;}}.preview-info {display: flex;- gap: 16px;- padding: 12px 16px;- background: var(--bg-tertiary);- font-size: 12px;- color: var(--text-secondary);+ gap: @space-4;+ padding: @space-3 @space-4;+ background: @bg-tertiary;+ font-size: @font-size-xs;+ color: @text-secondary;flex-wrap: wrap;}.file-editor {flex: 1;- padding: 16px;- font-family: var(--font-mono);- font-size: 13px;- line-height: 1.5;- background: var(--bg-primary);+ padding: @space-4;+ font-family: @font-mono;+ font-size: @font-size-sm;+ line-height: @line-height-relaxed;+ background: @bg-body;border: none;resize: none;- color: var(--text-primary);+ color: @text-primary;&:focus {outline: none;}&[readonly] {- background: var(--bg-tertiary);+ background: @bg-tertiary;}}@@ -371,45 +696,113 @@flex-direction: column;align-items: center;justify-content: center;- padding: 48px;- color: var(--text-tertiary);+ padding: @space-12;+ color: @text-tertiary;- .icon {- font-size: 48px;- margin-bottom: 16px;+ svg {+ margin-bottom: @space-4;}p {- margin-bottom: 16px;+ margin-bottom: @space-4;}}}.permissions-help {- margin-top: 16px;- padding: 12px;- background: var(--bg-tertiary);- border-radius: 6px;- font-size: 13px;+ margin-top: @space-4;+ padding: @space-3;+ background: @bg-tertiary;+ border-radius: @radius-md;+ font-size: @font-size-sm;p {- margin: 0 0 8px 0;- font-weight: 500;+ margin: 0 0 @space-2 0;+ font-weight: @font-weight-medium;}ul {margin: 0;- padding-left: 20px;+ padding-left: @space-5;li {- margin-bottom: 4px;+ margin-bottom: @space-1;}code {- background: var(--bg-primary);- padding: 2px 6px;- border-radius: 4px;+ background: @bg-body;+ padding: 2px @space-2;+ border-radius: @radius-sm;+ }+ }+ }++ // Spinning animation for refresh+ .spinning {+ animation: spin 1s linear infinite;+ }++ @keyframes spin {+ from { transform: rotate(0deg); }+ to { transform: rotate(360deg); }+ }+}++// Responsive adjustments+@media (max-width: @breakpoint-md) {+ .file-manager {+ .page-header {+ flex-direction: column;+ align-items: stretch;++ .page-header-actions {+ justify-content: flex-end;+ }+ }++ .file-manager-toolbar {+ flex-direction: column;+ align-items: stretch;++ .path-breadcrumb {+ order: 1;}++ .toolbar-actions {+ order: 2;+ justify-content: space-between;+ }+ }++ .file-list {+ .file-list-header,+ .file-item {+ grid-template-columns: 1fr 80px 100px;++ .col-permissions,+ .col-modified {+ display: none;+ }+ }+ }+ }+}++@media (max-width: @breakpoint-sm) {+ .file-manager {+ .file-list {+ .file-list-header,+ .file-item {+ grid-template-columns: 1fr 80px;++ .col-size {+ display: none;+ }+ }+ }++ .file-manager-content {+ grid-template-columns: 1fr !important;}}}