From 7bf1f187e866609f4cb46b5b2a257cd7cee999a1 Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj Date: Thu, 23 Nov 2023 19:31:45 +0530 Subject: [PATCH] New Graph UI (#684) A proposal from my end for a more polished UI for our Sync History. Screenshot 2023-11-19 at 10 07 37 AM - Hovering on the bars reveals a proper tooltip box with rows synced and at what time Screenshot 2023-11-19 at 10 31 57 AM --- .../[mirrorId]/aggregatedCountsByInterval.ts | 6 ++- ui/app/mirrors/edit/[mirrorId]/cdcGraph.tsx | 47 ++++--------------- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/ui/app/mirrors/edit/[mirrorId]/aggregatedCountsByInterval.ts b/ui/app/mirrors/edit/[mirrorId]/aggregatedCountsByInterval.ts index b2fdf7b1fb..b9b3216625 100644 --- a/ui/app/mirrors/edit/[mirrorId]/aggregatedCountsByInterval.ts +++ b/ui/app/mirrors/edit/[mirrorId]/aggregatedCountsByInterval.ts @@ -36,7 +36,7 @@ function aggregateCountsByInterval( // Iterate through the timestamps and populate the aggregatedCounts object for (let { timestamp, count } of timestamps) { - const date = roundUpToNearestNMinutes(timestamp, 15); + const date = roundUpToNearestNMinutes(timestamp, 1); const formattedTimestamp = moment(date).format(timeUnit); if (!aggregatedCounts[formattedTimestamp]) { @@ -64,6 +64,10 @@ function aggregateCountsByInterval( currentTimestamp.setHours(currentTimestamp.getHours() - 1); } else if (interval === '15min') { currentTimestamp.setMinutes(currentTimestamp.getMinutes() - 15); + } else if (interval === '1min') { + currentTimestamp.setMinutes(currentTimestamp.getMinutes() - 1); + } else if (interval === '5min') { + currentTimestamp.setMinutes(currentTimestamp.getMinutes() - 5); } else if (interval === 'month') { currentTimestamp.setMonth(currentTimestamp.getMonth() - 1); } else if (interval === 'day') { diff --git a/ui/app/mirrors/edit/[mirrorId]/cdcGraph.tsx b/ui/app/mirrors/edit/[mirrorId]/cdcGraph.tsx index cdc6d91a37..951baeaa3c 100644 --- a/ui/app/mirrors/edit/[mirrorId]/cdcGraph.tsx +++ b/ui/app/mirrors/edit/[mirrorId]/cdcGraph.tsx @@ -1,5 +1,6 @@ 'use client'; import { Label } from '@/lib/Label'; +import { BarChart } from '@tremor/react'; import moment from 'moment'; import { useEffect, useState } from 'react'; import ReactSelect from 'react-select'; @@ -51,15 +52,15 @@ function CdcGraph({ syncs }: { syncs: SyncStatusRow[] }) {
-
- {counts.map((count, i) => ( - - ))} -
+ ({ + name: formatGraphLabel(new Date(count[0]), aggregateType), + 'Rows synced at a point in time': count[1], + }))} + index='name' + categories={['Rows synced at a point in time']} + /> ); } @@ -80,32 +81,4 @@ function formatGraphLabel(date: Date, aggregateType: String): string { } } -type GraphBarProps = { - count: number; - label: string; -}; - -function GraphBar({ label, count }: GraphBarProps) { - let color = - count && count > 0 ? 'bg-positive-fill-normal' : 'bg-base-border-subtle'; - let classNames = `relative w-10 h-24 rounded ${color}`; - return ( -
-
-
-
{label}
-
{numberWithCommas(count)}
-
-
-
- ); -} - -function numberWithCommas(x: number): string { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); -} - export default CdcGraph;