feat: config history (diff/rollback) + friendly backup scheduling (v0.12.3-beta)

Configuration History:
- Per-device snapshots from the full RouterOS /export (.rsc) — config-only, so
  counters/operational state no longer cause phantom changes; deduped by content hash
- New Config History tab: snapshot timeline, readable line diff, on-demand Capture
  (with honest 'no changes' feedback), one-click rollback via the linked .rsc backup
- Snapshot and its backup are one artifact: badged 'Config Snapshot' on the Backups
  page, FK ON DELETE CASCADE keeps them in lockstep; delete is gated by a warning modal
- New config_drift alert event (off by default); periodic snapshot poll with
  configurable cadence/retention (config_snapshot_interval_min/_retention)
- New endpoints under /api/config-history (list/get/diff/capture/rollback/delete)

Scheduled Backups:
- Replaced the raw cron textbox in Settings with Frequency (Daily/Weekly/Monthly)
  + time + day pickers; cron is generated/parsed behind the scenes
- Fixed cronMatchesNow to evaluate day-of-month/month/day-of-week (it previously
  only checked minute/hour, so weekly/monthly schedules ran every day)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2GT-Rich
2026-06-06 16:01:58 -07:00
co-authored by Claude Opus 4.8
parent 4ff5ed805c
commit 367034c2d6
20 changed files with 1075 additions and 81 deletions
+20
View File
@@ -17,6 +17,10 @@ import type {
IpAddress,
PortVlanConfig,
PortMonitorData,
ConfigSnapshotMeta,
ConfigSnapshotFull,
ConfigDiffResponse,
ConfigCaptureResult,
} from '../types';
const api = axios.create({
@@ -376,6 +380,22 @@ export const backupsApi = {
delete: (id: number) => api.delete(`/backups/${id}`),
};
// ─── Config History ────────────────────────────────────────────────────────────
export const configHistoryApi = {
list: (deviceId: number) =>
api.get<ConfigSnapshotMeta[]>(`/config-history/${deviceId}`),
get: (deviceId: number, id: number) =>
api.get<ConfigSnapshotFull>(`/config-history/${deviceId}/${id}`),
diff: (deviceId: number, fromId: number, toId: number) =>
api.get<ConfigDiffResponse>(`/config-history/${deviceId}/${fromId}/diff/${toId}`),
capture: (deviceId: number) =>
api.post<ConfigCaptureResult>(`/config-history/${deviceId}/capture`),
rollback: (deviceId: number, id: number) =>
api.post<{ message: string }>(`/config-history/${deviceId}/${id}/rollback`),
delete: (deviceId: number, id: number) =>
api.delete(`/config-history/${deviceId}/${id}`),
};
// ─── Metrics ─────────────────────────────────────────────────────────────────
export const metricsApi = {
summary: () => api.get<MetricsSummary>('/metrics/summary'),