Updates and fixes.

This commit is contained in:
2025-12-19 11:26:26 +01:00
parent 6c0dc5f3d8
commit 4ce795228d
28 changed files with 459 additions and 232 deletions

View File

@@ -145,16 +145,41 @@ export function useDashboardConfig() {
}
}
// Only save to localStorage automatically (no backend saves)
// Auto-save to localStorage and debounced backend save
useEffect(() => {
if (!isInitialLoadRef.current) {
// Save to localStorage immediately
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(config))
} catch (error) {
console.error('Failed to save to localStorage:', error)
}
// Auto-save to backend with debounce (2 seconds after last change)
const timeoutId = setTimeout(async () => {
try {
if (layoutId) {
await dashboardLayoutApi.update(layoutId, {
config: config,
})
console.log('Dashboard auto-saved to backend')
} else {
const response = await dashboardLayoutApi.create({
name: 'default',
config: config,
is_default: true,
})
setLayoutId(response.data.id)
console.log('Dashboard created and auto-saved to backend')
}
} catch (error) {
console.error('Failed to auto-save to backend:', error)
}
}, 2000)
return () => clearTimeout(timeoutId)
}
}, [config])
}, [config, layoutId])
const addWidget = (widget: WidgetConfig) => {

View File

@@ -62,8 +62,8 @@ export function useTelemetrySeries({
return response.data as Telemetry[]
},
enabled,
refetchInterval: enabled ? 60000 : false, // Refresh every 60 seconds (reduced frequency)
staleTime: 30000, // Consider data fresh for 30 seconds
refetchInterval: enabled ? 5000 : false, // Refresh every 5 seconds
staleTime: 3000, // Consider data fresh for 3 seconds
})
return {