feat(dashboard): add domain toggle for top sources
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
27b814eba2
commit
3ee3ee902e
@@ -3,12 +3,14 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useEventQueryFilters } from '@/hooks/useEventQueryFilters';
|
import { useEventQueryFilters } from '@/hooks/useEventQueryFilters';
|
||||||
import { cn } from '@/utils/cn';
|
import { cn } from '@/utils/cn';
|
||||||
import { ExternalLinkIcon, FilterIcon } from 'lucide-react';
|
import { ExternalLinkIcon, FilterIcon, Globe2Icon } from 'lucide-react';
|
||||||
|
import { parseAsBoolean, useQueryState } from 'nuqs';
|
||||||
|
|
||||||
import { NOT_SET_VALUE } from '@openpanel/constants';
|
import { NOT_SET_VALUE } from '@openpanel/constants';
|
||||||
import type { IChartType } from '@openpanel/validation';
|
import type { IChartType } from '@openpanel/validation';
|
||||||
|
|
||||||
import { LazyChart } from '../report/chart/LazyChart';
|
import { LazyChart } from '../report/chart/LazyChart';
|
||||||
|
import { Button } from '../ui/button';
|
||||||
import { Tooltiper } from '../ui/tooltip';
|
import { Tooltiper } from '../ui/tooltip';
|
||||||
import { Widget, WidgetBody } from '../widget';
|
import { Widget, WidgetBody } from '../widget';
|
||||||
import { OverviewChartToggle } from './overview-chart-toggle';
|
import { OverviewChartToggle } from './overview-chart-toggle';
|
||||||
@@ -26,7 +28,11 @@ export default function OverviewTopPages({ projectId }: OverviewTopPagesProps) {
|
|||||||
useOverviewOptions();
|
useOverviewOptions();
|
||||||
const [chartType, setChartType] = useState<IChartType>('bar');
|
const [chartType, setChartType] = useState<IChartType>('bar');
|
||||||
const [filters, setFilter] = useEventQueryFilters();
|
const [filters, setFilter] = useEventQueryFilters();
|
||||||
|
const [domain, setDomain] = useQueryState('d', parseAsBoolean);
|
||||||
const renderSerieName = (names: string[]) => {
|
const renderSerieName = (names: string[]) => {
|
||||||
|
if (domain) {
|
||||||
|
return names.join('');
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Tooltiper content={names.join('')} side="left" className="text-left">
|
<Tooltiper content={names.join('')} side="left" className="text-left">
|
||||||
{names[1] || NOT_SET_VALUE}
|
{names[1] || NOT_SET_VALUE}
|
||||||
@@ -198,6 +204,16 @@ export default function OverviewTopPages({ projectId }: OverviewTopPagesProps) {
|
|||||||
<WidgetFooter>
|
<WidgetFooter>
|
||||||
<OverviewDetailsButton chart={widget.chart} />
|
<OverviewDetailsButton chart={widget.chart} />
|
||||||
<OverviewChartToggle {...{ chartType, setChartType }} />
|
<OverviewChartToggle {...{ chartType, setChartType }} />
|
||||||
|
<div className="flex-1"></div>
|
||||||
|
<Button
|
||||||
|
variant={'ghost'}
|
||||||
|
onClick={() => {
|
||||||
|
setDomain((p) => !p);
|
||||||
|
}}
|
||||||
|
icon={Globe2Icon}
|
||||||
|
>
|
||||||
|
{domain ? 'Hide domain' : 'Show domain'}
|
||||||
|
</Button>
|
||||||
</WidgetFooter>
|
</WidgetFooter>
|
||||||
)}
|
)}
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user