diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad47fee6..51f216931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ All notable changes to Bambuddy will be documented in this file. - 8 basic colors shown by default (White, Black, Red, Blue, Green, Yellow, Orange, Gray) - Click "+" to expand 24 additional colors (Cyan, Magenta, Purple, Pink, Brown, Beige, Navy, Teal, Lime, Gold, Silver, Maroon, Olive, Coral, Salmon, Turquoise, Violet, Indigo, Chocolate, Tan, Slate, Charcoal, Ivory, Cream) - Click "-" to collapse back to basic colors +- **File Manager Sorting** - Printer file manager now has sorting options: + - Sort by name (A-Z or Z-A) + - Sort by size (smallest or largest first) + - Sort by date (oldest or newest first) + - Directories always sorted first ### Fixed - **User preset AMS configuration** - Fixed user presets (inheriting from Bambu presets) showing empty fields in Bambu Studio after configuration: diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 48f0cab78..1e4fb20e2 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -1470,6 +1470,7 @@ export const api = { is_directory: boolean; size: number; path: string; + mtime?: string; }>; }>(`/printers/${printerId}/files?path=${encodeURIComponent(path)}`), getPrinterFileDownloadUrl: (printerId: number, path: string) => diff --git a/frontend/src/components/FileManagerModal.tsx b/frontend/src/components/FileManagerModal.tsx index 0d6c89e8e..6cab88997 100644 --- a/frontend/src/components/FileManagerModal.tsx +++ b/frontend/src/components/FileManagerModal.tsx @@ -15,6 +15,7 @@ import { FileText, Image, Search, + ArrowUpDown, } from 'lucide-react'; import { api } from '../api/client'; import { Button } from './Button'; @@ -66,6 +67,17 @@ function getFileIcon(filename: string, isDirectory: boolean) { } } +type SortOption = 'name-asc' | 'name-desc' | 'size-asc' | 'size-desc' | 'date-asc' | 'date-desc'; + +const SORT_OPTIONS: { value: SortOption; label: string }[] = [ + { value: 'name-asc', label: 'Name (A-Z)' }, + { value: 'name-desc', label: 'Name (Z-A)' }, + { value: 'size-asc', label: 'Size (smallest)' }, + { value: 'size-desc', label: 'Size (largest)' }, + { value: 'date-asc', label: 'Date (oldest)' }, + { value: 'date-desc', label: 'Date (newest)' }, +]; + export function FileManagerModal({ printerId, printerName, onClose }: FileManagerModalProps) { const { showToast } = useToast(); const queryClient = useQueryClient(); @@ -73,6 +85,7 @@ export function FileManagerModal({ printerId, printerName, onClose }: FileManage const [selectedFile, setSelectedFile] = useState(null); const [searchQuery, setSearchQuery] = useState(''); const [fileToDelete, setFileToDelete] = useState(null); + const [sortBy, setSortBy] = useState('name-asc'); // Close on Escape key useEffect(() => { @@ -206,6 +219,20 @@ export function FileManagerModal({ printerId, printerName, onClose }: FileManage className="w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none" /> +
+ + +