mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Added website menu view. Fixed pages filter.
This commit is contained in:
parent
d4437427c4
commit
4a689bf294
13 changed files with 100 additions and 85 deletions
|
|
@ -7,9 +7,7 @@ import { getDateRangeValues } from 'lib/date';
|
|||
import { getDateLocale } from 'lib/lang';
|
||||
import { labels } from 'components/messages';
|
||||
import styles from './DatePickerForm.module.css';
|
||||
|
||||
const FILTER_DAY = 'day';
|
||||
const FILTER_RANGE = 'range';
|
||||
import { FILTER_DAY, FILTER_RANGE } from 'lib/constants';
|
||||
|
||||
export default function DatePickerForm({
|
||||
startDate: defaultStartDate,
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import FilterButtons from 'components/common/FilterButtons';
|
|||
import { urlFilter } from 'lib/filters';
|
||||
import { labels } from 'components/messages';
|
||||
import MetricsTable from './MetricsTable';
|
||||
import { FILTER_COMBINED, FILTER_RAW } from 'lib/constants';
|
||||
|
||||
export const FILTER_COMBINED = 0;
|
||||
export const FILTER_RAW = 1;
|
||||
const filters = {
|
||||
[FILTER_RAW]: null,
|
||||
[FILTER_COMBINED]: urlFilter,
|
||||
};
|
||||
|
||||
export default function PagesTable({ websiteId, showFilters, ...props }) {
|
||||
const [filter, setFilter] = useState(FILTER_COMBINED);
|
||||
|
|
@ -16,11 +19,11 @@ export default function PagesTable({ websiteId, showFilters, ...props }) {
|
|||
const buttons = [
|
||||
{
|
||||
label: formatMessage(labels.filterCombined),
|
||||
value: FILTER_COMBINED,
|
||||
key: FILTER_COMBINED,
|
||||
},
|
||||
{
|
||||
label: formatMessage(labels.filterRaw),
|
||||
value: FILTER_RAW,
|
||||
key: FILTER_RAW,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -30,13 +33,13 @@ export default function PagesTable({ websiteId, showFilters, ...props }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
{showFilters && <FilterButtons buttons={buttons} selected={filter} onClick={setFilter} />}
|
||||
{showFilters && <FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />}
|
||||
<MetricsTable
|
||||
title={formatMessage(labels.pages)}
|
||||
type="url"
|
||||
metric={formatMessage(labels.views)}
|
||||
websiteId={websiteId}
|
||||
dataFilter={filter !== FILTER_RAW ? urlFilter : null}
|
||||
dataFilter={filters[filter]}
|
||||
renderLabel={renderLink}
|
||||
{...props}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
import { useState } from 'react';
|
||||
import { useIntl, defineMessages } from 'react-intl';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { safeDecodeURI } from 'next-basics';
|
||||
import Tag from 'components/common/Tag';
|
||||
import FilterButtons from 'components/common/FilterButtons';
|
||||
import { paramFilter } from 'lib/filters';
|
||||
import { FILTER_RAW, FILTER_COMBINED } from 'lib/constants';
|
||||
import { labels } from 'components/messages';
|
||||
import MetricsTable from './MetricsTable';
|
||||
|
||||
const FILTER_COMBINED = 0;
|
||||
const FILTER_RAW = 1;
|
||||
|
||||
const messages = defineMessages({
|
||||
combined: { id: 'metrics.filter.combined', defaultMessage: 'Combined' },
|
||||
raw: { id: 'metrics.filter.raw', defaultMessage: 'Raw' },
|
||||
views: { id: 'metrics.views', defaultMessage: 'Views' },
|
||||
none: { id: 'label.none', defaultMessage: 'None' },
|
||||
query: { id: 'metrics.query-parameters', defaultMessage: 'Query parameters' },
|
||||
});
|
||||
const filters = {
|
||||
[FILTER_RAW]: null,
|
||||
[FILTER_COMBINED]: paramFilter,
|
||||
};
|
||||
|
||||
export default function QueryParametersTable({ websiteId, showFilters, ...props }) {
|
||||
const [filter, setFilter] = useState(FILTER_COMBINED);
|
||||
|
|
@ -23,22 +19,22 @@ export default function QueryParametersTable({ websiteId, showFilters, ...props
|
|||
|
||||
const buttons = [
|
||||
{
|
||||
label: formatMessage(messages.combined),
|
||||
value: FILTER_COMBINED,
|
||||
label: formatMessage(labels.filterCombined),
|
||||
key: FILTER_COMBINED,
|
||||
},
|
||||
{ label: formatMessage(messages.raw), value: FILTER_RAW },
|
||||
{ label: formatMessage(labels.filterRaw), key: FILTER_RAW },
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
{showFilters && <FilterButtons buttons={buttons} selected={filter} onClick={setFilter} />}
|
||||
{showFilters && <FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />}
|
||||
<MetricsTable
|
||||
{...props}
|
||||
title={formatMessage(messages.query)}
|
||||
title={formatMessage(labels.query)}
|
||||
type="query"
|
||||
metric={formatMessage(messages.views)}
|
||||
metric={formatMessage(labels.views)}
|
||||
websiteId={websiteId}
|
||||
dataFilter={filter !== FILTER_RAW ? paramFilter : null}
|
||||
dataFilter={filters[filter]}
|
||||
renderLabel={({ x, p, v }) =>
|
||||
filter === FILTER_RAW ? (
|
||||
x
|
||||
|
|
|
|||
|
|
@ -54,19 +54,19 @@ export default function RealtimeLog({ data, websites, websiteId }) {
|
|||
const buttons = [
|
||||
{
|
||||
label: <FormattedMessage id="label.all" defaultMessage="All" />,
|
||||
value: TYPE_ALL,
|
||||
key: TYPE_ALL,
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.views" defaultMessage="Views" />,
|
||||
value: TYPE_PAGEVIEW,
|
||||
key: TYPE_PAGEVIEW,
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />,
|
||||
value: TYPE_SESSION,
|
||||
key: TYPE_SESSION,
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.events" defaultMessage="Events" />,
|
||||
value: TYPE_EVENT,
|
||||
key: TYPE_EVENT,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ export default function RealtimeLog({ data, websites, websiteId }) {
|
|||
|
||||
return (
|
||||
<div className={styles.table}>
|
||||
<FilterButtons buttons={buttons} selected={filter} onClick={setFilter} />
|
||||
<FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />
|
||||
<div className={styles.header}>
|
||||
<FormattedMessage id="label.realtime-logs" defaultMessage="Realtime logs" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import firstBy from 'thenby';
|
|||
import { percentFilter } from 'lib/filters';
|
||||
import DataTable from './DataTable';
|
||||
import FilterButtons from 'components/common/FilterButtons';
|
||||
|
||||
const FILTER_REFERRERS = 0;
|
||||
const FILTER_PAGES = 1;
|
||||
import { FILTER_PAGES, FILTER_REFERRERS } from 'lib/constants';
|
||||
|
||||
export default function RealtimeViews({ websiteId, data, websites }) {
|
||||
const { pageviews } = data;
|
||||
|
|
@ -23,11 +21,11 @@ export default function RealtimeViews({ websiteId, data, websites }) {
|
|||
const buttons = [
|
||||
{
|
||||
label: <FormattedMessage id="metrics.referrers" defaultMessage="Referrers" />,
|
||||
value: FILTER_REFERRERS,
|
||||
key: FILTER_REFERRERS,
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.pages" defaultMessage="Pages" />,
|
||||
value: FILTER_PAGES,
|
||||
key: FILTER_PAGES,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -90,7 +88,7 @@ export default function RealtimeViews({ websiteId, data, websites }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<FilterButtons buttons={buttons} selected={filter} onClick={setFilter} />
|
||||
<FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />
|
||||
{filter === FILTER_REFERRERS && (
|
||||
<DataTable
|
||||
title={<FormattedMessage id="metrics.referrers" defaultMessage="Referrers" />}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import FilterButtons from 'components/common/FilterButtons';
|
|||
import FilterLink from 'components/common/FilterLink';
|
||||
import { refFilter } from 'lib/filters';
|
||||
import { labels } from 'components/messages';
|
||||
import { FILTER_COMBINED, FILTER_RAW } from 'lib/constants';
|
||||
|
||||
const FILTER_COMBINED = 0;
|
||||
const FILTER_RAW = 1;
|
||||
const filters = {
|
||||
[FILTER_RAW]: null,
|
||||
[FILTER_COMBINED]: refFilter,
|
||||
};
|
||||
|
||||
export default function ReferrersTable({ websiteId, showFilters, ...props }) {
|
||||
const [filter, setFilter] = useState(FILTER_COMBINED);
|
||||
|
|
@ -16,9 +19,9 @@ export default function ReferrersTable({ websiteId, showFilters, ...props }) {
|
|||
const items = [
|
||||
{
|
||||
label: formatMessage(labels.filterCombined),
|
||||
value: FILTER_COMBINED,
|
||||
key: FILTER_COMBINED,
|
||||
},
|
||||
{ label: formatMessage(labels.filterRaw), value: FILTER_RAW },
|
||||
{ label: formatMessage(labels.filterRaw), key: FILTER_RAW },
|
||||
];
|
||||
|
||||
const renderLink = ({ w: link, x: referrer }) => {
|
||||
|
|
@ -31,14 +34,14 @@ export default function ReferrersTable({ websiteId, showFilters, ...props }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
{showFilters && <FilterButtons items={items} selected={filter} onSelect={setFilter} />}
|
||||
{showFilters && <FilterButtons items={items} selectedKey={filter} onSelect={setFilter} />}
|
||||
<MetricsTable
|
||||
{...props}
|
||||
title={formatMessage(labels.referrers)}
|
||||
type="referrer"
|
||||
metric={formatMessage(labels.views)}
|
||||
websiteId={websiteId}
|
||||
dataFilter={filter !== FILTER_RAW ? refFilter : null}
|
||||
dataFilter={filters[filter]}
|
||||
renderLabel={renderLink}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue