feat(watcher): Ajout watcher de fichiers temps réel

- Migration 0006: colonne watcher_enabled
- Crate notify pour surveillance FS temps réel (FSEvents/inotify)
- Watcher redémarré toutes les 30s si config change
- Détection instantanée création/modification/suppression
- Création job immédiate quand fichier détecté
- API: support watcher_enabled dans UpdateMonitoringRequest
- Backoffice: toggle Watcher avec indicateur 
- Fonctionne en parallèle du scheduler auto-scan

Usage: Activer Watcher + Auto-scan pour réactivité max
This commit is contained in:
2026-03-06 11:49:53 +01:00
parent 6e0a77fae0
commit 75f7de2e43
8 changed files with 340 additions and 25 deletions

View File

@@ -6,9 +6,10 @@ interface MonitoringFormProps {
libraryId: string;
monitorEnabled: boolean;
scanMode: string;
watcherEnabled: boolean;
}
export function MonitoringForm({ libraryId, monitorEnabled, scanMode }: MonitoringFormProps) {
export function MonitoringForm({ libraryId, monitorEnabled, scanMode, watcherEnabled }: MonitoringFormProps) {
const [isPending, startTransition] = useTransition();
const handleSubmit = (formData: FormData) => {
@@ -20,6 +21,7 @@ export function MonitoringForm({ libraryId, monitorEnabled, scanMode }: Monitori
body: JSON.stringify({
monitor_enabled: formData.get("monitor_enabled") === "true",
scan_mode: formData.get("scan_mode"),
watcher_enabled: formData.get("watcher_enabled") === "true",
}),
});
if (response.ok) {
@@ -34,16 +36,29 @@ export function MonitoringForm({ libraryId, monitorEnabled, scanMode }: Monitori
return (
<form action={handleSubmit} className="monitoring-form">
<input type="hidden" name="id" value={libraryId} />
<label className={`monitor-toggle ${isPending ? 'pending' : ''}`}>
<input
type="checkbox"
name="monitor_enabled"
value="true"
defaultChecked={monitorEnabled}
disabled={isPending}
/>
Auto
</label>
<div className="monitor-options">
<label className={`monitor-toggle ${isPending ? 'pending' : ''}`}>
<input
type="checkbox"
name="monitor_enabled"
value="true"
defaultChecked={monitorEnabled}
disabled={isPending}
/>
<span className="toggle-label">Auto-scan</span>
</label>
<label className={`monitor-toggle watcher-toggle ${isPending ? 'pending' : ''} ${watcherEnabled ? 'active' : ''}`}>
<input
type="checkbox"
name="watcher_enabled"
value="true"
defaultChecked={watcherEnabled}
disabled={isPending}
/>
<span className="toggle-label">Watcher</span>
<span className="toggle-hint" title="Detects file changes in real-time"></span>
</label>
</div>
<select
name="scan_mode"
defaultValue={scanMode}

View File

@@ -1234,3 +1234,27 @@ tr.job-highlighted td {
font-size: 0.75rem;
padding: 2px 4px;
}
/* Watcher toggle styles */
.watcher-toggle {
background: hsl(45 93% 90% / 0.3);
border: 1px solid hsl(45 93% 47% / 0.3);
border-radius: 4px;
padding: 2px 6px;
}
.watcher-toggle.active {
background: hsl(45 93% 90% / 0.6);
border-color: hsl(45 93% 47% / 0.6);
}
.toggle-hint {
margin-left: 4px;
cursor: help;
}
.monitor-options {
display: flex;
gap: 8px;
flex-wrap: wrap;
}