2023-02-11 08:21:50 +01:00
|
|
|
import { Row, Column, Menu, Item, Icon, Button, Flexbox, Text } from 'react-basics';
|
2023-02-10 12:26:57 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
2023-02-04 17:59:52 +01:00
|
|
|
import Link from 'next/link';
|
2023-02-10 12:37:06 +01:00
|
|
|
import classNames from 'classnames';
|
2023-02-04 17:59:52 +01:00
|
|
|
import BrowsersTable from 'components/metrics/BrowsersTable';
|
|
|
|
import CountriesTable from 'components/metrics/CountriesTable';
|
|
|
|
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 usePageQuery from 'hooks/usePageQuery';
|
|
|
|
import Icons from 'components/icons';
|
2023-02-08 07:17:55 +01:00
|
|
|
import { labels } from 'components/messages';
|
2023-02-10 12:26:57 +01:00
|
|
|
import styles from './WebsiteMenuView.module.css';
|
2023-02-04 17:59:52 +01:00
|
|
|
|
|
|
|
const views = {
|
|
|
|
url: PagesTable,
|
|
|
|
referrer: ReferrersTable,
|
|
|
|
browser: BrowsersTable,
|
|
|
|
os: OSTable,
|
|
|
|
device: DevicesTable,
|
|
|
|
screen: ScreenTable,
|
|
|
|
country: CountriesTable,
|
|
|
|
language: LanguagesTable,
|
|
|
|
event: EventsTable,
|
|
|
|
query: QueryParametersTable,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function WebsiteMenuView({ websiteId, websiteDomain }) {
|
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
const {
|
|
|
|
resolve,
|
|
|
|
query: { view },
|
|
|
|
} = usePageQuery();
|
|
|
|
|
|
|
|
const items = [
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'url',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.pages),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'referrer',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.referrers),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'browser',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.browsers),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'os',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.os),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'device',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.devices),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'country',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.countries),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'language',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.languages),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'screen',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.screens),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'event',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.events),
|
|
|
|
},
|
|
|
|
{
|
2023-02-11 08:21:50 +01:00
|
|
|
key: 'query',
|
2023-02-04 17:59:52 +01:00
|
|
|
label: formatMessage(labels.query),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const DetailsComponent = views[view];
|
|
|
|
|
|
|
|
return (
|
2023-02-10 12:26:57 +01:00
|
|
|
<Row className={styles.row}>
|
2023-02-10 12:37:06 +01:00
|
|
|
<Column defaultSize={3} className={classNames(styles.col, styles.menu)}>
|
2023-02-11 08:21:50 +01:00
|
|
|
<Link href={resolve({ view: undefined })}>
|
|
|
|
<a>
|
|
|
|
<Flexbox justifyContent="center">
|
|
|
|
<Button variant="quiet">
|
|
|
|
<Icon rotate={180}>
|
|
|
|
<Icons.ArrowRight />
|
|
|
|
</Icon>
|
|
|
|
<Text>{formatMessage(labels.back)}</Text>
|
|
|
|
</Button>
|
|
|
|
</Flexbox>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
<Menu items={items} selectedKey={view}>
|
|
|
|
{({ key, label }) => (
|
|
|
|
<Item key={key} className={styles.item}>
|
|
|
|
<Link href={resolve({ view: key })} shallow={true}>
|
2023-02-10 12:26:57 +01:00
|
|
|
<a>{label}</a>
|
|
|
|
</Link>
|
|
|
|
</Item>
|
2023-02-04 17:59:52 +01:00
|
|
|
)}
|
|
|
|
</Menu>
|
|
|
|
</Column>
|
2023-02-11 08:21:50 +01:00
|
|
|
<Column defaultSize={9} className={classNames(styles.col, styles.data)}>
|
2023-02-04 17:59:52 +01:00
|
|
|
<DetailsComponent
|
|
|
|
websiteId={websiteId}
|
|
|
|
websiteDomain={websiteDomain}
|
|
|
|
height={500}
|
|
|
|
limit={false}
|
|
|
|
animate={false}
|
2023-02-11 08:21:50 +01:00
|
|
|
showFilters={true}
|
|
|
|
virtualize={true}
|
2023-02-04 17:59:52 +01:00
|
|
|
/>
|
|
|
|
</Column>
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
}
|