From 30f7d41ec3f6abaa5f641b52254b6e1fa9c09904 Mon Sep 17 00:00:00 2001 From: maziggy Date: Tue, 27 Jan 2026 12:30:15 +0100 Subject: [PATCH] Add plate calibration to backup and fix directory creation - Add "Plate Detection" option to backup modal for exporting empty plate reference images (requires Printers to be selected) - Add parents=True to mkdir calls in config.py to create full directory tree on first run (fixes startup crash when data dir doesn't exist) - Update BackupModal test to use exact match for "Printers" text --- .../__tests__/components/BackupModal.test.tsx | 2 +- frontend/src/api/client.ts | 1 + frontend/src/components/BackupModal.tsx | 37 ++++++++++++++----- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/frontend/src/__tests__/components/BackupModal.test.tsx b/frontend/src/__tests__/components/BackupModal.test.tsx index aa70d9f86..e25351e71 100644 --- a/frontend/src/__tests__/components/BackupModal.test.tsx +++ b/frontend/src/__tests__/components/BackupModal.test.tsx @@ -59,7 +59,7 @@ describe('BackupModal', () => { it('has checkbox for printers', () => { render(); - expect(screen.getByText(/printers/i)).toBeInTheDocument(); + expect(screen.getByText('Printers')).toBeInTheDocument(); }); it('has checkbox for archives', () => { diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 6a2a64a82..1b0617af7 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -2214,6 +2214,7 @@ export const api = { if (categories.smart_plugs !== undefined) params.set('include_smart_plugs', String(categories.smart_plugs)); if (categories.external_links !== undefined) params.set('include_external_links', String(categories.external_links)); if (categories.printers !== undefined) params.set('include_printers', String(categories.printers)); + if (categories.plate_calibration !== undefined) params.set('include_plate_calibration', String(categories.plate_calibration)); if (categories.filaments !== undefined) params.set('include_filaments', String(categories.filaments)); if (categories.maintenance !== undefined) params.set('include_maintenance', String(categories.maintenance)); if (categories.archives !== undefined) params.set('include_archives', String(categories.archives)); diff --git a/frontend/src/components/BackupModal.tsx b/frontend/src/components/BackupModal.tsx index 0a276607b..3d9a988ce 100644 --- a/frontend/src/components/BackupModal.tsx +++ b/frontend/src/components/BackupModal.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { Download, X, Settings, Bell, FileText, Plug, Printer, Palette, Wrench, Archive, Loader2, Key, AlertTriangle, Link, FolderKanban, Upload } from 'lucide-react'; +import { Download, X, Settings, Bell, FileText, Plug, Printer, Palette, Wrench, Archive, Loader2, Key, AlertTriangle, Link, FolderKanban, Upload, Camera } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Card, CardContent } from './Card'; import { Button } from './Button'; @@ -12,6 +12,7 @@ interface BackupCategory { icon: React.ReactNode; default: boolean; description: string; + requiresPrinters?: boolean; } const BACKUP_CATEGORIES: BackupCategory[] = [ @@ -63,6 +64,15 @@ const BACKUP_CATEGORIES: BackupCategory[] = [ default: false, description: 'Printer info (access codes excluded)', }, + { + id: 'plate_calibration', + labelKey: 'backup.categories.plateCalibration', + defaultLabel: 'Plate Detection', + icon: , + default: false, + description: 'Empty plate reference images', + requiresPrinters: true, + }, { id: 'filaments', labelKey: 'backup.categories.filaments', @@ -221,33 +231,42 @@ export function BackupModal({ onClose, onExport }: BackupModalProps) { {/* Categories */}
- {BACKUP_CATEGORIES.map((category) => ( + {BACKUP_CATEGORIES.map((category) => { + const isDisabled = isExporting || (category.requiresPrinters && !selected.printers); + return (