Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: update storage report layout and formatting

TzeYiingb0b23d270432
diff --git a/studio/components/interfaces/Reports/renderers/StorageRenderers.tsx b/studio/components/interfaces/Reports/renderers/StorageRenderers.tsx
index eba43e7e5d2..c8e3b8db4ff 100644
--- a/studio/components/interfaces/Reports/renderers/StorageRenderers.tsx
+++ b/studio/components/interfaces/Reports/renderers/StorageRenderers.tsx
@@ -1,5 +1,7 @@
import Table from 'components/to-be-cleaned/Table'
+import StackedBarChart from 'components/ui/Charts/StackedBarChart'
import { ReportWidgetProps } from '../ReportWidget'
+import Statistic from '../Statistic'
export const renderLargestObjectsPerBucket = (
props: ReportWidgetProps<{
@@ -104,34 +106,23 @@ export const renderStaleFiles = (
one_month: number
three_month: number
six_month: number
- one_year: number
+ twelve_month: number
}>
) => {
return (
- <Table
- containerClassName="max-h-72 w-full overflow-y-auto"
- className="relative rounded border border-scale-600"
- head={
- <>
- <Table.th className="sticky top-0 z-10">1 Month</Table.th>
- <Table.th className="sticky top-0 z-10">3 Months</Table.th>
- <Table.th className="sticky top-0 z-10">6 Months</Table.th>
- <Table.th className="sticky top-0 z-10">12 Months</Table.th>
- </>
- }
- body={
- <>
- {props.data.map((row, index) => (
- <Table.tr key={index}>
- <Table.td>{row.one_month}</Table.td>
- <Table.td>{row.three_month}</Table.td>
- <Table.td>{row.six_month}</Table.td>
- <Table.td>{row.one_year}</Table.td>
- </Table.tr>
- ))}
- </>
- }
- />
+ <div className="flex flex-row w-full px-4 justify-between gap-4">
+ {[
+ { key: 'one_month', label: '1 Month' },
+ { key: 'three_month', label: '3 Month' },
+ { key: 'six_month', label: '6 Month' },
+ { key: 'twelve_month', label: '12 Month' },
+ ].map(({ key, label }) => (
+ <div className="flex flex-col items-center">
+ <Statistic value={props.data[0][key as keyof typeof props.data[0]]} />
+ <span className="text-lg text-scale-1000">{label}</span>
+ </div>
+ ))}
+ </div>
)
}
@@ -171,6 +162,30 @@ export const renderCacheHitRate = (
miss_count: number
}>
) => {
+ const stackedData = props.data.flatMap((datum) => [
+ {
+ timestamp: datum.timestamp,
+ count: datum.hit_count,
+ type: 'hit',
+ },
+ {
+ timestamp: datum.timestamp,
+ count: datum.miss_count,
+ type: 'miss',
+ },
+ ])
+
+ return (
+ <StackedBarChart
+ hideHeader
+ variant="percentages"
+ data={stackedData}
+ xAxisKey="timestamp"
+ yAxisKey="count"
+ stackKey="type"
+ />
+ )
+
return (
<Table
containerClassName="max-h-72 w-full overflow-y-auto"
diff --git a/studio/pages/project/[ref]/reports/storage.tsx b/studio/pages/project/[ref]/reports/storage.tsx
index 87e12b03ae1..2fa36cf6760 100644
--- a/studio/pages/project/[ref]/reports/storage.tsx
+++ b/studio/pages/project/[ref]/reports/storage.tsx
@@ -42,7 +42,7 @@ export const StorageReport: NextPageWithLayout = () => {
<ReportWidget
isLoading={isLoading}
params={cacheHitRate[0].params}
- className="col-span-3 col-start-1"
+ className="col-span-6 col-start-1"
title="Cache Hit Rate"
description="Edge Network Cache Hit Rate"
data={cacheHitRate[0]?.logData || []}
@@ -51,37 +51,28 @@ export const StorageReport: NextPageWithLayout = () => {
<ReportWidget
isLoading={isLoading}
- params={largestObjectsPerBucket[0].params}
- className="col-span-3 col-start-1"
- title="Largest Objects"
- description="Large objects in each bucket"
- data={largestObjectsPerBucket[0]?.data || []}
- renderer={renderLargestObjectsPerBucket}
+ params={topSizes[0].params}
+ className="col-span-2 col-start-1"
+ title="Top Object Sizes"
+ description="Most frequently used object sizes"
+ data={topSizes[0]?.logData || []}
+ renderer={renderTopSizes}
/>
<ReportWidget
isLoading={isLoading}
params={topDownloaded[0].params}
- className="col-span-3 col-start-1"
+ className="col-span-4 col-start-3"
title="Top Downloaded Objects"
description="Top download objectss"
data={topDownloaded[0]?.data || []}
renderer={renderTopDownloaded}
/>
- <ReportWidget
- isLoading={isLoading}
- params={mostFiles[0].params}
- className="col-span-3 col-start-1"
- title="Users with Most Files"
- description="Users with the most associated storage files"
- data={mostFiles[0]?.data || []}
- renderer={renderMostFiles}
- />
-
+ <Divider light />
<ReportWidget
isLoading={isLoading}
params={staleFiles[0].params}
- className="col-span-3 col-start-1"
+ className="col-span-6 col-start-1"
title="Stale Objects"
description="Objects by months from last access"
data={staleFiles[0]?.data || []}
@@ -90,12 +81,22 @@ export const StorageReport: NextPageWithLayout = () => {
<ReportWidget
isLoading={isLoading}
- params={topSizes[0].params}
+ params={mostFiles[0].params}
className="col-span-3 col-start-1"
- title="Top Object Sizes"
- description="Most frequently used object sizes"
- data={topSizes[0]?.logData || []}
- renderer={renderTopSizes}
+ title="Users with Most Files"
+ description="Users with the most associated storage files"
+ data={mostFiles[0]?.data || []}
+ renderer={renderMostFiles}
+ />
+
+ <ReportWidget
+ isLoading={isLoading}
+ params={largestObjectsPerBucket[0].params}
+ className="col-span-3 col-start-4"
+ title="Largest Objects"
+ description="Large objects in each bucket"
+ data={largestObjectsPerBucket[0]?.data || []}
+ renderer={renderLargestObjectsPerBucket}
/>
</div>
</Layout>