import Head from 'flareact/head' import MonitorHistogram from '../src/components/monitorHistogram' import { getLastUpdate, getMonitors, getMonitorsHistory, } from '../src/functions/helpers' import config from '../config.yaml' import MonitorStatusLabel from '../src/components/monitorStatusLabel' export async function getEdgeProps() { // get KV data const kvMonitors = await getMonitors() const kvMonitorsFailedDays = await getMonitorsHistory() const kvLastUpdate = await getLastUpdate() // prepare data maps for components let monitorsOperational = true let kvMonitorsMap = {} kvMonitors.forEach(x => { kvMonitorsMap[x.metadata.id] = x.metadata if (x.metadata.operational === false) monitorsOperational = false }) // transform KV list to array of failed days const kvMonitorsFailedDaysArray = kvMonitorsFailedDays.map(x => { return x.name }) return { props: { config, kvMonitorsMap, kvMonitorsFailedDaysArray, monitorsOperational, kvLastUpdate, }, // Revalidate these props once every x seconds revalidate: 5, } } export default function Index({ config, kvMonitorsMap, kvMonitorsFailedDaysArray, monitorsOperational, kvLastUpdate, }) { return (