diff --git a/backend/src/services/connections/index.ts b/backend/src/services/connections/index.ts index ba78a134..ac319f53 100644 --- a/backend/src/services/connections/index.ts +++ b/backend/src/services/connections/index.ts @@ -224,6 +224,16 @@ const delete_connection_for_uuid = async ({ uuid }) => { throw new Error500InternalServer(err) } } + +const get_num_connections = async (): Promise => { + try { + return await AppDataSource.getRepository(Connections).count() + } catch (err) { + console.error(`Error in Get Num Connections service: ${err}`) + throw new Error500InternalServer(err) + } +} + export { save_connection_aws, save_connection_gcp, @@ -231,4 +241,5 @@ export { get_connection_for_uuid, update_connection_for_uuid, delete_connection_for_uuid, + get_num_connections } diff --git a/backend/src/services/summary/index.ts b/backend/src/services/summary/index.ts index 94d3d5ab..ac92d077 100644 --- a/backend/src/services/summary/index.ts +++ b/backend/src/services/summary/index.ts @@ -1,4 +1,5 @@ import { Summary as SummaryResponse } from "@common/types" +import { get_num_connections } from "services/connections" import { getAlertTypeAggCached, getTopAlertsCached } from "./alerts" import { getTopEndpointsCached } from "./endpoints" import { getPIIDataTypeCountCached } from "./piiData" @@ -12,12 +13,14 @@ export class SummaryService { const piiDataTypeCount = await getPIIDataTypeCountCached() const usageStats = await getUsageStatsCached() const counts = await getCountsCached() + const numConnections = await get_num_connections() return { piiDataTypeCount: piiDataTypeCount as any, alertTypeCount: alertTypeCount as any, topAlerts, topEndpoints, usageStats, + numConnections, ...counts, } } diff --git a/common/src/types.ts b/common/src/types.ts index 7e6af378..c835be4d 100644 --- a/common/src/types.ts +++ b/common/src/types.ts @@ -238,6 +238,7 @@ export interface Summary { topAlerts: Alert[] topEndpoints: EndpointAndUsage[] usageStats: UsageStats + numConnections: number } export interface Usage { diff --git a/frontend/src/components/Home/HomeEmptyView.tsx b/frontend/src/components/Home/HomeEmptyView.tsx new file mode 100644 index 00000000..3f9fd959 --- /dev/null +++ b/frontend/src/components/Home/HomeEmptyView.tsx @@ -0,0 +1,31 @@ +import { Box, Heading, VStack, Button } from "@chakra-ui/react" +import { FiPlus } from "@react-icons/all-files/fi/FiPlus" +import { Logo } from "components/Logo" +import { DataHeading } from "components/utils/Card" + +export const HomeEmptyView: React.FC<{}> = () => { + return ( + + + + Welcome to Metlo + Add a connection to get started + + + + ) +} diff --git a/frontend/src/components/Home/index.tsx b/frontend/src/components/Home/index.tsx index 34e1cd9f..c0bec7eb 100644 --- a/frontend/src/components/Home/index.tsx +++ b/frontend/src/components/Home/index.tsx @@ -7,12 +7,16 @@ import AlertActions from "./AlertActions" import UsageChart from "./UsageChart" import LatestAlerts from "./LatestAlerts" import TopEndpoints from "./TopEndpoints" +import { HomeEmptyView } from "./HomeEmptyView" interface HomePageProps { summary: Summary } const HomePage: React.FC = React.memo(({ summary }) => { + if (summary.numConnections === 0) { + return + } return (