mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 06:07:11 +02:00
- Fix lodash security issue - Fix minors style issues detected by the upgrade Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
27 lines
1002 B
TypeScript
27 lines
1002 B
TypeScript
import React, { FC } from 'react';
|
|
import { RouteComponentProps } from '@reach/router';
|
|
import PathPrefixProps from '../../types/PathPrefixProps';
|
|
import { useFetch } from '../../hooks/useFetch';
|
|
import { withStatusIndicator } from '../../components/withStatusIndicator';
|
|
import AlertsContent, { RuleStatus, AlertsProps } from './AlertContents';
|
|
|
|
const AlertsWithStatusIndicator = withStatusIndicator(AlertsContent);
|
|
|
|
const Alerts: FC<RouteComponentProps & PathPrefixProps> = ({ pathPrefix = '' }) => {
|
|
const { response, error, isLoading } = useFetch<AlertsProps>(`${pathPrefix}/api/v1/rules?type=alert`);
|
|
|
|
const ruleStatsCount: RuleStatus<number> = {
|
|
inactive: 0,
|
|
pending: 0,
|
|
firing: 0,
|
|
};
|
|
|
|
if (response.data && response.data.groups) {
|
|
response.data.groups.forEach(el => el.rules.forEach(r => ruleStatsCount[r.state]++));
|
|
}
|
|
|
|
return <AlertsWithStatusIndicator {...response.data} statsCount={ruleStatsCount} error={error} isLoading={isLoading} />;
|
|
};
|
|
|
|
export default Alerts;
|