Support contains queries in overview page.

This commit is contained in:
Mike Cao 2024-03-27 02:17:55 -07:00
commit d945ed3a23
12 changed files with 75 additions and 105 deletions

View file

@ -211,7 +211,7 @@ const ResultsMenu = ({ values, type, isLoading, onSelect }) => {
}
if (!values?.length) {
return <h1>poop</h1>;
return null;
}
return (

View file

@ -1,5 +1,4 @@
.form {
position: absolute;
background: var(--base50);
min-width: 300px;
padding: 20px;

View file

@ -35,7 +35,7 @@ export function ShareUrl({
const url = `${hostUrl || process.env.hostUrl || window?.location.origin}${
process.env.basePath
}/share/${id}/${encodeURIComponent(domain)}`;
}/share/${id}/${domain}`;
const handleGenerate = () => {
setId(generateId());

View file

@ -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>
);

View file

@ -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)}