wip: more layout & chartjs
This commit is contained in:
1 parent
f9212c88a6
commit
4fba030932
7 files changed
+129
-26
No files matched your search
@@ -34,11 +34,9 @@ export default function Header() {
|
||||
<header className={classes.header}>
|
||||
<Container size="md" className={classes.inner}>
|
||||
<MantineLogo size={28} />
|
||||
<Group gap={5} visibleFrom="xs">
|
||||
<Group gap={5}>
|
||||
{items}
|
||||
</Group>
|
||||
|
||||
<Burger opened={opened} onClick={toggle} hiddenFrom="xs" size="sm" />
|
||||
</Container>
|
||||
</header>
|
||||
);
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,67 @@
|
||||
import { MonitorState, MonitorTarget } from "@/uptime.types";
|
||||
import { Card, Center, Divider, Text } from "@mantine/core";
|
||||
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend } from 'chart.js';
|
||||
import { Line } from "react-chartjs-2";
|
||||
|
||||
ChartJS.register(
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
PointElement,
|
||||
LineElement,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend
|
||||
);
|
||||
|
||||
|
||||
export const options = {
|
||||
responsive: true,
|
||||
interaction: {
|
||||
mode: 'index' as const,
|
||||
intersect: false,
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'top' as const,
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Response times',
|
||||
align: 'start' as const
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
||||
|
||||
export const data = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
data: labels.map(() => Math.round(Math.random() * 1000)),
|
||||
borderColor: 'rgb(255, 99, 132)',
|
||||
backgroundColor: 'rgba(255, 99, 132, 0.5)',
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
export default function MonitorList({ config, state }: { config: any, state: MonitorState }) {
|
||||
|
||||
return (
|
||||
<Center>
|
||||
<Card shadow="sm" padding="lg" radius="md" ml="xl" mr="xl" mt="xl" withBorder style={{ width: '800px' }}>
|
||||
{config.monitors.map((monitor: MonitorTarget) => (
|
||||
<div key={monitor.id}>
|
||||
<Card.Section>
|
||||
<Text>{monitor.name}</Text>
|
||||
<Line options={options} data={data} />
|
||||
</Card.Section>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</Center>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
import { Center, Space, Title } from '@mantine/core'
|
||||
import { Center, Title } from '@mantine/core'
|
||||
import { IconCircleCheck, IconAlertCircle } from '@tabler/icons-react'
|
||||
|
||||
export default function OverallStatus({ state }: { state: { overallUp: number, overallDown: number, lastUpdate: number }}) {
|
||||
|
||||
let statusString = ''
|
||||
let icon = <IconAlertCircle style={{ width: 64, height: 64 }} />
|
||||
let icon = <IconAlertCircle style={{ width: 64, height: 64, color: '#b91c1c' }} />
|
||||
if (state.overallUp === 0 && state.overallDown === 0) {
|
||||
statusString = 'No data yet'
|
||||
} else if (state.overallUp === 0) {
|
||||
statusString = 'All down'
|
||||
statusString = 'All systems not operational'
|
||||
} else if (state.overallDown === 0) {
|
||||
statusString = 'All up'
|
||||
icon = <IconCircleCheck style={{ width: 64, height: 64 }} />
|
||||
statusString = 'All systems operational'
|
||||
icon = <IconCircleCheck style={{ width: 64, height: 64, color: '#059669' }} />
|
||||
} else {
|
||||
statusString = `${state.overallUp} up, ${state.overallDown} down`
|
||||
statusString = `Some systems not operational (${state.overallDown} out of ${state.overallUp + state.overallDown})`
|
||||
}
|
||||
|
||||
return (<>
|
||||
<Center>
|
||||
{icon}
|
||||
</Center>
|
||||
<Space h="md"/>
|
||||
<Center>
|
||||
<Title order={1}>{statusString}</Title>
|
||||
</Center>
|
||||
<Center>
|
||||
<Title order={5}>Last updated on: {new Date(state.lastUpdate * 1000).toLocaleString()}</Title>
|
||||
</Center>
|
||||
<Title mt="sm" style={{ textAlign: 'center' }} order={1}>{statusString}</Title>
|
||||
<Title mt="sm" style={{ textAlign: 'center', color: '#70778c' }} order={5}>Last updated on: {new Date(state.lastUpdate * 1000).toLocaleString()} ({Math.round(Date.now() / 1000) - state.lastUpdate} sec ago)</Title>
|
||||
</>)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user