Skip to content

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

Add new Reports layout

Terry Sutton91757781d296
diff --git a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
index b4551f77c74..d67625440fa 100644
--- a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
+++ b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
@@ -11,38 +11,38 @@ export const generateLogsMenu = (project?: Project): ProductMenuGroup[] => {
title: 'Logs',
items: [
{
- name: 'Explorer',
+ name: 'Logs Explorer',
key: 'explorer',
url: `/project/${ref}/logs/explorer`,
items: [],
},
{
- name: 'Postgres logs',
+ name: 'Postgres',
key: 'postgres-logs',
url: `/project/${ref}/logs/postgres-logs`,
items: [],
},
{
- name: 'PostgREST logs',
+ name: 'PostgREST',
key: 'postgrest-logs',
url: `/project/${ref}/logs/postgrest-logs`,
items: [],
},
{
- name: 'Auth logs',
+ name: 'Auth',
key: 'auth-logs',
url: `/project/${ref}/logs/auth-logs`,
items: [],
},
{
- name: 'Storage logs',
+ name: 'Storage',
key: 'storage-logs',
url: `/project/${ref}/logs/storage-logs`,
items: [],
},
{
- name: 'Realtime logs',
+ name: 'Realtime',
key: 'realtime-logs',
url: `/project/${ref}/logs/realtime-logs`,
items: [],
@@ -51,7 +51,7 @@ export const generateLogsMenu = (project?: Project): ProductMenuGroup[] => {
...(productReports
? [
{
- name: 'API usage',
+ name: 'Usage (used to be "API usage") move to reports',
key: 'api-usage',
url: `/project/${ref}/logs/api-usage`,
items: [],
diff --git a/studio/components/layouts/ReportsLayout/ReportsLayout.tsx b/studio/components/layouts/ReportsLayout/ReportsLayout.tsx
index 1ac4056fa5e..d2b090f6c2c 100644
--- a/studio/components/layouts/ReportsLayout/ReportsLayout.tsx
+++ b/studio/components/layouts/ReportsLayout/ReportsLayout.tsx
@@ -4,6 +4,7 @@ import { useRouter } from 'next/router'
import { useStore, withAuth } from 'hooks'
import BaseLayout from '..'
import ProductMenu from 'components/ui/ProductMenu'
+import { generateReportsMenu } from './ReportsMenu.utils'
interface Props {
title: string
@@ -12,7 +13,7 @@ interface Props {
const ReportsLayout: FC<Props> = ({ title, children }) => {
const { ui } = useStore()
- const projectRef = ui.selectedProjectRef as string
+ const project = ui.selectedProject
const router = useRouter()
const page = router.pathname.split('/')[4] || ''
@@ -22,7 +23,7 @@ const ReportsLayout: FC<Props> = ({ title, children }) => {
{
name: 'Overview',
key: '',
- url: `/project/${projectRef}/reports`,
+ url: `/project/${project}/reports`,
items: [],
},
],
@@ -32,7 +33,7 @@ const ReportsLayout: FC<Props> = ({ title, children }) => {
{
name: 'Dashboard',
key: 'dashboard',
- url: `/project/${projectRef}/reports/dashboard`,
+ url: `/project/${project}/reports/dashboard`,
items: [],
},
],
@@ -42,7 +43,7 @@ const ReportsLayout: FC<Props> = ({ title, children }) => {
<BaseLayout
title={title}
product="Reports"
- productMenu={<ProductMenu page={page} menu={menuRoutes} />}
+ productMenu={<ProductMenu page={page} menu={generateReportsMenu(project)} />}
>
<main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">
{children}
diff --git a/studio/components/layouts/ReportsLayout/ReportsMenu.utils.ts b/studio/components/layouts/ReportsLayout/ReportsMenu.utils.ts
new file mode 100644
index 00000000000..b36fec9b7dd
--- /dev/null
+++ b/studio/components/layouts/ReportsLayout/ReportsMenu.utils.ts
@@ -0,0 +1,34 @@
+import { Project } from 'types'
+import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
+import { useFlag } from 'hooks'
+
+export const generateReportsMenu = (project?: Project): ProductMenuGroup[] => {
+ const ref = project?.ref ?? 'default'
+ const productReports = useFlag('productReports')
+
+ return [
+ {
+ title: 'Reports',
+ items: [
+ {
+ name: 'Custom reports?',
+ key: 'reports',
+ url: `/project/${ref}/reports`,
+ items: [],
+ },
+ {
+ name: 'API?',
+ key: 'api-usage',
+ url: `/project/${ref}/reports/api-usage`,
+ items: [],
+ },
+ {
+ name: 'Database?',
+ key: 'database',
+ url: `/project/${ref}/reports/database`,
+ items: [],
+ },
+ ],
+ },
+ ]
+}
diff --git a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts
index bc2b02a22ed..c9b26d031e7 100644
--- a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts
+++ b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts
@@ -33,7 +33,7 @@ export const generateSettingsMenu = (ref: string, project?: ProjectBase): Produc
items: [],
},
{
- name: 'Connections',
+ name: 'API',
key: 'api',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/api`,
items: [],
diff --git a/studio/pages/project/[ref]/reports/[id].tsx b/studio/pages/project/[ref]/reports/[id].tsx
index 5bb2526a034..9afcfa08e0a 100644
--- a/studio/pages/project/[ref]/reports/[id].tsx
+++ b/studio/pages/project/[ref]/reports/[id].tsx
@@ -3,6 +3,7 @@ import { NextPageWithLayout } from 'types'
import { ProjectLayoutWithAuth } from 'components/layouts'
import EditReportModal from 'components/to-be-cleaned/Reports/EditReportModal'
import Reports from 'components/interfaces/Reports/Reports'
+import ReportsLayout from 'components/layouts/ReportsLayout/ReportsLayout'
const PageLayout: NextPageWithLayout = () => (
<>
@@ -13,6 +14,6 @@ const PageLayout: NextPageWithLayout = () => (
</>
)
-PageLayout.getLayout = (page) => <ProjectLayoutWithAuth>{page}</ProjectLayoutWithAuth>
+PageLayout.getLayout = (page) => <ReportsLayout>{page}</ReportsLayout>
export default observer(PageLayout)
diff --git a/studio/pages/project/[ref]/logs/api-usage.tsx b/studio/pages/project/[ref]/reports/api-usage.tsx
similarity index 77%
rename from studio/pages/project/[ref]/logs/api-usage.tsx
rename to studio/pages/project/[ref]/reports/api-usage.tsx
index d6c523c8564..9a027edf251 100644
--- a/studio/pages/project/[ref]/logs/api-usage.tsx
+++ b/studio/pages/project/[ref]/reports/api-usage.tsx
@@ -4,7 +4,7 @@ import { useRouter } from 'next/router'
import { NextPageWithLayout } from 'types'
import PresetReport from 'components/interfaces/Reports/PresetReport'
import { Presets } from 'components/interfaces/Reports/Reports.types'
-import { LogsLayout } from 'components/layouts'
+import ReportsLayout from 'components/layouts/ReportsLayout/ReportsLayout'
export const ApiUsagePage: NextPageWithLayout = () => {
const router = useRouter()
@@ -13,6 +13,6 @@ export const ApiUsagePage: NextPageWithLayout = () => {
return <PresetReport preset={Presets.OVERVIEW} projectRef={ref as string} />
}
-ApiUsagePage.getLayout = (page) => <LogsLayout>{page}</LogsLayout>
+ApiUsagePage.getLayout = (page) => <ReportsLayout>{page}</ReportsLayout>
export default observer(ApiUsagePage)
diff --git a/studio/pages/project/[ref]/reports/database.tsx b/studio/pages/project/[ref]/reports/database.tsx
new file mode 100644
index 00000000000..42da85a7c12
--- /dev/null
+++ b/studio/pages/project/[ref]/reports/database.tsx
@@ -0,0 +1,127 @@
+import dayjs from 'dayjs'
+import useSWR from 'swr'
+import * as Tooltip from '@radix-ui/react-tooltip'
+import { FC, useState, useRef, useEffect } from 'react'
+import { toJS } from 'mobx'
+import { observer } from 'mobx-react-lite'
+import { useRouter } from 'next/router'
+import { debounce } from 'lodash'
+import generator from 'generate-password'
+import { Input, Button, IconDownload, IconArrowRight, Tabs, Modal } from 'ui'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+
+import { NextPageWithLayout } from 'types'
+import { checkPermissions, useFlag, useStore } from 'hooks'
+import { get, patch } from 'lib/common/fetch'
+import { pluckObjectFields, passwordStrength } from 'lib/helpers'
+import { API_URL, DEFAULT_MINIMUM_PASSWORD_STRENGTH, TIME_PERIODS_INFRA } from 'lib/constants'
+
+import ReportsLayout from 'components/layouts/ReportsLayout/ReportsLayout'
+import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
+import Panel from 'components/ui/Panel'
+import DateRangePicker from 'components/to-be-cleaned/DateRangePicker'
+import ChartHandler from 'components/to-be-cleaned/Charts/ChartHandler'
+import ProjectUsageMinimal from 'components/interfaces/Settings/ProjectUsageBars/ProjectUsageMinimal'
+
+const ProjectSettings: NextPageWithLayout = () => {
+ const router = useRouter()
+ const { ref } = router.query
+
+ const { ui } = useStore()
+ const project = ui.selectedProject
+
+ return (
+ <div>
+ <div className="content h-full w-full overflow-y-auto">
+ <div className="w-full max-w-5xl px-4 py-4">
+ <DatabaseUsage project={project} />
+ </div>
+ </div>
+ </div>
+ )
+}
+
+ProjectSettings.getLayout = (page) => <ReportsLayout title="Database">{page}</ReportsLayout>
+
+export default observer(ProjectSettings)
+
+const DatabaseUsage: FC<any> = ({ project }) => {
+ const [dateRange, setDateRange] = useState<any>(undefined)
+ const router = useRouter()
+ const ref = router.query.ref as string
+
+ return (
+ <>
+ <div>
+ <section className="">
+ <Panel
+ title={
+ <h5 key="panel-title" className="mb-0">
+ Database health
+ </h5>
+ }
+ >
+ <Panel.Content>
+ <div className="mb-4 flex items-center space-x-3">
+ <DateRangePicker
+ loading={false}
+ value={'3h'}
+ options={TIME_PERIODS_INFRA}
+ currentBillingPeriodStart={undefined}
+ onChange={setDateRange}
+ />
+ {dateRange && (
+ <div className="flex items-center space-x-2">
+ <p className="text-scale-1000">
+ {dayjs(dateRange.period_start.date).format('MMMM D, hh:mma')}
+ </p>
+ <p className="text-scale-1000">
+ <IconArrowRight size={12} />
+ </p>
+ <p className="text-scale-1000">
+ {dayjs(dateRange.period_end.date).format('MMMM D, hh:mma')}
+ </p>
+ </div>
+ )}
+ </div>
+ <div className="space-y-6">
+ {dateRange && (
+ <ChartHandler
+ startDate={dateRange?.period_start?.date}
+ endDate={dateRange?.period_end?.date}
+ attribute={'ram_usage'}
+ label={'Memory usage'}
+ interval={dateRange.interval}
+ provider={'infra-monitoring'}
+ />
+ )}
+
+ {dateRange && (
+ <ChartHandler
+ startDate={dateRange?.period_start?.date}
+ endDate={dateRange?.period_end?.date}
+ attribute={'cpu_usage'}
+ label={'CPU usage'}
+ interval={dateRange.interval}
+ provider={'infra-monitoring'}
+ />
+ )}
+
+ {dateRange && (
+ <ChartHandler
+ startDate={dateRange?.period_start?.date}
+ endDate={dateRange?.period_end?.date}
+ attribute={'disk_io_budget'}
+ label={'Daily Disk IO Budget remaining'}
+ interval={dateRange.interval}
+ provider={'infra-monitoring'}
+ />
+ )}
+ </div>
+ </Panel.Content>
+ </Panel>
+ </section>
+ </div>
+ </>
+ )
+}
diff --git a/studio/pages/project/[ref]/settings/database.tsx b/studio/pages/project/[ref]/settings/database.tsx
index dd89bf6e2ad..dd342a1af8b 100644
--- a/studio/pages/project/[ref]/settings/database.tsx
+++ b/studio/pages/project/[ref]/settings/database.tsx
@@ -19,23 +19,18 @@ import { API_URL, DEFAULT_MINIMUM_PASSWORD_STRENGTH, TIME_PERIODS_INFRA } from '
import { SettingsLayout } from 'components/layouts'
import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
import Panel from 'components/ui/Panel'
-import DateRangePicker from 'components/to-be-cleaned/DateRangePicker'
-import ChartHandler from 'components/to-be-cleaned/Charts/ChartHandler'
import ConnectionPooling from 'components/interfaces/Database/Pooling/ConnectionPooling'
-import ProjectUsageMinimal from 'components/interfaces/Settings/ProjectUsageBars/ProjectUsageMinimal'
const ProjectSettings: NextPageWithLayout = () => {
const router = useRouter()
const { ref } = router.query
const { ui } = useStore()
- const project = ui.selectedProject
return (
<div>
<div className="content h-full w-full overflow-y-auto">
<div className="w-full max-w-5xl px-4 py-4">
- <DatabaseUsage project={project} />
<GeneralSettings projectRef={ref} />
<ConnectionPooling />
</div>
@@ -48,102 +43,6 @@ ProjectSettings.getLayout = (page) => <SettingsLayout title="Database">{page}</S
export default observer(ProjectSettings)
-const DatabaseUsage: FC<any> = ({ project }) => {
- const [dateRange, setDateRange] = useState<any>(undefined)
- const router = useRouter()
- const ref = router.query.ref as string
-
- return (
- <>
- <div>
- <section className="">
- <Panel
- title={
- <h5 key="panel-title" className="mb-0">
- Database health
- </h5>
- }
- >
- <Panel.Content>
- <div className="mb-4 flex items-center space-x-3">
- <DateRangePicker
- loading={false}
- value={'3h'}
- options={TIME_PERIODS_INFRA}
- currentBillingPeriodStart={undefined}
- onChange={setDateRange}
- />
- {dateRange && (
- <div className="flex items-center space-x-2">
- <p className="text-scale-1000">
- {dayjs(dateRange.period_start.date).format('MMMM D, hh:mma')}
- </p>
- <p className="text-scale-1000">
- <IconArrowRight size={12} />
- </p>
- <p className="text-scale-1000">
- {dayjs(dateRange.period_end.date).format('MMMM D, hh:mma')}
- </p>
- </div>
- )}
- </div>
- <div className="space-y-6">
- {dateRange && (
- <ChartHandler
- startDate={dateRange?.period_start?.date}
- endDate={dateRange?.period_end?.date}
- attribute={'ram_usage'}
- label={'Memory usage'}
- interval={dateRange.interval}
- provider={'infra-monitoring'}
- />
- )}
-
- {dateRange && (
- <ChartHandler
- startDate={dateRange?.period_start?.date}
- endDate={dateRange?.period_end?.date}
- attribute={'cpu_usage'}
- label={'CPU usage'}
- interval={dateRange.interval}
- provider={'infra-monitoring'}
- />
- )}
-
- {dateRange && (
- <ChartHandler
- startDate={dateRange?.period_start?.date}
- endDate={dateRange?.period_end?.date}
- attribute={'disk_io_budget'}
- label={'Daily Disk IO Budget remaining'}
- interval={dateRange.interval}
- provider={'infra-monitoring'}
- />
- )}
- </div>
- </Panel.Content>
- </Panel>
- </section>
- </div>
- <div>
- <section className="mt-6">
- <Panel
- title={
- <h5 key="panel-title" className="mb-0">
- Database usage
- </h5>
- }
- >
- <Panel.Content>
- <ProjectUsageMinimal projectRef={ref} filter={'Database'} />
- </Panel.Content>
- </Panel>
- </section>
- </div>
- </>
- )
-}
-
const ResetDbPassword: FC<any> = () => {
const { ui } = useStore()
const projectRef = ui.selectedProject?.ref