mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/components/common/Pager.module.css # src/lib/constants.ts # src/lib/yup.ts # src/pages/api/teams/[id]/users/index.ts # src/pages/api/websites/[id]/reports.ts
This commit is contained in:
commit
40cfcd41e9
19 changed files with 135 additions and 92 deletions
|
|
@ -30,7 +30,7 @@ export const FILTER_DAY = 'filter-day';
|
|||
export const FILTER_RANGE = 'filter-range';
|
||||
export const FILTER_REFERRERS = 'filter-referrers';
|
||||
export const FILTER_PAGES = 'filter-pages';
|
||||
|
||||
export const UNIT_TYPES = ['year', 'month', 'hour', 'day'];
|
||||
export const EVENT_COLUMNS = ['url', 'referrer', 'title', 'query', 'event'];
|
||||
|
||||
export const SESSION_COLUMNS = [
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ export function parseDateRange(value, locale = 'en-US') {
|
|||
const endDate = new Date(+endTime);
|
||||
|
||||
return {
|
||||
...getDateRangeValues(startDate, endDate),
|
||||
startDate,
|
||||
endDate,
|
||||
unit: getMinimumUnit(startDate, endDate),
|
||||
value,
|
||||
};
|
||||
}
|
||||
|
|
@ -255,14 +257,6 @@ export function getMinimumUnit(startDate, endDate) {
|
|||
return 'year';
|
||||
}
|
||||
|
||||
export function getDateRangeValues(startDate, endDate) {
|
||||
return {
|
||||
startDate: startOfDay(startDate),
|
||||
endDate: endOfDay(endDate),
|
||||
unit: getMinimumUnit(startDate, endDate),
|
||||
};
|
||||
}
|
||||
|
||||
export function getDateFromString(str) {
|
||||
const [ymd, hms] = str.split(' ');
|
||||
const [year, month, day] = ymd.split('-');
|
||||
|
|
|
|||
15
src/lib/yup.ts
Normal file
15
src/lib/yup.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import moment from 'moment';
|
||||
import * as yup from 'yup';
|
||||
import { UNIT_TYPES } from './constants';
|
||||
|
||||
export const TimezoneTest = yup.string().test(
|
||||
'timezone',
|
||||
() => `Invalid timezone`,
|
||||
value => moment.tz.zone(value) !== null,
|
||||
);
|
||||
|
||||
export const UnitTypeTest = yup.string().test(
|
||||
'unit',
|
||||
() => `Invalid unit`,
|
||||
value => UNIT_TYPES.includes(value),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue