mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Fixed filter tags. Added clear all option.
This commit is contained in:
parent
4a689bf294
commit
638a674e99
@ -83,6 +83,7 @@ export const labels = defineMessages({
|
|||||||
filterRaw: { id: 'label.filter-raw', defaultMessage: 'Raw' },
|
filterRaw: { id: 'label.filter-raw', defaultMessage: 'Raw' },
|
||||||
views: { id: 'label.views', defaultMessage: 'View' },
|
views: { id: 'label.views', defaultMessage: 'View' },
|
||||||
none: { id: 'label.none', defaultMessage: 'None' },
|
none: { id: 'label.none', defaultMessage: 'None' },
|
||||||
|
clearAll: { id: 'label.clear-all', defaultMessage: 'Clear all' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const messages = defineMessages({
|
export const messages = defineMessages({
|
||||||
|
@ -1,22 +1,29 @@
|
|||||||
|
import { useIntl } from 'react-intl';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { safeDecodeURI } from 'next-basics';
|
import { safeDecodeURI } from 'next-basics';
|
||||||
import { Button, Icon, Icons } from 'react-basics';
|
import { Button, Icon, Icons, Text } from 'react-basics';
|
||||||
|
import { labels } from 'components/messages';
|
||||||
import styles from './FilterTags.module.css';
|
import styles from './FilterTags.module.css';
|
||||||
|
|
||||||
export default function FilterTags({ className, params, onClick }) {
|
export default function FilterTags({ className, params, onClick }) {
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
if (Object.keys(params).filter(key => params[key]).length === 0) {
|
if (Object.keys(params).filter(key => params[key]).length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.filters, 'col-12', className)}>
|
<div className={classNames(styles.filters, className)}>
|
||||||
{Object.keys(params).map(key => {
|
{Object.keys(params).map(key => {
|
||||||
if (!params[key]) {
|
if (!params[key]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div key={key} className={styles.tag}>
|
<div key={key} className={styles.tag}>
|
||||||
<Button onClick={() => onClick(key)} variant="action" iconRight>
|
<Button onClick={() => onClick(key)} variant="primary" size="sm">
|
||||||
{`${key}: ${safeDecodeURI(params[key])}`}
|
<Text>
|
||||||
|
<b>{`${key}`}</b> — {`${safeDecodeURI(params[key])}`}
|
||||||
|
</Text>
|
||||||
<Icon>
|
<Icon>
|
||||||
<Icons.Close />
|
<Icons.Close />
|
||||||
</Icon>
|
</Icon>
|
||||||
@ -24,6 +31,12 @@ export default function FilterTags({ className, params, onClick }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
<Button size="sm" variant="quiet" onClick={() => onClick(null)}>
|
||||||
|
<Icon>
|
||||||
|
<Icons.Close />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.clearAll)}</Text>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export default function WebsiteChart({
|
|||||||
const {
|
const {
|
||||||
router,
|
router,
|
||||||
resolve,
|
resolve,
|
||||||
query: { url, referrer, os, browser, device, country },
|
query: { view, url, referrer, os, browser, device, country },
|
||||||
} = usePageQuery();
|
} = usePageQuery();
|
||||||
const { get, useQuery } = useApi();
|
const { get, useQuery } = useApi();
|
||||||
|
|
||||||
@ -67,7 +67,11 @@ export default function WebsiteChart({
|
|||||||
}, [data, startDate, endDate, unit]);
|
}, [data, startDate, endDate, unit]);
|
||||||
|
|
||||||
function handleCloseFilter(param) {
|
function handleCloseFilter(param) {
|
||||||
router.push(resolve({ [param]: undefined }));
|
if (param === null) {
|
||||||
|
router.push(`/websites/${websiteId}/?view=${view}`);
|
||||||
|
} else {
|
||||||
|
router.push(resolve({ [param]: undefined }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDateChange(value) {
|
async function handleDateChange(value) {
|
||||||
@ -97,11 +101,11 @@ export default function WebsiteChart({
|
|||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<FilterTags
|
|
||||||
params={{ url, referrer, os, browser, device, country }}
|
|
||||||
onClick={handleCloseFilter}
|
|
||||||
/>
|
|
||||||
</WebsiteHeader>
|
</WebsiteHeader>
|
||||||
|
<FilterTags
|
||||||
|
params={{ url, referrer, os, browser, device, country }}
|
||||||
|
onClick={handleCloseFilter}
|
||||||
|
/>
|
||||||
<StickyHeader stickyClassName={styles.sticky} enabled={stickyHeader}>
|
<StickyHeader stickyClassName={styles.sticky} enabled={stickyHeader}>
|
||||||
<Row className={styles.header}>
|
<Row className={styles.header}>
|
||||||
<Column xs={12} sm={12} md={12} defaultSize={10}>
|
<Column xs={12} sm={12} md={12} defaultSize={10}>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||||
|
import { Row, Column } from 'react-basics';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { subMinutes, startOfMinute } from 'date-fns';
|
import { subMinutes, startOfMinute } from 'date-fns';
|
||||||
import firstBy from 'thenby';
|
import firstBy from 'thenby';
|
||||||
import Page from 'components/layout/Page';
|
import Page from 'components/layout/Page';
|
||||||
import GridLayout, { GridRow, GridColumn } from 'components/layout/GridLayout';
|
|
||||||
import RealtimeChart from 'components/metrics/RealtimeChart';
|
import RealtimeChart from 'components/metrics/RealtimeChart';
|
||||||
import RealtimeLog from 'components/metrics/RealtimeLog';
|
import RealtimeLog from 'components/metrics/RealtimeLog';
|
||||||
import RealtimeHeader from 'components/metrics/RealtimeHeader';
|
import RealtimeHeader from 'components/metrics/RealtimeHeader';
|
||||||
@ -129,29 +129,27 @@ export default function RealtimeDashboard() {
|
|||||||
<div className={styles.chart}>
|
<div className={styles.chart}>
|
||||||
<RealtimeChart data={realtimeData} unit="minute" records={REALTIME_RANGE} />
|
<RealtimeChart data={realtimeData} unit="minute" records={REALTIME_RANGE} />
|
||||||
</div>
|
</div>
|
||||||
<GridLayout>
|
<Row>
|
||||||
<GridRow>
|
<Column xs={12} lg={4}>
|
||||||
<GridColumn xs={12} lg={4}>
|
<RealtimeViews websiteId={websiteId} data={realtimeData} websites={websites} />
|
||||||
<RealtimeViews websiteId={websiteId} data={realtimeData} websites={websites} />
|
</Column>
|
||||||
</GridColumn>
|
<Column xs={12} lg={8}>
|
||||||
<GridColumn xs={12} lg={8}>
|
<RealtimeLog websiteId={websiteId} data={realtimeData} websites={websites} />
|
||||||
<RealtimeLog websiteId={websiteId} data={realtimeData} websites={websites} />
|
</Column>
|
||||||
</GridColumn>
|
</Row>
|
||||||
</GridRow>
|
<Row>
|
||||||
<GridRow>
|
<Column xs={12} lg={4}>
|
||||||
<GridColumn xs={12} lg={4}>
|
<DataTable
|
||||||
<DataTable
|
title={<FormattedMessage id="metrics.countries" defaultMessage="Countries" />}
|
||||||
title={<FormattedMessage id="metrics.countries" defaultMessage="Countries" />}
|
metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
|
||||||
metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
|
data={countries}
|
||||||
data={countries}
|
renderLabel={renderCountryName}
|
||||||
renderLabel={renderCountryName}
|
/>
|
||||||
/>
|
</Column>
|
||||||
</GridColumn>
|
<Column xs={12} lg={8}>
|
||||||
<GridColumn xs={12} lg={8}>
|
<WorldMap data={countries} />
|
||||||
<WorldMap data={countries} />
|
</Column>
|
||||||
</GridColumn>
|
</Row>
|
||||||
</GridRow>
|
|
||||||
</GridLayout>
|
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user