umami/components/pages/websites/WebsiteMenuView.js

138 lines
3.9 KiB
JavaScript
Raw Normal View History

2023-03-31 14:55:28 +02:00
import { Icon, Button, Flexbox, Text } from 'react-basics';
2023-02-04 17:59:52 +01:00
import Link from 'next/link';
import { GridRow, GridColumn } from 'components/layout/Grid';
2023-02-04 17:59:52 +01:00
import BrowsersTable from 'components/metrics/BrowsersTable';
import CountriesTable from 'components/metrics/CountriesTable';
2023-04-14 07:28:29 +02:00
import RegionsTable from 'components/metrics/RegionsTable';
import CitiesTable from 'components/metrics/CitiesTable';
2023-02-04 17:59:52 +01:00
import DevicesTable from 'components/metrics/DevicesTable';
import LanguagesTable from 'components/metrics/LanguagesTable';
import OSTable from 'components/metrics/OSTable';
import PagesTable from 'components/metrics/PagesTable';
import QueryParametersTable from 'components/metrics/QueryParametersTable';
import ReferrersTable from 'components/metrics/ReferrersTable';
import ScreenTable from 'components/metrics/ScreenTable';
import EventsTable from 'components/metrics/EventsTable';
import Icons from 'components/icons';
2023-03-23 19:46:49 +01:00
import SideNav from 'components/layout/SideNav';
import usePageQuery from 'hooks/usePageQuery';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-03-23 19:46:49 +01:00
import styles from './WebsiteMenuView.module.css';
2023-02-04 17:59:52 +01:00
const views = {
url: PagesTable,
2023-03-31 14:55:28 +02:00
title: PagesTable,
2023-02-04 17:59:52 +01:00
referrer: ReferrersTable,
browser: BrowsersTable,
os: OSTable,
device: DevicesTable,
screen: ScreenTable,
country: CountriesTable,
2023-04-14 07:28:29 +02:00
region: RegionsTable,
city: CitiesTable,
2023-02-04 17:59:52 +01:00
language: LanguagesTable,
event: EventsTable,
query: QueryParametersTable,
};
export default function WebsiteMenuView({ websiteId, websiteDomain }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels } = useMessages();
2023-02-04 17:59:52 +01:00
const {
resolveUrl,
2023-02-04 17:59:52 +01:00
query: { view },
} = usePageQuery();
const items = [
{
key: 'url',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.pages),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'url' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'referrer',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.referrers),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'referrer' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'browser',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.browsers),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'browser' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'os',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.os),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'os' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'device',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.devices),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'device' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'country',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.countries),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'country' }),
2023-02-04 17:59:52 +01:00
},
2023-04-14 07:28:29 +02:00
{
key: 'region',
label: formatMessage(labels.regions),
url: resolveUrl({ view: 'region' }),
},
{
key: 'city',
label: formatMessage(labels.cities),
url: resolveUrl({ view: 'city' }),
},
2023-02-04 17:59:52 +01:00
{
key: 'language',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.languages),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'language' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'screen',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.screens),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'screen' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'event',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.events),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'event' }),
2023-02-04 17:59:52 +01:00
},
{
key: 'query',
2023-02-04 17:59:52 +01:00
label: formatMessage(labels.query),
2023-03-23 19:46:49 +01:00
url: resolveUrl({ view: 'query' }),
2023-02-04 17:59:52 +01:00
},
];
const DetailsComponent = views[view] || (() => null);
2023-02-04 17:59:52 +01:00
return (
<GridRow>
<GridColumn xs={12} sm={12} md={12} defaultSize={3} className={styles.menu}>
<Link href={resolveUrl({ view: undefined })}>
<Flexbox justifyContent="center">
<Button variant="quiet">
<Icon rotate={180}>
<Icons.ArrowRight />
</Icon>
<Text>{formatMessage(labels.back)}</Text>
</Button>
</Flexbox>
</Link>
2023-03-23 19:46:49 +01:00
<SideNav items={items} selectedKey={view} shallow={true} />
</GridColumn>
2023-04-01 06:31:58 +02:00
<GridColumn xs={12} sm={12} md={12} defaultSize={9} className={styles.content}>
2023-02-04 17:59:52 +01:00
<DetailsComponent
websiteId={websiteId}
websiteDomain={websiteDomain}
limit={false}
animate={false}
showFilters={true}
virtualize={true}
2023-02-04 17:59:52 +01:00
/>
</GridColumn>
</GridRow>
2023-02-04 17:59:52 +01:00
);
}