feat: add chart annotations
Inline annotation markers on the dashboard chart with create/edit/delete UI. Color-coded categories: deploy, campaign, incident, other.
This commit is contained in:
@@ -16,6 +16,8 @@ import {
|
||||
getStats,
|
||||
getDailyStats,
|
||||
} from '@/lib/api/stats'
|
||||
import { listAnnotations } from '@/lib/api/annotations'
|
||||
import type { Annotation } from '@/lib/api/annotations'
|
||||
import { getSite } from '@/lib/api/sites'
|
||||
import type { Site } from '@/lib/api/sites'
|
||||
import type {
|
||||
@@ -48,6 +50,7 @@ const fetchers = {
|
||||
realtime: (siteId: string) => getRealtime(siteId),
|
||||
campaigns: (siteId: string, start: string, end: string, limit: number) =>
|
||||
getCampaigns(siteId, start, end, limit),
|
||||
annotations: (siteId: string, start: string, end: string) => listAnnotations(siteId, start, end),
|
||||
}
|
||||
|
||||
// * Standard SWR config for dashboard data
|
||||
@@ -247,5 +250,18 @@ export function useCampaigns(siteId: string, start: string, end: string, limit =
|
||||
)
|
||||
}
|
||||
|
||||
// * Hook for annotations data
|
||||
export function useAnnotations(siteId: string, startDate: string, endDate: string) {
|
||||
return useSWR<Annotation[]>(
|
||||
siteId && startDate && endDate ? ['annotations', siteId, startDate, endDate] : null,
|
||||
() => fetchers.annotations(siteId, startDate, endDate),
|
||||
{
|
||||
...dashboardSWRConfig,
|
||||
refreshInterval: 60 * 1000,
|
||||
dedupingInterval: 10 * 1000,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// * Re-export for convenience
|
||||
export { fetchers }
|
||||
|
||||
Reference in New Issue
Block a user