50e8519220
- Add 6 renderer components: StatCard, Gauge, List, Progress, AlertBanner, Chart - Add IntegrationWidget container with auto-refresh, loading, error states - Add IntegrationAlertOverlay for layout-level critical alerts - Add IntegrationConfigFields for dynamic form generation from Zod schemas - Register integration type in WidgetRenderer - Extend WidgetCreationForm with integration app/endpoint pickers - Extend AppForm with integration config section and test connection button - Add /api/integrations/alerts endpoint
46 lines
2.3 KiB
Markdown
46 lines
2.3 KiB
Markdown
# Phase 4: Pi-hole Integration
|
|
|
|
**Status:** ⬜ Not Started
|
|
**Parent plan:** [PLAN.md](./PLAN.md)
|
|
**Domain:** backend
|
|
|
|
## Objective
|
|
Implement Pi-hole integration using its admin API to display DNS blocking statistics, top blocked domains, and query logs.
|
|
|
|
## Tasks
|
|
|
|
- [ ] Task 1: Create `src/lib/server/integrations/pihole/schema.ts` — Zod schemas for auth config (`{ apiToken: string }`) and endpoint responses (summary stats, top items, query log).
|
|
- [ ] Task 2: Create `src/lib/server/integrations/pihole/client.ts` — HTTP client for Pi-hole API. Endpoints: `{app.url}/admin/api.php?summary`, `?topItems=N`, `?getAllQueries=N`, `?getQuerySources`. Include auth token as `&auth=<token>`.
|
|
- [ ] Task 3: Create `src/lib/server/integrations/pihole/transform.ts` — Transform API responses: summary → stat-card data (total queries, blocked, block %, clients), topItems → list data, queries → list with allow/block indicator.
|
|
- [ ] Task 4: Create `src/lib/server/integrations/pihole/index.ts` — Integration implementation. Endpoints: `stats-summary` (stat-card), `top-blocked` (list), `query-log` (list), `gravity-status` (stat-card). testConnection: fetch summary endpoint.
|
|
- [ ] Task 5: Register Pi-hole integration in registry.
|
|
|
|
## Files to Modify/Create
|
|
- `src/lib/server/integrations/pihole/schema.ts` — new
|
|
- `src/lib/server/integrations/pihole/client.ts` — new
|
|
- `src/lib/server/integrations/pihole/transform.ts` — new
|
|
- `src/lib/server/integrations/pihole/index.ts` — new
|
|
- `src/lib/server/integrations/registry.ts` — modify: register Pi-hole
|
|
|
|
## Acceptance Criteria
|
|
- Stats summary shows: total queries, blocked queries, block percentage, unique clients
|
|
- Top blocked domains list with counts
|
|
- Query log with domain, client, allow/block status
|
|
- Gravity status shows last update time and blocklist count
|
|
- Test connection validates API token
|
|
- Handles Pi-hole v5 and v6 API differences gracefully
|
|
|
|
## Notes
|
|
- Pi-hole API is simple GET-based with auth token as query parameter
|
|
- Some endpoints require authentication (topItems, queries), summary is often public
|
|
- Response format is flat JSON — easy to parse
|
|
- Consider Pi-hole v6 (new API format) — detect version and adapt
|
|
|
|
## Review Checklist
|
|
- [ ] All tasks completed
|
|
- [ ] API responses properly validated
|
|
- [ ] Code follows project conventions
|
|
|
|
## Handoff to Next Phase
|
|
<!-- Filled in after completion -->
|