import { FC, useState } from "react"; import { observer } from "mobx-react-lite"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner"; import type { CountersResponseT, APILabelCounterT } from "Models/APITypes"; import { AlertStore, FormatBackendURI, FormatAPIFilterQuery, } from "Stores/AlertStore"; import { useFetchGet } from "Hooks/useFetchGet"; import { TooltipWrapper } from "Components/TooltipWrapper"; import LabelWithPercent from "Components/Labels/LabelWithPercent"; import { ToggleIcon } from "Components/ToggleIcon"; const TableRows: FC<{ alertStore: AlertStore; nameStats: APILabelCounterT[]; }> = observer(({ alertStore, nameStats }) => ( <> {nameStats.map((nameStats) => ( {nameStats.hits} {nameStats.name} {nameStats.values.slice(0, 9).map((valueStats) => ( f.raw === valueStats.raw ).length > 0 } /> ))} {nameStats.values.length > 9 ? (
+{nameStats.values.length - 9} more
) : null} ))} )); const LabelsTable: FC<{ alertStore: AlertStore; counters: CountersResponseT; showAllLabels: boolean; toggleAllLabels: () => void; }> = observer(({ alertStore, counters, showAllLabels, toggleAllLabels }) => ( <> nameStats.hits >= counters.total )} > {counters.counters.filter( (nameStats) => nameStats.hits < counters.total ).length > 0 ? ( ) : null} {showAllLabels ? ( nameStats.hits < counters.total )} > ) : null}
)); const NothingToShow: FC = () => (

No labels to display

); const LoadingMessage: FC = () => (

); const ErrorMessage: FC<{ error: string }> = ({ error }) => (

{error}

); const OverviewModalContent: FC<{ alertStore: AlertStore; onHide: () => void; }> = observer(({ alertStore, onHide }) => { const [showAllLabels, setShowAllLabels] = useState(false); const { response, error } = useFetchGet( FormatBackendURI( `counters.json?${FormatAPIFilterQuery( alertStore.filters.values.map((f) => f.raw) )}` ), { deps: [alertStore.info.timestamp] } ); return ( <>
Overview
{error !== null ? ( ) : response === null ? ( ) : response.counters.length === 0 ? ( ) : ( setShowAllLabels(!showAllLabels)} /> )}
); }); export { OverviewModalContent };