feat: incident history (#113)
* feat: add incident history link to links in header * fix: lower margin-bottom on header to have not that much wasted space * chore: move footer to own component * feat: add NoIncidents component * feat: add incidents history page * fix: add sorting by date * fix: fix sorting * feat: hash linking to individual incidents * fix: always truthy title * feat: remove hash * feat: some link improvements * feat: improve styles for alert, support mobile devices * fix: remove unused vars, larger margin --------- Co-authored-by: lyc8503 <[email protected]>
This commit is contained in:
1 parent
5769a52f0c
commit
41257c6ae9
7 files changed
+235
-42
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { Divider, Text } from '@mantine/core'
|
||||
|
||||
export default function Footer() {
|
||||
return (
|
||||
<>
|
||||
<Divider mt="lg" />
|
||||
<Text
|
||||
size="xs"
|
||||
mt="xs"
|
||||
mb="xs"
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
Open-source monitoring and status page powered by{' '}
|
||||
<a href="https://github.com/lyc8503/UptimeFlare" target="_blank">
|
||||
Uptimeflare
|
||||
</a>{' '}
|
||||
and{' '}
|
||||
<a href="https://www.cloudflare.com/" target="_blank">
|
||||
Cloudflare
|
||||
</a>
|
||||
, made with ❤ by{' '}
|
||||
<a href="https://github.com/lyc8503" target="_blank">
|
||||
lyc8503
|
||||
</a>
|
||||
.
|
||||
</Text>
|
||||
</>
|
||||
)
|
||||
}
|
||||
+11
-6
@@ -4,12 +4,12 @@ import { pageConfig } from '@/uptime.config'
|
||||
import { PageConfigLink } from '@/types/config'
|
||||
|
||||
export default function Header() {
|
||||
const linkToElement = (link: PageConfigLink) => {
|
||||
const linkToElement = (link: PageConfigLink, i: number) => {
|
||||
return (
|
||||
<a
|
||||
key={link.label}
|
||||
key={i}
|
||||
href={link.link}
|
||||
target="_blank"
|
||||
target={link.link.startsWith('/') ? undefined : '_blank'}
|
||||
className={classes.link}
|
||||
data-active={link.highlight}
|
||||
>
|
||||
@@ -18,11 +18,16 @@ export default function Header() {
|
||||
)
|
||||
}
|
||||
|
||||
const links = [{ label: 'Incident History', link: '/incidents' }, ...(pageConfig.links || [])]
|
||||
|
||||
return (
|
||||
<header className={classes.header}>
|
||||
<Container size="md" className={classes.inner}>
|
||||
<div>
|
||||
<a href="https://github.com/lyc8503/UptimeFlare" target="_blank">
|
||||
<a
|
||||
href={location.pathname == '/' ? 'https://github.com/lyc8503/UptimeFlare' : '/'}
|
||||
target={location.pathname == '/' ? '_blank' : undefined}
|
||||
>
|
||||
<Text size="xl" span>
|
||||
🕒
|
||||
</Text>
|
||||
@@ -39,11 +44,11 @@ export default function Header() {
|
||||
</div>
|
||||
|
||||
<Group gap={5} visibleFrom="sm">
|
||||
{pageConfig.links?.map(linkToElement)}
|
||||
{links?.map(linkToElement)}
|
||||
</Group>
|
||||
|
||||
<Group gap={5} hiddenFrom="sm">
|
||||
{pageConfig.links?.filter((link) => link.highlight).map(linkToElement)}
|
||||
{links?.filter((link) => (link.highlight || link.link.startsWith('/'))).map(linkToElement)}
|
||||
</Group>
|
||||
</Container>
|
||||
</header>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Alert, List, Text } from '@mantine/core'
|
||||
import { Alert, List, Text, useMantineTheme } from '@mantine/core'
|
||||
import { useMediaQuery } from '@mantine/hooks'
|
||||
import { IconAlertTriangle } from '@tabler/icons-react'
|
||||
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
|
||||
|
||||
@@ -9,24 +10,42 @@ export default function MaintenanceAlert({
|
||||
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] }
|
||||
style?: React.CSSProperties
|
||||
}) {
|
||||
const theme = useMantineTheme()
|
||||
const isDesktop = useMediaQuery(`(min-width: ${theme.breakpoints.sm})`)
|
||||
|
||||
return (
|
||||
<Alert
|
||||
icon={<IconAlertTriangle />}
|
||||
title={maintenance.title || 'Scheduled Maintenance'}
|
||||
title={
|
||||
<span
|
||||
style={{
|
||||
fontSize: '1rem',
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{maintenance.title || 'Scheduled Maintenance'}
|
||||
</span>
|
||||
}
|
||||
color={maintenance.color || 'yellow'}
|
||||
withCloseButton={false}
|
||||
style={{ position: 'relative', margin: '16px auto 0 auto', ...style }}
|
||||
>
|
||||
{/* Date range in top right */}
|
||||
{/* Date range in top right (desktop) or inline (mobile) */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 10,
|
||||
right: 10,
|
||||
fontSize: '0.85rem',
|
||||
textAlign: 'right',
|
||||
padding: '2px 8px',
|
||||
borderRadius: 6,
|
||||
...{
|
||||
top: 10,
|
||||
fontSize: '0.85rem',
|
||||
borderRadius: 6,
|
||||
},
|
||||
...(isDesktop
|
||||
? {
|
||||
position: 'absolute',
|
||||
right: 10,
|
||||
padding: '2px 8px',
|
||||
textAlign: 'right',
|
||||
}
|
||||
: {}),
|
||||
}}
|
||||
>
|
||||
<b>From:</b> {new Date(maintenance.start).toLocaleString()}
|
||||
@@ -35,7 +54,7 @@ export default function MaintenanceAlert({
|
||||
{maintenance.end ? new Date(maintenance.end).toLocaleString() : 'Until further notice'}
|
||||
</div>
|
||||
|
||||
<Text>{maintenance.body}</Text>
|
||||
<Text style={{ paddingTop: '3px' }}>{maintenance.body}</Text>
|
||||
{maintenance.monitors && maintenance.monitors.length > 0 && (
|
||||
<>
|
||||
<Text mt="xs">
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Alert, Text } from '@mantine/core'
|
||||
import { IconInfoCircle } from '@tabler/icons-react'
|
||||
|
||||
export default function NoIncidentsAlert({ style }: { style?: React.CSSProperties }) {
|
||||
return (
|
||||
<Alert
|
||||
icon={<IconInfoCircle />}
|
||||
title={
|
||||
<span
|
||||
style={{
|
||||
fontSize: '1rem',
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{'No incidents in this month'}
|
||||
</span>
|
||||
}
|
||||
color="gray"
|
||||
withCloseButton={false}
|
||||
style={{
|
||||
position: 'relative',
|
||||
margin: '16px auto 0 auto',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<Text>There are no incidents for this month.</Text>
|
||||
</Alert>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user