📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
display period hotkeys
Blue Mouse2a80d793605e
diff --git a/web/app/modals/ViewProjectHotkeys.tsx b/web/app/modals/ViewProjectHotkeys.tsxindex dbce36eca..d94028674 100644--- a/web/app/modals/ViewProjectHotkeys.tsx+++ b/web/app/modals/ViewProjectHotkeys.tsx@@ -3,6 +3,7 @@ import _map from 'lodash/map'import { useMemo } from 'react'import { useTranslation } from 'react-i18next'+import { Period } from '~/lib/constants'import { Badge } from '~/ui/Badge'import Modal from '~/ui/Modal'@@ -16,20 +17,35 @@ interface HotkeysListProps {hotkeys: Record<string, string>}+export const PERIOD_HOTKEYS_MAP: Record<Period, string> = {+ '1h': 'H',+ today: 'T',+ yesterday: 'Y',+ '1d': 'D',+ '7d': 'W',+ '4w': 'M',+ '3M': 'Q',+ '12M': 'L',+ '24M': 'Z',+ all: 'A',+ custom: 'U',+ compare: 'C',+}+const getHotkeys = (t: TFunction) => ({[t('modals.shortcuts.timebuckets')]: {- [t('project.thisHour')]: 'H',- [t('project.today')]: 'T',- [t('project.yesterday')]: 'Y',- [t('project.last24h')]: 'D',- [t('project.lastXDays', { amount: 7 })]: 'W',- [t('project.lastXWeeks', { amount: 4 })]: 'M',- [t('project.lastXMonths', { amount: 3 })]: 'Q',- [t('project.lastXMonths', { amount: 12 })]: 'L',- [t('project.lastXMonths', { amount: 24 })]: 'Z',- [t('project.all')]: 'A',- [t('project.compare')]: 'C',- [t('project.custom')]: 'U',+ [t('project.thisHour')]: PERIOD_HOTKEYS_MAP['1h'],+ [t('project.today')]: PERIOD_HOTKEYS_MAP.today,+ [t('project.yesterday')]: PERIOD_HOTKEYS_MAP.yesterday,+ [t('project.last24h')]: PERIOD_HOTKEYS_MAP['1d'],+ [t('project.lastXDays', { amount: 7 })]: PERIOD_HOTKEYS_MAP['7d'],+ [t('project.lastXWeeks', { amount: 4 })]: PERIOD_HOTKEYS_MAP['4w'],+ [t('project.lastXMonths', { amount: 3 })]: PERIOD_HOTKEYS_MAP['3M'],+ [t('project.lastXMonths', { amount: 12 })]: PERIOD_HOTKEYS_MAP['12M'],+ [t('project.lastXMonths', { amount: 24 })]: PERIOD_HOTKEYS_MAP['24M'],+ [t('project.all')]: PERIOD_HOTKEYS_MAP.all,+ [t('project.compare')]: PERIOD_HOTKEYS_MAP.compare,+ [t('project.custom')]: PERIOD_HOTKEYS_MAP.custom,},[t('modals.shortcuts.tabs')]: {[t('dashboard.traffic')]: 'Shift + T',diff --git a/web/app/pages/Project/View/components/TBPeriodSelector.tsx b/web/app/pages/Project/View/components/TBPeriodSelector.tsxindex a75b10d45..b2b817e73 100644--- a/web/app/pages/Project/View/components/TBPeriodSelector.tsx+++ b/web/app/pages/Project/View/components/TBPeriodSelector.tsx@@ -7,16 +7,18 @@ import { CalendarIcon } from 'lucide-react'import React, { memo, Fragment, useMemo } from 'react'import { useTranslation } from 'react-i18next'-import { TimeBucket, VALID_TIME_BUCKETS } from '~/lib/constants'+import { TBPeriodPairsProps, TimeBucket, VALID_TIME_BUCKETS } from '~/lib/constants'+import { PERIOD_HOTKEYS_MAP } from '~/modals/ViewProjectHotkeys'+import { Badge } from '~/ui/Badge'import { useViewProjectContext } from '../ViewProject'interface TBPeriodSelectorProps {title: string | number | React.ReactNode- items: any[]+ items: TBPeriodPairsProps[]/* (function): A function that is called when an item is selected. */- onSelect: (item: any, e?: React.MouseEvent<HTMLElement>) => void | null- activePeriod: any+ onSelect: (item: TBPeriodPairsProps, e?: React.MouseEvent<HTMLElement>) => void | null+ activePeriod?: TBPeriodPairsPropsclasses?: {timeBucket?: stringperiods?: string@@ -104,13 +106,14 @@ const TBPeriodSelector = ({ items, title, onSelect, activePeriod, classes }: TBPkey={item.label}onClick={(e: React.MouseEvent<HTMLElement>) => onSelect(item, e)}className={cx(- 'block cursor-pointer rounded-md px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700',+ 'flex cursor-pointer items-center justify-between space-x-1 rounded-md p-2 text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700',{'cursor-wait': dataLoading,},)}>- {item.dropdownLabel || item.label}+ <span>{item.dropdownLabel || item.label}</span>+ <Badge colour='slate' label={PERIOD_HOTKEYS_MAP[item.period]} /></PopoverButton>))}</ul>