mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 20:15: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' },
|
confirmPassword: { id: 'label.confirm-password', defaultMessage: 'Confirm password' },
|
||||||
timezone: { id: 'label.timezone', defaultMessage: 'Timezone' },
|
timezone: { id: 'label.timezone', defaultMessage: 'Timezone' },
|
||||||
defaultDateRange: { id: 'label.default-date-range', defaultMessage: 'Default date range' },
|
defaultDateRange: { id: 'label.default-date-range', defaultMessage: 'Default date range' },
|
||||||
|
timeUnit: { id: 'label.time-unit', defaultMessage: 'Time Unit' },
|
||||||
language: { id: 'label.language', defaultMessage: 'Language' },
|
language: { id: 'label.language', defaultMessage: 'Language' },
|
||||||
theme: { id: 'label.theme', defaultMessage: 'Theme' },
|
theme: { id: 'label.theme', defaultMessage: 'Theme' },
|
||||||
profile: { id: 'label.profile', defaultMessage: 'Profile' },
|
profile: { id: 'label.profile', defaultMessage: 'Profile' },
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ export const AUTH_TOKEN = 'umami.auth';
|
||||||
export const LOCALE_CONFIG = 'umami.locale';
|
export const LOCALE_CONFIG = 'umami.locale';
|
||||||
export const TIMEZONE_CONFIG = 'umami.timezone';
|
export const TIMEZONE_CONFIG = 'umami.timezone';
|
||||||
export const DATE_RANGE_CONFIG = 'umami.date-range';
|
export const DATE_RANGE_CONFIG = 'umami.date-range';
|
||||||
|
export const TIME_UNIT_CONFIG = 'umami.time-range';
|
||||||
export const THEME_CONFIG = 'umami.theme';
|
export const THEME_CONFIG = 'umami.theme';
|
||||||
export const DASHBOARD_CONFIG = 'umami.dashboard';
|
export const DASHBOARD_CONFIG = 'umami.dashboard';
|
||||||
export const VERSION_CHECK = 'umami.version-check';
|
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_THEME = 'light';
|
||||||
export const DEFAULT_ANIMATION_DURATION = 300;
|
export const DEFAULT_ANIMATION_DURATION = 300;
|
||||||
export const DEFAULT_DATE_RANGE = '24hour';
|
export const DEFAULT_DATE_RANGE = '24hour';
|
||||||
|
export const DEFAULT_TIME_UNIT = '1hour';
|
||||||
export const DEFAULT_WEBSITE_LIMIT = 10;
|
export const DEFAULT_WEBSITE_LIMIT = 10;
|
||||||
export const DEFAULT_RESET_DATE = '2000-01-01';
|
export const DEFAULT_RESET_DATE = '2000-01-01';
|
||||||
export const DEFAULT_PAGE_SIZE = 10;
|
export const DEFAULT_PAGE_SIZE = 10;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
import { create } from 'zustand';
|
|
||||||
import {
|
import {
|
||||||
DATE_RANGE_CONFIG,
|
DATE_RANGE_CONFIG,
|
||||||
DEFAULT_DATE_RANGE,
|
DEFAULT_DATE_RANGE,
|
||||||
DEFAULT_LOCALE,
|
DEFAULT_LOCALE,
|
||||||
DEFAULT_THEME,
|
DEFAULT_THEME,
|
||||||
|
DEFAULT_TIME_UNIT,
|
||||||
LOCALE_CONFIG,
|
LOCALE_CONFIG,
|
||||||
THEME_CONFIG,
|
THEME_CONFIG,
|
||||||
|
TIME_UNIT_CONFIG,
|
||||||
TIMEZONE_CONFIG,
|
TIMEZONE_CONFIG,
|
||||||
} from 'lib/constants';
|
} from 'lib/constants';
|
||||||
import { getItem } from 'next-basics';
|
|
||||||
import { getTimezone } from 'lib/date';
|
import { getTimezone } from 'lib/date';
|
||||||
|
import { getItem } from 'next-basics';
|
||||||
|
import { create } from 'zustand';
|
||||||
|
|
||||||
function getDefaultTheme() {
|
function getDefaultTheme() {
|
||||||
return typeof window !== 'undefined'
|
return typeof window !== 'undefined'
|
||||||
|
|
@ -24,6 +26,7 @@ const initialState = {
|
||||||
theme: getItem(THEME_CONFIG) || getDefaultTheme() || DEFAULT_THEME,
|
theme: getItem(THEME_CONFIG) || getDefaultTheme() || DEFAULT_THEME,
|
||||||
timezone: getItem(TIMEZONE_CONFIG) || getTimezone(),
|
timezone: getItem(TIMEZONE_CONFIG) || getTimezone(),
|
||||||
dateRange: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE,
|
dateRange: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE,
|
||||||
|
timeUnit: getItem(TIME_UNIT_CONFIG) || DEFAULT_TIME_UNIT,
|
||||||
shareToken: null,
|
shareToken: null,
|
||||||
user: null,
|
user: null,
|
||||||
config: null,
|
config: null,
|
||||||
|
|
@ -59,4 +62,8 @@ export function setDateRange(dateRange: string | object) {
|
||||||
store.setState({ dateRange });
|
store.setState({ dateRange });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setTimeUnit(timeUnit: string | object) {
|
||||||
|
store.setState({ timeUnit });
|
||||||
|
}
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue