Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

make panels larger, display the line fill indicator in the background

Blue Mouse94dd4a52894a
diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsx
index f63e4f204..fe10b4f5e 100644
--- a/web/app/pages/Project/View/Panels.tsx
+++ b/web/app/pages/Project/View/Panels.tsx
@@ -42,7 +42,6 @@ import Chart from '~/ui/Chart'
import Sort from '~/ui/icons/Sort'
import Spin from '~/ui/icons/Spin'
import Modal from '~/ui/Modal'
-import Progress from '~/ui/Progress'
import { nFormatter } from '~/utils/generic'
import CustomEventsDropdown from './components/CustomEventsDropdown'
@@ -52,8 +51,8 @@ import { Customs, Filter, Properties } from './interfaces/traffic'
import { useViewProjectContext } from './ViewProject'
import { iconClassName } from './ViewProject.helpers'
-const ENTRIES_PER_PANEL = 5
-const ENTRIES_PER_CUSTOM_EVENTS_PANEL = 6
+const ENTRIES_PER_PANEL = 8
+const ENTRIES_PER_CUSTOM_EVENTS_PANEL = 8
const PANELS_WITH_BARS = ['cc', 'rg', 'ct', 'ce', 'os', 'br', 'dv', 'pg']
@@ -100,7 +99,6 @@ const removeDuplicates = (arr: any[], keys: string[]) => {
interface PanelContainerProps {
name: React.ReactNode
children?: React.ReactNode
- noSwitch?: boolean
icon?: React.ReactNode
type: string
onExpandClick?: () => void
@@ -111,11 +109,9 @@ interface PanelContainerProps {
isCustomContent?: boolean
}
-// noSwitch - 'previous' and 'next' buttons
const PanelContainer = ({
name,
children,
- noSwitch,
icon,
type,
activeFragment = 0,
@@ -127,10 +123,9 @@ const PanelContainer = ({
}: PanelContainerProps) => (
<div
className={cx(
- 'relative max-h-96 min-h-[17rem] overflow-hidden rounded-lg border border-gray-300 bg-white px-4 pt-5 sm:px-6 dark:border-slate-800/60 dark:bg-slate-800/25',
+ 'h-96 overflow-hidden rounded-lg border border-gray-300 bg-white px-4 py-5 dark:border-slate-800/60 dark:bg-slate-800/25',
{
- 'pb-12': !noSwitch,
- 'pb-5': noSwitch,
+ 'col-span-2': type === 'ce',
},
)}
>
@@ -1499,43 +1494,17 @@ const Panel = ({
}: PanelProps) => {
const { dataLoading, activeTab } = useViewProjectContext()
const { t } = useTranslation('common')
- const [page, setPage] = useState(0)
- const currentIndex = page * ENTRIES_PER_PANEL
const total = useMemo(() => _reduce(data, (prev, curr) => prev + curr.count, 0), [data])
- const totalPages = _ceil(_size(data) / ENTRIES_PER_PANEL)
- const entries = useMemo(() => _orderBy(data, 'count', 'desc'), [data])
- const entriesToDisplay = _slice(entries, currentIndex, currentIndex + ENTRIES_PER_PANEL)
const [activeFragment, setActiveFragment] = useState(0)
const [isModalOpen, setIsModalOpen] = useState(false)
const [isReversedUserFlow, setIsReversedUserFlow] = useState(false)
- const canGoPrev = () => page > 0
- const canGoNext = () => page < _floor((_size(entries) - 1) / ENTRIES_PER_PANEL)
const navigate = useNavigate()
- useEffect(() => {
- const sizeKeys = _size(entries)
-
- if (currentIndex > sizeKeys) {
- setPage(_floor(sizeKeys / ENTRIES_PER_PANEL))
- }
- }, [currentIndex, entries])
-
- useEffect(() => {
- setPage(0)
+ const entriesToDisplay = useMemo(() => {
+ const orderedData = _orderBy(data, 'count', 'desc')
+ return _slice(orderedData, 0, ENTRIES_PER_PANEL)
}, [data])
- const onPrevious = () => {
- if (canGoPrev()) {
- setPage(page - 1)
- }
- }
-
- const onNext = () => {
- if (canGoNext()) {
- setPage(page + 1)
- }
- }
-
const _setActiveFragment = (index: number) => {
setActiveFragment(index)
@@ -1680,112 +1649,76 @@ const Panel = ({
{_isEmpty(data) ? (
<p className='mt-1 text-base text-gray-700 dark:text-gray-300'>{t('project.noParamData')}</p>
) : (
- _map(entriesToDisplay, (entry) => {
- const { count, name: entryName, ...rest } = entry
- const perc = _round((count / total) * 100, 2)
- const rowData = rowMapper(entry)
- const valueData = valueMapper(count)
-
- const link = getFilterLink(id, entryName)
-
- return (
- <Fragment key={`${id}-${entryName}-${Object.values(rest).join('-')}`}>
- <FilterWrapper
- as={link ? 'Link' : 'div'}
- to={link}
- className={cx('mt-[0.32rem] flex justify-between rounded-sm first:mt-0 dark:text-gray-50', {
- 'group cursor-pointer hover:bg-gray-100 hover:dark:bg-slate-700': !hideFilters && !dataLoading,
- 'cursor-wait': dataLoading,
- })}
- >
- {linkContent ? (
- <a
- className={cx(
- 'scrollbar-thin flex flex-1 items-center overflow-hidden text-clip whitespace-nowrap text-blue-600 hover:underline dark:text-blue-500',
- {
- capitalize,
- },
- )}
- href={rowData as string}
- target='_blank'
- rel='noopener noreferrer nofollow'
- aria-label={`${rowData} (opens in a new tab)`}
- >
- <span className='flex items-center truncate'>{rowData}</span>
- </a>
- ) : (
- <span
- className={cx(
- 'scrollbar-thin flex flex-1 items-center overflow-hidden text-clip whitespace-nowrap',
- {
- capitalize,
- },
+ <>
+ <div className='mb-2 flex items-center justify-between px-1 py-1'>
+ <span className='text-sm font-medium text-gray-600 dark:text-gray-400'>{t('project.source')}</span>
+ <span className='text-sm font-medium text-gray-600 dark:text-gray-400'>{t('project.visitors')}</span>
+ </div>
+
+ <div className='space-y-0.5'>
+ {_map(entriesToDisplay, (entry) => {
+ const { count, name: entryName, ...rest } = entry
+ const perc = _round((count / total) * 100, 2)
+ const rowData = rowMapper(entry)
+ const valueData = valueMapper(count)
+
+ const link = getFilterLink(id, entryName)
+
+ return (
+ <FilterWrapper
+ key={`${id}-${entryName}-${Object.values(rest).join('-')}`}
+ as={link ? 'Link' : 'div'}
+ to={link}
+ className={cx('relative flex items-center justify-between rounded-sm px-1 py-1.5 dark:text-gray-50', {
+ 'group cursor-pointer hover:bg-gray-50 hover:dark:bg-slate-800': !hideFilters && !dataLoading,
+ 'cursor-wait': dataLoading,
+ })}
+ >
+ <div
+ className='absolute inset-0 rounded-sm bg-blue-50 dark:bg-blue-900/10'
+ style={{ width: `${perc}%` }}
+ />
+
+ <div className='relative z-10 flex min-w-0 flex-1 items-center'>
+ {linkContent ? (
+ <a
+ className={cx(
+ 'flex items-center truncate text-sm text-blue-600 hover:underline dark:text-blue-500',
+ {
+ capitalize,
+ },
+ )}
+ href={rowData as string}
+ target='_blank'
+ rel='noopener noreferrer nofollow'
+ aria-label={`${rowData} (opens in a new tab)`}
+ >
+ {rowData}
+ </a>
+ ) : (
+ <span
+ className={cx('flex items-center truncate text-sm text-gray-900 dark:text-gray-100', {
+ capitalize,
+ })}
+ >
+ {rowData}
+ </span>
)}
- >
- <span className='flex items-center truncate'>{rowData}</span>
- </span>
- )}
- <div className='flex min-w-fit items-center pl-2'>
- <span className='mr-1 hidden text-gray-500 group-hover:inline dark:text-gray-200'>
- ({_round((count / total) * 100, 2)}%)
- </span>
- <span className='dark:text-gray-50'>
- {activeTab === PROJECT_TABS.traffic ? nFormatter(valueData, 1) : valueData}
- </span>
- </div>
- </FilterWrapper>
- <Progress now={perc} />
- </Fragment>
- )
- })
- )}
- {/* for pagination in tabs */}
- {_size(entries) > ENTRIES_PER_PANEL ? (
- <div className='absolute bottom-0 w-[calc(100%-2rem)] sm:w-[calc(100%-3rem)]'>
- <div className='mb-2 flex justify-between select-none'>
- <div>
- <span className='text-xs font-light text-gray-500 lowercase dark:text-gray-200'>
- {_size(entries)} {t('project.results')}
- </span>
- <span className='text-xs font-light text-gray-500 dark:text-gray-200'>
- . {t('project.page')} {page + 1} / {totalPages}
- </span>
- </div>
- <div className='flex w-[4.5rem] justify-between'>
- <Button
- className={cx(
- 'border border-gray-300 px-1.5 py-0.5 font-light text-gray-500 dark:border-slate-800/50 dark:bg-slate-800 dark:text-gray-200',
- {
- 'cursor-not-allowed opacity-50': !canGoPrev(),
- 'hover:bg-gray-100 hover:dark:bg-slate-700': canGoPrev(),
- },
- )}
- type='button'
- onClick={onPrevious}
- disabled={!canGoPrev()}
- focus={false}
- >
- <ArrowLongLeftIcon className='h-5 w-5' />
- </Button>
- <Button
- className={cx(
- 'border border-gray-300 px-1.5 py-0.5 font-light text-gray-500 dark:border-slate-800/50 dark:bg-slate-800 dark:text-gray-200',
- {
- 'cursor-not-allowed opacity-50': !canGoNext(),
- 'hover:bg-gray-100 hover:dark:bg-slate-700': canGoNext(),
- },
- )}
- onClick={onNext}
- disabled={!canGoNext()}
- type='button'
- focus={false}
- >
- <ArrowLongRightIcon className='h-5 w-5' />
- </Button>
- </div>
+ </div>
+ <div className='relative z-10 flex min-w-fit items-center justify-end pl-4'>
+ <span className='mr-2 hidden text-xs text-gray-500 group-hover:inline dark:text-gray-400'>
+ ({perc}%)
+ </span>
+ <span className='text-sm font-medium text-gray-900 dark:text-gray-50'>
+ {activeTab === PROJECT_TABS.traffic ? nFormatter(valueData, 1) : valueData}
+ </span>
+ </div>
+ </FilterWrapper>
+ )
+ })}
</div>
- </div>
- ) : null}
+ </>
+ )}
{/* PAGE - User flow modal */}
{id === 'pg' ? (
@@ -1910,7 +1843,7 @@ const MetadataPanel = ({ metadata }: MetadataPanelProps) => {
return (
<div className='col-span-full'>
- <PanelContainer name={t('project.metadata')} type='metadata' noSwitch>
+ <PanelContainer name={t('project.metadata')} type='metadata'>
<div className='overflow-y-auto'>
<table className='w-full border-separate border-spacing-y-1'>
<thead>
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index bee48b71e..537c561c1 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -3350,7 +3350,7 @@ const ViewProject = () => {
/>
) : null}
<Filters tnMapping={tnMapping} />
- <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
+ <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2'>
{!_isEmpty(activeError?.params)
? _map(ERROR_PANELS_ORDER, (type: keyof typeof tnMapping) => {
const panelName = tnMapping[type]
@@ -3659,7 +3659,7 @@ const ViewProject = () => {
<LoadingBar />
</div>
) : null}
- <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
+ <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2'>
{!_isEmpty(panelsData.types)
? _map(TRAFFIC_PANELS_ORDER, (type: keyof typeof tnMapping) => {
const panelName = tnMapping[type]
@@ -3982,7 +3982,7 @@ const ViewProject = () => {
<LoadingBar />
</div>
) : null}
- <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
+ <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2'>
{!_isEmpty(panelsDataPerf.types)
? _map(PERFORMANCE_PANELS_ORDER, (type: keyof typeof tnMapping) => {
const panelName = tnMapping[type]
diff --git a/web/app/pages/Project/View/components/ProjectDropdown.tsx b/web/app/pages/Project/View/components/ProjectDropdown.tsx
index 25e690060..4cc871d64 100644
--- a/web/app/pages/Project/View/components/ProjectDropdown.tsx
+++ b/web/app/pages/Project/View/components/ProjectDropdown.tsx
@@ -47,7 +47,7 @@ const ProjectDropdown = <T extends string = string>({
headless
buttonClassName='cursor-pointer !p-0 text-lg font-semibold flex items-center text-gray-900 dark:text-gray-50'
className='relative inline-block'
- menuItemsClassName='absolute top-4 left-5 z-10 mt-2 max-h-[200px] !min-w-[220px] overflow-auto'
+ menuItemsClassName='absolute top-4 left-5 z-20 mt-2 max-h-[200px] !min-w-[220px] overflow-auto'
chevron='mini'
/>
)