mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
Support contains queries in overview page.
This commit is contained in:
commit
d945ed3a23
12 changed files with 75 additions and 105 deletions
|
|
@ -2,6 +2,7 @@ import { Button, Icon, Icons, Popup, PopupTrigger, Text } from 'react-basics';
|
|||
import PopupForm from 'app/(main)/reports/[reportId]/PopupForm';
|
||||
import FilterSelectForm from 'app/(main)/reports/[reportId]/FilterSelectForm';
|
||||
import { useFields, useMessages, useNavigation } from 'components/hooks';
|
||||
import { OPERATORS } from 'lib/constants';
|
||||
|
||||
export function WebsiteFilterButton({
|
||||
websiteId,
|
||||
|
|
@ -14,8 +15,18 @@ export function WebsiteFilterButton({
|
|||
const { renderUrl, router } = useNavigation();
|
||||
const { fields } = useFields();
|
||||
|
||||
const handleAddFilter = ({ name, value }) => {
|
||||
router.push(renderUrl({ [name]: value }));
|
||||
const handleAddFilter = ({ name, operator, value }) => {
|
||||
let prefix = '';
|
||||
|
||||
if (operator === OPERATORS.notEquals) {
|
||||
prefix = '!';
|
||||
} else if (operator === OPERATORS.contains) {
|
||||
prefix = '~';
|
||||
} else if (operator === OPERATORS.doesNotContain) {
|
||||
prefix = '!~';
|
||||
}
|
||||
|
||||
router.push(renderUrl({ [name]: prefix + value }));
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -26,7 +37,7 @@ export function WebsiteFilterButton({
|
|||
</Icon>
|
||||
<Text>{formatMessage(labels.filter)}</Text>
|
||||
</Button>
|
||||
<Popup position="bottom" alignment="start">
|
||||
<Popup position="bottom" alignment="end">
|
||||
{(close: () => void) => {
|
||||
return (
|
||||
<PopupForm>
|
||||
|
|
@ -37,7 +48,6 @@ export function WebsiteFilterButton({
|
|||
handleAddFilter(value);
|
||||
close();
|
||||
}}
|
||||
allowFilterSelect={false}
|
||||
/>
|
||||
</PopupForm>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -47,24 +47,15 @@ export function WebsiteMetricsBar({
|
|||
value={views.value}
|
||||
change={views.change}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.visitors)}
|
||||
value={visitors.value}
|
||||
change={visitors.change}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.visits)}
|
||||
value={visits.value}
|
||||
change={visits.change}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.viewsPerVisit)}
|
||||
value={visits.value ? views.value / visits.value : 0}
|
||||
change={
|
||||
visits.value && visits.change
|
||||
? views.value / visits.value - diffs.views / diffs.visits
|
||||
: 0
|
||||
}
|
||||
label={formatMessage(labels.visitors)}
|
||||
value={visitors.value}
|
||||
change={visitors.change}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.bounceRate)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue