Adds an events table + logEvent helper for a genuine activity log, and a /api/integrations/resources aggregate endpoint backed by a new optional listResources adapter method (implemented for Docker via its containers API). StatusCards, MiddleRow, BottomRow, and Infrastructure now render real integration/resource/event data instead of hardcoded numbers, with empty states where no data source exists yet (AWS cost, historical trends). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BbJV5nm8KPVH1oNJYKpnoF
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import type { IntegrationAdapter, Resource } from './types.js'
|
|
|
|
export const docker: IntegrationAdapter = {
|
|
async testConnection(config) {
|
|
const baseUrl = config.baseUrl?.replace(/\/$/, '')
|
|
if (!baseUrl) return { ok: false, message: 'Missing baseUrl' }
|
|
try {
|
|
const res = await fetch(`${baseUrl}/version`)
|
|
if (!res.ok) return { ok: false, message: `HTTP ${res.status}` }
|
|
return { ok: true, message: 'Connected' }
|
|
} catch (err) {
|
|
return { ok: false, message: err instanceof Error ? err.message : 'Connection failed' }
|
|
}
|
|
},
|
|
|
|
async listResources(config): Promise<Resource[]> {
|
|
const baseUrl = config.baseUrl?.replace(/\/$/, '')
|
|
if (!baseUrl) return []
|
|
const res = await fetch(`${baseUrl}/containers/json?all=true`)
|
|
if (!res.ok) return []
|
|
const containers = (await res.json()) as { Names: string[]; State: string }[]
|
|
return containers.map((c) => ({
|
|
name: c.Names[0]?.replace(/^\//, '') ?? 'unknown',
|
|
status: c.State === 'running' ? 'healthy' : c.State === 'restarting' ? 'warning' : 'critical',
|
|
detail: c.State,
|
|
}))
|
|
},
|
|
}
|