mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 12:05:41 +01:00
feat: time unit utils
This commit is contained in:
parent
c03bb921d7
commit
a041baad75
3 changed files with 12 additions and 2 deletions
|
|
@ -70,6 +70,7 @@ export const labels = defineMessages({
|
|||
confirmPassword: { id: 'label.confirm-password', defaultMessage: 'Confirm password' },
|
||||
timezone: { id: 'label.timezone', defaultMessage: 'Timezone' },
|
||||
defaultDateRange: { id: 'label.default-date-range', defaultMessage: 'Default date range' },
|
||||
timeUnit: { id: 'label.time-unit', defaultMessage: 'Time Unit' },
|
||||
language: { id: 'label.language', defaultMessage: 'Language' },
|
||||
theme: { id: 'label.theme', defaultMessage: 'Theme' },
|
||||
profile: { id: 'label.profile', defaultMessage: 'Profile' },
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ export const AUTH_TOKEN = 'umami.auth';
|
|||
export const LOCALE_CONFIG = 'umami.locale';
|
||||
export const TIMEZONE_CONFIG = 'umami.timezone';
|
||||
export const DATE_RANGE_CONFIG = 'umami.date-range';
|
||||
export const TIME_UNIT_CONFIG = 'umami.time-range';
|
||||
export const THEME_CONFIG = 'umami.theme';
|
||||
export const DASHBOARD_CONFIG = 'umami.dashboard';
|
||||
export const VERSION_CHECK = 'umami.version-check';
|
||||
|
|
@ -17,6 +18,7 @@ export const DEFAULT_LOCALE = process.env.defaultLocale || 'en-US';
|
|||
export const DEFAULT_THEME = 'light';
|
||||
export const DEFAULT_ANIMATION_DURATION = 300;
|
||||
export const DEFAULT_DATE_RANGE = '24hour';
|
||||
export const DEFAULT_TIME_UNIT = '1hour';
|
||||
export const DEFAULT_WEBSITE_LIMIT = 10;
|
||||
export const DEFAULT_RESET_DATE = '2000-01-01';
|
||||
export const DEFAULT_PAGE_SIZE = 10;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { create } from 'zustand';
|
||||
import {
|
||||
DATE_RANGE_CONFIG,
|
||||
DEFAULT_DATE_RANGE,
|
||||
DEFAULT_LOCALE,
|
||||
DEFAULT_THEME,
|
||||
DEFAULT_TIME_UNIT,
|
||||
LOCALE_CONFIG,
|
||||
THEME_CONFIG,
|
||||
TIME_UNIT_CONFIG,
|
||||
TIMEZONE_CONFIG,
|
||||
} from 'lib/constants';
|
||||
import { getItem } from 'next-basics';
|
||||
import { getTimezone } from 'lib/date';
|
||||
import { getItem } from 'next-basics';
|
||||
import { create } from 'zustand';
|
||||
|
||||
function getDefaultTheme() {
|
||||
return typeof window !== 'undefined'
|
||||
|
|
@ -24,6 +26,7 @@ const initialState = {
|
|||
theme: getItem(THEME_CONFIG) || getDefaultTheme() || DEFAULT_THEME,
|
||||
timezone: getItem(TIMEZONE_CONFIG) || getTimezone(),
|
||||
dateRange: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE,
|
||||
timeUnit: getItem(TIME_UNIT_CONFIG) || DEFAULT_TIME_UNIT,
|
||||
shareToken: null,
|
||||
user: null,
|
||||
config: null,
|
||||
|
|
@ -59,4 +62,8 @@ export function setDateRange(dateRange: string | object) {
|
|||
store.setState({ dateRange });
|
||||
}
|
||||
|
||||
export function setTimeUnit(timeUnit: string | object) {
|
||||
store.setState({ timeUnit });
|
||||
}
|
||||
|
||||
export default store;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue