The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Added navigation to logs logic with timestamp padding.
TzeYiinge5bab001da91
diff --git a/studio/components/interfaces/Home/ProjectUsage.tsx b/studio/components/interfaces/Home/ProjectUsage.tsxindex e8a0eeee074..d4868370edf 100644--- a/studio/components/interfaces/Home/ProjectUsage.tsx+++ b/studio/components/interfaces/Home/ProjectUsage.tsx@@ -21,6 +21,9 @@ import { ProjectUsageMinimal } from 'components/to-be-cleaned/Usage'import { get } from 'lib/common/fetch'import { API_URL, METRICS, DATE_FORMAT } from 'lib/constants'import { useFlag } from 'hooks'+import { TooltipProps } from 'recharts'+import { TooltipType } from 'recharts/types/util/types'+import { TooltipContentProps, TooltipTriggerProps } from '@radix-ui/react-tooltip'const CHART_INTERVALS = [{ key: 'minutely', label: '60 minutes', startValue: 1, startUnit: 'hour', format: 'MMM D, h:ma' },@@ -53,6 +56,20 @@ const ProjectUsage: FC<Props> = ({ project }) => {const endDate = dayjs().format(DATE_FORMAT)const charts = data?.dataconst datetimeFormat = selectedInterval.format || 'MMM D, ha'+ const handleBarClick = (v: any) => {+ if (!v || !v.activePayload?.[0]?.payload) return+ // returns rechart internal tooltip data type+ const payload = v.activePayload[0].payload+ const timestamp = payload.timestamp+ const timestampDigits = String(timestamp).length+ if (timestampDigits < 16) {+ // pad unix timestamp with additional 0 and then forward+ const paddedTimestamp = String(timestamp) + '0'.repeat(16 - timestampDigits)+ router.push(`/project/${ref}/settings/logs/rest?te=${paddedTimestamp}`)+ } else {+ router.push(`/project/${ref}/settings/logs/rest?te=${timestamp}`)+ }+ }return (<div className="mx-6 space-y-6"><div className="flex flex-row justify-between align-center w-full">@@ -99,6 +116,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {customDateFormat={datetimeFormat}data={charts}isLoading={!charts && !error ? true : false}+ onBarClick={handleBarClick}/><ProjectUsageMinimalprojectRef={project.ref}@@ -125,6 +143,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {customDateFormat={datetimeFormat}data={charts}isLoading={!charts && !error ? true : false}+ onBarClick={handleBarClick}/><ProjectUsageMinimalprojectRef={project.ref}@@ -151,6 +170,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {customDateFormat={datetimeFormat}data={charts}isLoading={!charts && !error ? true : false}+ onBarClick={handleBarClick}/><ProjectUsageMinimalprojectRef={project.ref}@@ -173,6 +193,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {customDateFormat={datetimeFormat}data={charts}isLoading={!charts && !error ? true : false}+ onBarClick={handleBarClick}/>{/* Empty space just so the cards are of the same height */}<div className="py-[26px]" />diff --git a/studio/components/to-be-cleaned/Charts/ChartHandler.tsx b/studio/components/to-be-cleaned/Charts/ChartHandler.tsxindex ccfcbfa6bf9..ed68ae46a48 100644--- a/studio/components/to-be-cleaned/Charts/ChartHandler.tsx+++ b/studio/components/to-be-cleaned/Charts/ChartHandler.tsx@@ -15,6 +15,7 @@ import { API_URL } from 'lib/constants'import { get } from 'lib/common/fetch'import { BarChart, AreaChart } from './ChartRenderer'import { ChartData } from './ChartHandler.types'+import { TooltipProps } from 'recharts'interface Props {label: string@@ -30,6 +31,7 @@ interface Props {hideChartType?: booleandata?: ChartDataisLoading?: boolean+ onBarClick?: (v: TooltipProps) => void}/**@@ -55,6 +57,7 @@ const ChartHandler: FC<Props> = ({hideChartType = false,data,isLoading,+ onBarClick,}) => {const router = useRouter()const { ref } = router.query@@ -169,6 +172,7 @@ const ChartHandler: FC<Props> = ({highlightedValue={highlightedValue}label={label}customDateFormat={customDateFormat}+ onBarClick={onBarClick}/>) : (<AreaChartdiff --git a/studio/components/to-be-cleaned/Charts/ChartRenderer.tsx b/studio/components/to-be-cleaned/Charts/ChartRenderer.tsxindex 9aa26b14c1a..447d3203914 100644--- a/studio/components/to-be-cleaned/Charts/ChartRenderer.tsx+++ b/studio/components/to-be-cleaned/Charts/ChartRenderer.tsx@@ -10,6 +10,7 @@ import {Tooltip,Cell,ResponsiveContainer,+ TooltipProps,} from 'recharts'import dayjs from 'dayjs'@@ -17,6 +18,7 @@ import customParseFormat from 'dayjs/plugin/customParseFormat'import timezone from 'dayjs/plugin/timezone'import utc from 'dayjs/plugin/utc'import { formatBytes } from 'lib/helpers'+import { TooltipType } from 'recharts/types/util/types'dayjs.extend(customParseFormat)dayjs.extend(timezone)@@ -141,6 +143,7 @@ export function BarChart({highlightedValue,customDateFormat,label,+ onBarClick,}: any) {const hasData = data ? dataCheck(data, attribute) : true@@ -185,9 +188,13 @@ export function BarChart({left: 0,bottom: 0,}}- className="overflow-visible"+ className="overflow-visible cursor-pointer"onMouseMove={onMouseMove}onMouseLeave={onMouseLeave}+ onClick={(tooltipData: any) => {+ // receives tooltip data https://github.com/recharts/recharts/blob/2a3405ff64a0c050d2cf94c36f0beef738d9e9c2/src/chart/generateCategoricalChart.tsx+ if (onBarClick) onBarClick(tooltipData)+ }}><XAxisdataKey="period_start"@@ -212,7 +219,9 @@ export function BarChart({{data?.map((entry: any, index: any) => (<Cellkey={`cell-${index}`}- className="transition-all duration-300"+ className={`transition-all duration-300 ${+ onBarClick ? 'cursor-pointer' : ''+ }`}fill={focusBar === index || mouseLeave ? '#3ecf8e' : 'rgba(62, 207, 142, 0.2)'}