import {SimpleLayout} from '@/components/layouts/SimpleLayout' import {Card} from '@/components/ui/Card' import {CardGroup} from '@/components/ui/CardGroup' import {getDashboardData} from '@/lib/dashboard' import {numberFormat} from '@/lib/numberFormat' export const metadata = { title: 'Dashboard - Ryan Freeman', description: 'This is my digital life in numbers, I use this dashboard to keep track of various metrics across platforms like Spotify, GitHub, Twitter and for monitoring the performance of my Raspberry Pi using Grafana and Prometheus.' } const config = { refreshInterval: 30000 } export const dynamic = 'force-dynamic' export default async function Dashboard() { const metrics = await getDashboardData() // const tempData = (useSWR('api/grafana/temp', fetcher, config)).data as { temp: string } // const sysLoadData = (useSWR('api/grafana/sysload', fetcher, config)).data as { sysLoad: string } // const ramData = (useSWR('api/grafana/ram', fetcher, config)).data as { ramUsage: string } // const rootFsData = (useSWR('api/grafana/rootfs', fetcher, config)).data as { rootFsUsage: string } // const uptimeData = (useSWR('api/grafana/uptime', fetcher, config)).data as { days: number } return ( {metrics.map(({groupName, groupItems}) => ( {groupItems.map((item) => (

{item.title}

{typeof item.value === "number" ? numberFormat(item.value) : item.value}
))}
))} {/**/} {/* */} {/*

*/} {/* Temperature*/} {/*

*/} {/* */} {/* {tempData ? `${tempData.temp}℃` : "—"}*/} {/* */} {/*
*/} {/* */} {/*

*/} {/* Sys load (5m avg)*/} {/*

*/} {/* */} {/* {sysLoadData ? `${sysLoadData.sysLoad}%` : "—"}*/} {/* */} {/*
*/} {/* */} {/*

*/} {/* RAM usage*/} {/*

*/} {/* */} {/* {ramData ? `${ramData.ramUsage}%` : "—"}*/} {/* */} {/*
*/} {/* */} {/*

*/} {/* Root FS usage*/} {/*

*/} {/* */} {/* {rootFsData ? `${rootFsData.rootFsUsage}%` : "—"}*/} {/* */} {/*
*/} {/* */} {/*

*/} {/* Uptime days*/} {/*

*/} {/* */} {/* {uptimeData ? `${numberFormat(uptimeData.days)}` : "—"}*/} {/* */} {/*
*/} {/*
*/}
) }