mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Updated filter params logic. Added inline compare dates.
This commit is contained in:
parent
bfdd3f9525
commit
e79f4717e7
17 changed files with 1128 additions and 1057 deletions
|
|
@ -101,13 +101,6 @@ export const OPERATORS = {
|
|||
after: 'af',
|
||||
} as const;
|
||||
|
||||
export const OPERATOR_PREFIXES = {
|
||||
[OPERATORS.equals]: '',
|
||||
[OPERATORS.notEquals]: '!',
|
||||
[OPERATORS.contains]: '~',
|
||||
[OPERATORS.doesNotContain]: '!~',
|
||||
};
|
||||
|
||||
export const DATA_TYPES = {
|
||||
[DATA_TYPE.string]: 'string',
|
||||
[DATA_TYPE.number]: 'number',
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
import { FILTER_COLUMNS, OPERATOR_PREFIXES, OPERATORS } from '@/lib/constants';
|
||||
import { FILTER_COLUMNS, OPERATORS } from '@/lib/constants';
|
||||
import { QueryFilters, QueryOptions } from '@/lib/types';
|
||||
|
||||
export function parseParameterValue(param: any) {
|
||||
if (typeof param === 'string') {
|
||||
const [, prefix, value] = param.match(/^(!~|!|~)?(.*)$/);
|
||||
|
||||
const operator =
|
||||
Object.keys(OPERATOR_PREFIXES).find(key => OPERATOR_PREFIXES[key] === prefix) ||
|
||||
OPERATORS.equals;
|
||||
const [, operator, value] = param.match(/^([a-z]+)\.(.*)/) || [];
|
||||
|
||||
return { operator, value };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { Dispatch, SetStateAction } from 'react';
|
||||
import {
|
||||
COLLECTION_TYPE,
|
||||
DATA_TYPE,
|
||||
|
|
@ -8,13 +9,11 @@ import {
|
|||
ROLES,
|
||||
} from './constants';
|
||||
import { TIME_UNIT } from './date';
|
||||
import { Dispatch, SetStateAction } from 'react';
|
||||
|
||||
type ObjectValues<T> = T[keyof T];
|
||||
|
||||
export type TimeUnit = ObjectValues<typeof TIME_UNIT>;
|
||||
export type Permission = ObjectValues<typeof PERMISSIONS>;
|
||||
|
||||
export type CollectionType = ObjectValues<typeof COLLECTION_TYPE>;
|
||||
export type Role = ObjectValues<typeof ROLES>;
|
||||
export type EventType = ObjectValues<typeof EVENT_TYPE>;
|
||||
|
|
@ -203,3 +202,10 @@ export interface SessionData {
|
|||
ip?: string;
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
export interface InputItem {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: any;
|
||||
seperator?: boolean;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue