mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 21:51:59 +02:00
Fixed pages.
This commit is contained in:
parent
f7151a880e
commit
b85109241b
|
@ -4,7 +4,7 @@ import { parseDateRange } from 'lib/date';
|
||||||
import DateFilter from 'components/input/DateFilter';
|
import DateFilter from 'components/input/DateFilter';
|
||||||
import WebsiteSelect from 'components/input/WebsiteSelect';
|
import WebsiteSelect from 'components/input/WebsiteSelect';
|
||||||
import { useMessages, useTeamUrl } from 'components/hooks';
|
import { useMessages, useTeamUrl } from 'components/hooks';
|
||||||
import { ReportContext } from './ReportPage';
|
import { ReportContext } from './Report';
|
||||||
|
|
||||||
export interface BaseParametersProps {
|
export interface BaseParametersProps {
|
||||||
showWebsiteSelect?: boolean;
|
showWebsiteSelect?: boolean;
|
||||||
|
|
33
src/app/(main)/reports/[reportId]/Report.tsx
Normal file
33
src/app/(main)/reports/[reportId]/Report.tsx
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import { createContext, ReactNode } from 'react';
|
||||||
|
import { Loading } from 'react-basics';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { useReport } from 'components/hooks';
|
||||||
|
import styles from './Report.module.css';
|
||||||
|
|
||||||
|
export const ReportContext = createContext(null);
|
||||||
|
|
||||||
|
export function Report({
|
||||||
|
reportId,
|
||||||
|
defaultParameters,
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
reportId: string;
|
||||||
|
defaultParameters: { [key: string]: any };
|
||||||
|
children: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
const report = useReport(reportId, defaultParameters);
|
||||||
|
|
||||||
|
if (!report) {
|
||||||
|
return reportId ? <Loading position="page" /> : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReportContext.Provider value={report}>
|
||||||
|
<div className={classNames(styles.container, className)}>{children}</div>
|
||||||
|
</ReportContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Report;
|
|
@ -1,6 +1,6 @@
|
||||||
import styles from './ReportBody.module.css';
|
import styles from './ReportBody.module.css';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { ReportContext } from './ReportPage';
|
import { ReportContext } from './Report';
|
||||||
|
|
||||||
export function ReportBody({ children }) {
|
export function ReportBody({ children }) {
|
||||||
const { report } = useContext(ReportContext);
|
const { report } = useContext(ReportContext);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { Icon, LoadingButton, InlineEditField, useToasts } from 'react-basics';
|
import { Icon, LoadingButton, InlineEditField, useToasts } from 'react-basics';
|
||||||
import { useMessages, useApi, useNavigation, useTeamUrl } from 'components/hooks';
|
import { useMessages, useApi, useNavigation, useTeamUrl } from 'components/hooks';
|
||||||
import { ReportContext } from './ReportPage';
|
import { ReportContext } from './Report';
|
||||||
import styles from './ReportHeader.module.css';
|
import styles from './ReportHeader.module.css';
|
||||||
import { REPORT_TYPES } from 'lib/constants';
|
import { REPORT_TYPES } from 'lib/constants';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import styles from './ReportMenu.module.css';
|
import styles from './ReportMenu.module.css';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { ReportContext } from './ReportPage';
|
import { ReportContext } from './Report';
|
||||||
|
|
||||||
export function ReportMenu({ children }) {
|
export function ReportMenu({ children }) {
|
||||||
const { report } = useContext(ReportContext);
|
const { report } = useContext(ReportContext);
|
||||||
|
|
|
@ -1,33 +1,6 @@
|
||||||
import { createContext, ReactNode } from 'react';
|
'use client';
|
||||||
import { Loading } from 'react-basics';
|
import ReportDetails from './ReportDetails';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useReport } from 'components/hooks';
|
|
||||||
import styles from './Report.module.css';
|
|
||||||
|
|
||||||
export const ReportContext = createContext(null);
|
export default function ReportPage({ reportId }) {
|
||||||
|
return <ReportDetails reportId={reportId} />;
|
||||||
export function ReportPage({
|
|
||||||
reportId,
|
|
||||||
defaultParameters,
|
|
||||||
children,
|
|
||||||
className,
|
|
||||||
}: {
|
|
||||||
reportId: string;
|
|
||||||
defaultParameters: { [key: string]: any };
|
|
||||||
children: ReactNode;
|
|
||||||
className?: string;
|
|
||||||
}) {
|
|
||||||
const report = useReport(reportId, defaultParameters);
|
|
||||||
|
|
||||||
if (!report) {
|
|
||||||
return reportId ? <Loading position="page" /> : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ReportContext.Provider value={report}>
|
|
||||||
<div className={classNames(styles.container, className)}>{children}</div>
|
|
||||||
</ReportContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReportPage;
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import ReportDetails from './ReportDetails';
|
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
|
import ReportPage from './ReportPage';
|
||||||
|
|
||||||
export default function ReportDetailsPage({ params: { reportId } }) {
|
export default function ({ params: { reportId } }) {
|
||||||
if (!reportId) {
|
return <ReportPage reportId={reportId} />;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <ReportDetails reportId={reportId} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Empty from 'components/common/Empty';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import { useApi, useMessages } from 'components/hooks';
|
import { useApi, useMessages } from 'components/hooks';
|
||||||
import { DATA_TYPES, REPORT_PARAMETERS } from 'lib/constants';
|
import { DATA_TYPES, REPORT_PARAMETERS } from 'lib/constants';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import FieldAddForm from '../[reportId]/FieldAddForm';
|
import FieldAddForm from '../[reportId]/FieldAddForm';
|
||||||
import ParameterList from '../[reportId]/ParameterList';
|
import ParameterList from '../[reportId]/ParameterList';
|
||||||
import BaseParameters from '../[reportId]/BaseParameters';
|
import BaseParameters from '../[reportId]/BaseParameters';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ReportPage from '../[reportId]/ReportPage';
|
import Report from '../[reportId]/Report';
|
||||||
import ReportHeader from '../[reportId]/ReportHeader';
|
import ReportHeader from '../[reportId]/ReportHeader';
|
||||||
import ReportMenu from '../[reportId]/ReportMenu';
|
import ReportMenu from '../[reportId]/ReportMenu';
|
||||||
import ReportBody from '../[reportId]/ReportBody';
|
import ReportBody from '../[reportId]/ReportBody';
|
||||||
|
@ -13,7 +13,7 @@ const defaultParameters = {
|
||||||
|
|
||||||
export default function EventDataReport({ reportId }: { reportId?: string }) {
|
export default function EventDataReport({ reportId }: { reportId?: string }) {
|
||||||
return (
|
return (
|
||||||
<ReportPage reportId={reportId} defaultParameters={defaultParameters}>
|
<Report reportId={reportId} defaultParameters={defaultParameters}>
|
||||||
<ReportHeader icon={<Nodes />} />
|
<ReportHeader icon={<Nodes />} />
|
||||||
<ReportMenu>
|
<ReportMenu>
|
||||||
<EventDataParameters />
|
<EventDataParameters />
|
||||||
|
@ -21,6 +21,6 @@ export default function EventDataReport({ reportId }: { reportId?: string }) {
|
||||||
<ReportBody>
|
<ReportBody>
|
||||||
<EventDataTable />
|
<EventDataTable />
|
||||||
</ReportBody>
|
</ReportBody>
|
||||||
</ReportPage>
|
</Report>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { GridTable, GridColumn } from 'react-basics';
|
import { GridTable, GridColumn } from 'react-basics';
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
|
|
||||||
export function EventDataTable() {
|
export function EventDataTable() {
|
||||||
const { report } = useContext(ReportContext);
|
const { report } = useContext(ReportContext);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import EventDataReport from './EventDataReport';
|
import EventDataReportPage from './EventDataReportPage';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return <EventDataReport />;
|
return <EventDataReportPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Loading, StatusLight } from 'react-basics';
|
||||||
import { useMessages, useTheme } from 'components/hooks';
|
import { useMessages, useTheme } from 'components/hooks';
|
||||||
import BarChart from 'components/metrics/BarChart';
|
import BarChart from 'components/metrics/BarChart';
|
||||||
import { formatLongNumber } from 'lib/format';
|
import { formatLongNumber } from 'lib/format';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import styles from './FunnelChart.module.css';
|
import styles from './FunnelChart.module.css';
|
||||||
|
|
||||||
export interface FunnelChartProps {
|
export interface FunnelChartProps {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import UrlAddForm from './UrlAddForm';
|
import UrlAddForm from './UrlAddForm';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import BaseParameters from '../[reportId]/BaseParameters';
|
import BaseParameters from '../[reportId]/BaseParameters';
|
||||||
import ParameterList from '../[reportId]/ParameterList';
|
import ParameterList from '../[reportId]/ParameterList';
|
||||||
import PopupForm from '../[reportId]/PopupForm';
|
import PopupForm from '../[reportId]/PopupForm';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import FunnelChart from './FunnelChart';
|
import FunnelChart from './FunnelChart';
|
||||||
import FunnelTable from './FunnelTable';
|
import FunnelTable from './FunnelTable';
|
||||||
import FunnelParameters from './FunnelParameters';
|
import FunnelParameters from './FunnelParameters';
|
||||||
import ReportPage from '../[reportId]/ReportPage';
|
import Report from '../[reportId]/Report';
|
||||||
import ReportHeader from '../[reportId]/ReportHeader';
|
import ReportHeader from '../[reportId]/ReportHeader';
|
||||||
import ReportMenu from '../[reportId]/ReportMenu';
|
import ReportMenu from '../[reportId]/ReportMenu';
|
||||||
import ReportBody from '../[reportId]/ReportBody';
|
import ReportBody from '../[reportId]/ReportBody';
|
||||||
|
@ -15,7 +15,7 @@ const defaultParameters = {
|
||||||
|
|
||||||
export default function FunnelReport({ reportId }: { reportId?: string }) {
|
export default function FunnelReport({ reportId }: { reportId?: string }) {
|
||||||
return (
|
return (
|
||||||
<ReportPage reportId={reportId} defaultParameters={defaultParameters}>
|
<Report reportId={reportId} defaultParameters={defaultParameters}>
|
||||||
<ReportHeader icon={<Funnel />} />
|
<ReportHeader icon={<Funnel />} />
|
||||||
<ReportMenu>
|
<ReportMenu>
|
||||||
<FunnelParameters />
|
<FunnelParameters />
|
||||||
|
@ -24,6 +24,6 @@ export default function FunnelReport({ reportId }: { reportId?: string }) {
|
||||||
<FunnelChart />
|
<FunnelChart />
|
||||||
<FunnelTable />
|
<FunnelTable />
|
||||||
</ReportBody>
|
</ReportBody>
|
||||||
</ReportPage>
|
</Report>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import ListTable from 'components/metrics/ListTable';
|
import ListTable from 'components/metrics/ListTable';
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
|
|
||||||
export function FunnelTable() {
|
export function FunnelTable() {
|
||||||
const { report } = useContext(ReportContext);
|
const { report } = useContext(ReportContext);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import BaseParameters from '../[reportId]/BaseParameters';
|
import BaseParameters from '../[reportId]/BaseParameters';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import ParameterList from '../[reportId]/ParameterList';
|
import ParameterList from '../[reportId]/ParameterList';
|
||||||
import FilterSelectForm from '../[reportId]/FilterSelectForm';
|
import FilterSelectForm from '../[reportId]/FilterSelectForm';
|
||||||
import FieldSelectForm from '../[reportId]/FieldSelectForm';
|
import FieldSelectForm from '../[reportId]/FieldSelectForm';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ReportPage from '../[reportId]/ReportPage';
|
import Report from '../[reportId]/Report';
|
||||||
import ReportHeader from '../[reportId]/ReportHeader';
|
import ReportHeader from '../[reportId]/ReportHeader';
|
||||||
import ReportMenu from '../[reportId]/ReportMenu';
|
import ReportMenu from '../[reportId]/ReportMenu';
|
||||||
import ReportBody from '../[reportId]/ReportBody';
|
import ReportBody from '../[reportId]/ReportBody';
|
||||||
|
@ -14,7 +14,7 @@ const defaultParameters = {
|
||||||
|
|
||||||
export default function InsightsReport({ reportId }: { reportId?: string }) {
|
export default function InsightsReport({ reportId }: { reportId?: string }) {
|
||||||
return (
|
return (
|
||||||
<ReportPage reportId={reportId} defaultParameters={defaultParameters}>
|
<Report reportId={reportId} defaultParameters={defaultParameters}>
|
||||||
<ReportHeader icon={<Lightbulb />} />
|
<ReportHeader icon={<Lightbulb />} />
|
||||||
<ReportMenu>
|
<ReportMenu>
|
||||||
<InsightsParameters />
|
<InsightsParameters />
|
||||||
|
@ -22,6 +22,6 @@ export default function InsightsReport({ reportId }: { reportId?: string }) {
|
||||||
<ReportBody>
|
<ReportBody>
|
||||||
<InsightsTable />
|
<InsightsTable />
|
||||||
</ReportBody>
|
</ReportBody>
|
||||||
</ReportPage>
|
</Report>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useContext, useEffect, useState } from 'react';
|
import { useContext, useEffect, useState } from 'react';
|
||||||
import { GridTable, GridColumn } from 'react-basics';
|
import { GridTable, GridColumn } from 'react-basics';
|
||||||
import { useFormat, useMessages } from 'components/hooks';
|
import { useFormat, useMessages } from 'components/hooks';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
||||||
|
|
||||||
export function InsightsTable() {
|
export function InsightsTable() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import { Form, FormButtons, FormRow, SubmitButton } from 'react-basics';
|
import { Form, FormButtons, FormRow, SubmitButton } from 'react-basics';
|
||||||
import { ReportContext } from '../[reportId]/ReportPage';
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import { MonthSelect } from 'components/input/MonthSelect';
|
import { MonthSelect } from 'components/input/MonthSelect';
|
||||||
import BaseParameters from '../[reportId]/BaseParameters';
|
import BaseParameters from '../[reportId]/BaseParameters';
|
||||||
import { parseDateRange } from 'lib/date';
|
import { parseDateRange } from 'lib/date';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import RetentionTable from './RetentionTable';
|
import RetentionTable from './RetentionTable';
|
||||||
import RetentionParameters from './RetentionParameters';
|
import RetentionParameters from './RetentionParameters';
|
||||||
import ReportPage from '../[reportId]/ReportPage';
|
import Report from '../[reportId]/Report';
|
||||||
import ReportHeader from '../[reportId]/ReportHeader';
|
import ReportHeader from '../[reportId]/ReportHeader';
|
||||||
import ReportMenu from '../[reportId]/ReportMenu';
|
import ReportMenu from '../[reportId]/ReportMenu';
|
||||||
import ReportBody from '../[reportId]/ReportBody';
|
import ReportBody from '../[reportId]/ReportBody';
|
||||||
|
@ -20,7 +20,7 @@ const defaultParameters = {
|
||||||
|
|
||||||
export default function RetentionReport({ reportId }: { reportId?: string }) {
|
export default function RetentionReport({ reportId }: { reportId?: string }) {
|
||||||
return (
|
return (
|
||||||
<ReportPage reportId={reportId} defaultParameters={defaultParameters}>
|
<Report reportId={reportId} defaultParameters={defaultParameters}>
|
||||||
<ReportHeader icon={<Magnet />} />
|
<ReportHeader icon={<Magnet />} />
|
||||||
<ReportMenu>
|
<ReportMenu>
|
||||||
<RetentionParameters />
|
<RetentionParameters />
|
||||||
|
@ -28,6 +28,6 @@ export default function RetentionReport({ reportId }: { reportId?: string }) {
|
||||||
<ReportBody>
|
<ReportBody>
|
||||||
<RetentionTable />
|
<RetentionTable />
|
||||||
</ReportBody>
|
</ReportBody>
|
||||||
</ReportPage>
|
</Report>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
'use client';
|
||||||
|
import WebsiteHeader from '../WebsiteHeader';
|
||||||
|
import WebsiteEventData from './WebsiteEventData';
|
||||||
|
|
||||||
|
export default function EventDataPage({ websiteId }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<WebsiteHeader websiteId={websiteId} />
|
||||||
|
<WebsiteEventData websiteId={websiteId} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,15 +1,10 @@
|
||||||
import WebsiteHeader from '../WebsiteHeader';
|
import { Metadata } from 'next';
|
||||||
import WebsiteEventData from './WebsiteEventData';
|
import EventDataPage from './EventDataPage';
|
||||||
|
|
||||||
export default function WebsiteEventDataPage({ params: { websiteId } }) {
|
export default async function ({ params: { websiteId } }) {
|
||||||
if (!websiteId) {
|
return <EventDataPage websiteId={websiteId} />;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<WebsiteHeader websiteId={websiteId} />
|
|
||||||
<WebsiteEventData websiteId={websiteId} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Event Data | Umami',
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user