diff --git a/apps/studio-prototype/src/app/[org]/projects/page.tsx b/apps/studio-prototype/src/app/[org]/projects/page.tsx index ce47ccef854..afe9727664f 100644 --- a/apps/studio-prototype/src/app/[org]/projects/page.tsx +++ b/apps/studio-prototype/src/app/[org]/projects/page.tsx @@ -29,6 +29,7 @@ export default function ProjectsPage() {
+
{/* */} {/* */} diff --git a/apps/studio-prototype/src/app/[org]/top-header.tsx b/apps/studio-prototype/src/app/[org]/top-header.tsx index 057da3ea8a5..7c791774f41 100644 --- a/apps/studio-prototype/src/app/[org]/top-header.tsx +++ b/apps/studio-prototype/src/app/[org]/top-header.tsx @@ -14,11 +14,13 @@ export default function TopHeader() { selectedOrg, selectedProject, selectedEnv: { type }, + settingsAllPreviews, } = config const isPreview = - type !== 'prod' && - !resolveHideBranchesDropdown(pathName, selectedOrg?.key, selectedProject?.key) + (settingsAllPreviews && pathName.includes(`${selectedOrg?.key}/settings`)) || + (type !== 'prod' && + !resolveHideBranchesDropdown(pathName, selectedOrg?.key, selectedProject?.key)) const pickersHidden = resolveHideBranchesDropdown(pathName, selectedOrg?.key, selectedProject?.key) && diff --git a/apps/studio-prototype/src/components/charts/queries-chart.tsx b/apps/studio-prototype/src/components/charts/queries-chart.tsx index 49255bdeeda..3b50efff910 100644 --- a/apps/studio-prototype/src/components/charts/queries-chart.tsx +++ b/apps/studio-prototype/src/components/charts/queries-chart.tsx @@ -1,17 +1,47 @@ 'use client' -import React from 'react' -import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts' +import React, { useRef, useEffect, useState } from 'react' +import { BarChart, Bar, XAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts' -const generateBarChartData = () => { +// Generate initial data with timestamps, query values, and unique IDs +const generateInitialBarChartData = () => { return Array.from({ length: 120 }, (_, i) => ({ - time: `${14 + Math.floor(i / 4)}:${(i % 4) * 15}`, + id: i, + time: `${14 + Math.floor(i / 4)}:${String((i % 4) * 15).padStart(2, '0')}`, queries: Math.floor(Math.random() * 3000), })) } +// Calculate the next time value based on the last data point +const getNextTime = (lastTime) => { + const [hours, minutes] = lastTime.split(':').map(Number) + const newMinutes = (minutes + 15) % 60 + const newHours = newMinutes === 0 ? hours + 1 : hours + return `${String(newHours).padStart(2, '0')}:${String(newMinutes).padStart(2, '0')}` +} + const QueriesChart = () => { - const data = generateBarChartData() + const [data, setData] = useState(generateInitialBarChartData()) + const dataRef = useRef(data) + + useEffect(() => { + const interval = setInterval(() => { + const lastDataPoint = dataRef.current[dataRef.current.length - 1] + const newTime = getNextTime(lastDataPoint.time) + const newQueries = Math.floor(Math.random() * 3000) + const newData = [ + ...dataRef.current.slice(1), + { id: lastDataPoint.id + 1, time: newTime, queries: newQueries }, + ] + dataRef.current = newData + setData(newData) + }, 5000) + + return () => clearInterval(interval) + }, []) + + console.log('render') + console.log(data) return (
@@ -21,19 +51,21 @@ const QueriesChart = () => {
- - - - {/* */} + + {/* */} - + diff --git a/apps/studio-prototype/src/components/charts/read-and-writes-chart.tsx b/apps/studio-prototype/src/components/charts/read-and-writes-chart.tsx index f8abe1198f8..0ed415e73ed 100644 --- a/apps/studio-prototype/src/components/charts/read-and-writes-chart.tsx +++ b/apps/studio-prototype/src/components/charts/read-and-writes-chart.tsx @@ -4,7 +4,7 @@ import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis } f const generateLineChartData = () => { let reads = 12400 - let writes = 300 + let writes = 1000 return Array.from({ length: 20 }, (_, i) => { reads = reads + (Math.random() - 0.5) * 5000 // Add variation to reads @@ -17,6 +17,7 @@ const generateLineChartData = () => { } }) } + const ReadAndWritesChart = () => { const data = generateLineChartData() @@ -27,56 +28,99 @@ const ReadAndWritesChart = () => {

3,402

- Reads + Rows read

242

- Writes + Rows write
- - - - - - - + + + + + + + + + + + + + + + - - {/* */}