Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
New reports screens.
Mike Cao2b13002f1b67
diff --git a/components/messages.js b/components/messages.jsindex 166a121bf..c6ddae60f 100644--- a/components/messages.js+++ b/components/messages.js@@ -133,6 +133,8 @@ export const labels = defineMessages({runQuery: { id: 'label.run-query', defaultMessage: 'Run query' },field: { id: 'label.field', defaultMessage: 'Field' },fields: { id: 'label.fields', defaultMessage: 'Fields' },+ createReport: { id: 'labels.create-report', defaultMessage: 'Create report' },+ description: { id: 'labels.description', defaultMessage: 'Description' },});export const messages = defineMessages({diff --git a/components/pages/reports/ReportList.js b/components/pages/reports/ReportTemplates.jssimilarity index 85%rename from components/pages/reports/ReportList.jsrename to components/pages/reports/ReportTemplates.jsindex 6e07c81ed..7ed40af75 100644--- a/components/pages/reports/ReportList.js+++ b/components/pages/reports/ReportTemplates.js@@ -5,7 +5,8 @@ import PageHeader from 'components/layout/PageHeader';import Funnel from 'assets/funnel.svg';import Nodes from 'assets/nodes.svg';import Lightbulb from 'assets/lightbulb.svg';-import styles from './ReportList.module.css';+import styles from './ReportTemplates.module.css';+import { useMessages } from 'hooks';const reports = [{@@ -50,10 +51,12 @@ function ReportItem({ title, description, url, icon }) {);}-export function ReportList() {+export function ReportTemplates() {+ const { formatMessage, labels } = useMessages();+return (<Page>- <PageHeader title="Reports" />+ <PageHeader title={formatMessage(labels.reports)} /><div className={styles.reports}>{reports.map(({ title, description, url, icon }) => {return (@@ -65,4 +68,4 @@ export function ReportList() {);}-export default ReportList;+export default ReportTemplates;diff --git a/components/pages/reports/ReportList.module.css b/components/pages/reports/ReportTemplates.module.csssimilarity index 100%rename from components/pages/reports/ReportList.module.cssrename to components/pages/reports/ReportTemplates.module.cssdiff --git a/components/pages/reports/ReportsList.js b/components/pages/reports/ReportsList.jsnew file mode 100644index 000000000..255cb5468--- /dev/null+++ b/components/pages/reports/ReportsList.js@@ -0,0 +1,29 @@+import Page from 'components/layout/Page';+import PageHeader from 'components/layout/PageHeader';+import Link from 'next/link';+import { Button, Icon, Icons, Text } from 'react-basics';+import { useMessages, useReports } from 'hooks';+import ReportsTable from './ReportsTable';++export function ReportsList() {+ const { formatMessage, labels } = useMessages();+ const { reports, error, isLoading } = useReports();++ return (+ <Page loading={isLoading} error={error}>+ <PageHeader title="Reports">+ <Link href="/reports/create">+ <Button variant="primary">+ <Icon>+ <Icons.Plus />+ </Icon>+ <Text>{formatMessage(labels.createReport)}</Text>+ </Button>+ </Link>+ </PageHeader>+ <ReportsTable data={reports} />+ </Page>+ );+}++export default ReportsList;diff --git a/components/pages/reports/ReportsTable.js b/components/pages/reports/ReportsTable.jsnew file mode 100644index 000000000..dfb3a97a3--- /dev/null+++ b/components/pages/reports/ReportsTable.js@@ -0,0 +1,37 @@+import Link from 'next/link';+import { Button, Text, Icon, Icons } from 'react-basics';+import SettingsTable from 'components/common/SettingsTable';+import useMessages from 'hooks/useMessages';+import useConfig from 'hooks/useConfig';++export function ReportsTable({ data = [] }) {+ const { formatMessage, labels } = useMessages();+ const { openExternal } = useConfig();++ const columns = [+ { name: 'name', label: formatMessage(labels.name) },+ { name: 'description', label: formatMessage(labels.description) },+ { name: 'action', label: ' ' },+ ];++ return (+ <SettingsTable columns={columns} data={data}>+ {row => {+ const { id } = row;++ return (+ <Link href={`/reports/${id}`}>+ <Button>+ <Icon>+ <Icons.ArrowRight />+ </Icon>+ <Text>{formatMessage(labels.view)}</Text>+ </Button>+ </Link>+ );+ }}+ </SettingsTable>+ );+}++export default ReportsTable;diff --git a/hooks/index.js b/hooks/index.jsindex 3f2ba4d73..cca6ca297 100644--- a/hooks/index.js+++ b/hooks/index.js@@ -10,6 +10,7 @@ export * from './useLocale';export * from './useMessages';export * from './usePageQuery';export * from './useReport';+export * from './useReports';export * from './useRequireLogin';export * from './useShareToken';export * from './useSticky';diff --git a/hooks/useReports.js b/hooks/useReports.jsnew file mode 100644index 000000000..0b5e60d05--- /dev/null+++ b/hooks/useReports.js@@ -0,0 +1,10 @@+import useApi from './useApi';++export function useReports() {+ const { get, useQuery } = useApi();+ const { data, error, isLoading } = useQuery(['reports'], () => get(`/reports`));++ return { reports: data, error, isLoading };+}++export default useReports;diff --git a/pages/reports/create.js b/pages/reports/create.jsnew file mode 100644index 000000000..421b9c0ac--- /dev/null+++ b/pages/reports/create.js@@ -0,0 +1,13 @@+import AppLayout from 'components/layout/AppLayout';+import ReportTemplates from 'components/pages/reports/ReportTemplates';+import { useMessages } from 'hooks';++export default function ReportsPage() {+ const { formatMessage, labels } = useMessages();++ return (+ <AppLayout title={formatMessage(labels.reports)}>+ <ReportTemplates />+ </AppLayout>+ );+}diff --git a/pages/reports/index.js b/pages/reports/index.jsindex 6da2b943e..237f31ee0 100644--- a/pages/reports/index.js+++ b/pages/reports/index.js@@ -1,21 +1,13 @@-import { useState } from 'react';-import { Item, Tabs } from 'react-basics';import AppLayout from 'components/layout/AppLayout';-import ReportList from 'components/pages/reports/ReportList';import useMessages from 'hooks/useMessages';+import ReportsList from 'components/pages/reports/ReportsList';export default function ReportsPage() {- const [tab, setTab] = useState('create');const { formatMessage, labels } = useMessages();return (<AppLayout title={formatMessage(labels.reports)}>- <Tabs selectedKey={tab} onSelect={setTab} style={{ marginBottom: 30, fontSize: 14 }}>- <Item key="create">{formatMessage(labels.reports)}</Item>- <Item key="saved">{formatMessage(labels.save)}</Item>- </Tabs>- {tab === 'create' && <ReportList />}- {tab === 'saved' && <h1>My reports</h1>}+ <ReportsList /></AppLayout>);}