From d791c187c860f7a2ab1885434907fb1363d8230d Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Sun, 12 May 2024 01:57:28 +0800 Subject: [PATCH] fix #16: show single monitor --- pages/index.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pages/index.tsx b/pages/index.tsx index e58236d..d873ffb 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -8,6 +8,7 @@ import OverallStatus from '@/components/OverallStatus' import Header from '@/components/Header' import MonitorList from '@/components/MonitorList' import { Center, Divider, Text } from '@mantine/core' +import MonitorDetail from '@/components/MonitorDetail' export const runtime = 'experimental-edge' const inter = Inter({ subsets: ['latin'] }) @@ -24,6 +25,24 @@ export default function Home({ state = JSON.parse(stateStr) as MonitorState } + // Specify monitorId in URL hash to view a specific monitor (can be used in iframe) + const monitorId = window.location.hash.substring(1); + if (monitorId) { + const monitor = monitors.find((monitor) => monitor.id === monitorId); + if (!monitor || !state) { + return ( + + Monitor with id {monitorId} not found! + + ) + } + return ( +
+ +
+ ) + } + return ( <>