diff --git a/ui/react-app/src/client/alert.ts b/ui/react-app/src/client/alert.ts index 4c52b5bf..8bebbabc 100644 --- a/ui/react-app/src/client/alert.ts +++ b/ui/react-app/src/client/alert.ts @@ -11,7 +11,7 @@ export interface Receiver { export interface AlertStatus { state: 'active' | 'unprocessed' | 'suppressed'; inhibitedBy: string[]; - silenceby: string[]; + silenceBy: string[]; } export interface Alert { @@ -33,7 +33,7 @@ export interface AlertGroup { } export function useAlertGroups() { - return useQuery([], () => { + return useQuery([resource], () => { const url = buildURL({ resource: resource }); return fetchJson(url); }); diff --git a/ui/react-app/src/client/status.ts b/ui/react-app/src/client/status.ts index 69f868a9..4c08b6be 100644 --- a/ui/react-app/src/client/status.ts +++ b/ui/react-app/src/client/status.ts @@ -34,7 +34,7 @@ export interface AMStatus { } export function useAMStatus() { - return useQuery([], () => { + return useQuery([resource], () => { const url = buildURL({ resource: resource }); return fetchJson(url); }); diff --git a/ui/react-app/src/views/AlertView.tsx b/ui/react-app/src/views/AlertView.tsx index b382335f..8708554c 100644 --- a/ui/react-app/src/views/AlertView.tsx +++ b/ui/react-app/src/views/AlertView.tsx @@ -1,15 +1,107 @@ -import { useAlertGroups } from '../client/alert'; -import { Container, Typography } from '@mui/material'; +import React, { useState } from 'react'; +import ExpandedIcon from 'mdi-material-ui/ChevronDown'; +import BellOff from 'mdi-material-ui/BellOff'; +import { + Card, + CardActions, + CardContent, + Chip, + Collapse, + Container, + Divider, + IconButton, + IconButtonProps, + List, + ListItem, + styled, + Tooltip, + Typography, +} from '@mui/material'; +import Grid from '@mui/material/Unstable_Grid2'; +import { AlertGroup, useAlertGroups } from '../client/alert'; + +interface ExpandMoreProps extends IconButtonProps { + expand: boolean; +} + +const ExpandMore = styled((props: ExpandMoreProps) => { + const { ...other } = props; + return ; +})(({ theme, expand }) => ({ + transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)', + marginLeft: 'auto', + transition: theme.transitions.create('transform', { + duration: theme.transitions.duration.shortest, + }), +})); + +interface AlertCardProps { + group: AlertGroup; +} + +function renderLabels(labels: Record) { + const result = []; + for (const k in labels) { + result.push(); + } + return result; +} + +function AlertCard(props: AlertCardProps) { + const { group } = props; + const [expanded, setExpanded] = useState(false); + const handleExpandClick = () => { + setExpanded(!expanded); + }; + + return ( + + {renderLabels(group.labels)} + + + + + + + + + + + + + + {group.alerts.map((alert, index) => { + return ( + + + {renderLabels(alert.labels)} + + + ); + })} + + + + ); +} export default function AlertView() { const { data } = useAlertGroups(); if (data === undefined || data === null) { return null; } - return ( - + Alert + + {data.map((group, index) => { + return ( + + + + ); + })} + ); } diff --git a/ui/react-app/src/views/StatusView.tsx b/ui/react-app/src/views/StatusView.tsx index dc047d93..ce1f594e 100644 --- a/ui/react-app/src/views/StatusView.tsx +++ b/ui/react-app/src/views/StatusView.tsx @@ -44,9 +44,10 @@ function CustomTableCell(props: tableCellProperties) { export default function StatusView() { const { data } = useAMStatus(); - if (data === undefined || data === null || (Array.isArray(data) && data.length === 0)) { + if (data === undefined || data === null) { return null; } + console.log(data); return (