Skip to content

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

add basic components for StackedAreaChart, add elements to ProjectUsage

TzeYiing14092b1dcf3b
diff --git a/studio/components/interfaces/Home/ProjectUsage.tsx b/studio/components/interfaces/Home/ProjectUsage.tsx
index d2b9a2a1ae6..458bb1a882b 100644
--- a/studio/components/interfaces/Home/ProjectUsage.tsx
+++ b/studio/components/interfaces/Home/ProjectUsage.tsx
@@ -21,6 +21,8 @@ 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 StackedAreaChart from 'components/ui/charts/StackedAreaChart'
+import Table from 'components/to-be-cleaned/Table'
const CHART_INTERVALS = [
{ key: 'minutely', label: '60 minutes', startValue: 1, startUnit: 'hour', format: 'MMM D, h:ma' },
@@ -201,6 +203,45 @@ const ProjectUsage: FC<Props> = ({ project }) => {
/> */}
</Panel.Content>
</Panel>
+ <div>
+ <Panel>
+ <Panel.Content className="space-y-4">
+ <PanelHeader title="API Status Codes" />
+ <StackedAreaChart
+ label="Status Codes"
+ customDateFormat={datetimeFormat}
+ data={[]}
+ isLoading={!charts && !error ? true : false}
+ />
+ </Panel.Content>
+ </Panel>
+
+ <Panel>
+ <Panel.Content className="space-y-4">
+ <PanelHeader title="Top Routes" />
+ <Table
+ head={
+ <>
+ <Table.th>Path</Table.th>
+ <Table.th>Count</Table.th>
+ <Table.th>Avg. Latency</Table.th>
+ </>
+ }
+ body={
+ <>
+ {[{ path: '123', count: 123, average_latency: 123 }].map((row) => (
+ <Table.tr>
+ <Table.td>{row.path}</Table.td>
+ <Table.td>{row.count}</Table.td>
+ <Table.td>{row.average_latency}</Table.td>
+ </Table.tr>
+ ))}
+ </>
+ }
+ />
+ </Panel.Content>
+ </Panel>
+ </div>
</div>
)}
</div>
diff --git a/studio/components/ui/charts/StackedAreaChart.tsx b/studio/components/ui/charts/StackedAreaChart.tsx
new file mode 100644
index 00000000000..f32667b2e32
--- /dev/null
+++ b/studio/components/ui/charts/StackedAreaChart.tsx
@@ -0,0 +1,39 @@
+import { AreaChart, XAxis, YAxis, Area, Tooltip, ResponsiveContainer } from 'recharts'
+interface Props {
+ label: string
+ customDateFormat: string
+ data: any[]
+ isLoading: boolean
+}
+
+const StackedAreaChart: React.FC<Props> = () => (
+ <ResponsiveContainer>
+ <AreaChart
+ width={730}
+ height={250}
+ data={[
+ {
+ day: '05-01',
+ temperature: [-1, 10],
+ },
+ {
+ day: '05-02',
+ temperature: [2, 15],
+ },
+ ]}
+ margin={{
+ top: 20,
+ right: 20,
+ bottom: 20,
+ left: 20,
+ }}
+ >
+ <XAxis dataKey="day" />
+ <YAxis />
+ <Area dataKey="temperature" stroke="#8884d8" fill="#8884d8" />
+ <Tooltip />
+ </AreaChart>
+ </ResponsiveContainer>
+)
+
+export default StackedAreaChart