Skip to content

Commit

Permalink
Added installed providers
Browse files Browse the repository at this point in the history
  • Loading branch information
vikashsprem committed Sep 26, 2024
1 parent 7e6103e commit 177d2d6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions keep-ui/app/alerts/quality/alert-quality-table.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
"use client"; // Add this line at the top to make this a Client Component

import React, { useState, useEffect } from 'react';
import { useFetchProviders } from 'app/providers/page.client';
import { GenericTable } from '@/components/table/GenericTable';

interface ProviderAlertQuality {
providerName: string;
alertsReceived: number;
alertsCorrelatedToIncidentsPercentage: number; // Percentage
alertsWithFieldFilledPercentage: number; // Percentage
alertsCorrelatedToIncidentsPercentage: number;
alertsWithFieldFilledPercentage: number;
}

const AlertQualityTable = () => {
const {installedProviders} = useFetchProviders();
const [data, setData] = useState<ProviderAlertQuality[]>([]);
const [rowCount, setRowCount] = useState<number>(0);
const [offset, setOffset] = useState<number>(0);
Expand Down Expand Up @@ -40,14 +42,11 @@ const AlertQualityTable = () => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch('/api/alert-quality');
const result = await response.json();

const transformedData = result.providers.map((provider: any) => ({
providerName: provider.name,
alertsReceived: provider.alertsReceived,
alertsCorrelatedToIncidentsPercentage: provider.alertsCorrelatedToIncidentsPercentage * 100,
alertsWithFieldFilledPercentage: provider.alertsWithFieldFilledPercentage * 100,
const transformedData = installedProviders.map((provider: any) => ({
providerName: `${provider.details.name} (${provider.display_name})` || 'Unknown',
alertsReceived: provider.alertsReceived || 0,
alertsCorrelatedToIncidentsPercentage: provider.alertsCorrelatedToIncidentsPercentage * 100 || 0,
alertsWithFieldFilledPercentage: provider.alertsWithFieldFilledPercentage * 100 || 0,
}));

setData(transformedData);
Expand Down

0 comments on commit 177d2d6

Please sign in to comment.