mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Added month select component.
This commit is contained in:
parent
6ef1f2e9f9
commit
c548267d91
16 changed files with 169 additions and 71 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { StatusLight } from 'react-basics';
|
||||
import { dateFormat } from 'lib/date';
|
||||
import { formatDate } from 'lib/date';
|
||||
import { formatLongNumber } from 'lib/format';
|
||||
|
||||
export function renderNumberLabels(label) {
|
||||
|
|
@ -12,15 +12,15 @@ export function renderDateLabels(unit, locale) {
|
|||
|
||||
switch (unit) {
|
||||
case 'minute':
|
||||
return dateFormat(d, 'h:mm', locale);
|
||||
return formatDate(d, 'h:mm', locale);
|
||||
case 'hour':
|
||||
return dateFormat(d, 'p', locale);
|
||||
return formatDate(d, 'p', locale);
|
||||
case 'day':
|
||||
return dateFormat(d, 'MMM d', locale);
|
||||
return formatDate(d, 'MMM d', locale);
|
||||
case 'month':
|
||||
return dateFormat(d, 'MMM', locale);
|
||||
return formatDate(d, 'MMM', locale);
|
||||
case 'year':
|
||||
return dateFormat(d, 'YYY', locale);
|
||||
return formatDate(d, 'YYY', locale);
|
||||
default:
|
||||
return label;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ export function renderStatusTooltipPopup(unit, locale) {
|
|||
|
||||
setTooltipPopup(
|
||||
<>
|
||||
<div>{dateFormat(new Date(dataPoints[0].raw.x), formats[unit], locale)}</div>
|
||||
<div>{formatDate(new Date(dataPoints[0].raw.x), formats[unit], locale)}</div>
|
||||
<div>
|
||||
<StatusLight color={labelColors?.[0]?.backgroundColor}>
|
||||
{formatLongNumber(dataPoints[0].raw.y)} {dataPoints[0].dataset.label}
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ function getDateFormat(date) {
|
|||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||
}
|
||||
|
||||
function mapFilter(column, operator, name) {
|
||||
function mapFilter(column, operator, name, type = 'String') {
|
||||
switch (operator) {
|
||||
case OPERATORS.equals:
|
||||
return `${column} = {${name}:String}`;
|
||||
return `${column} = {${name}:${type}`;
|
||||
case OPERATORS.notEquals:
|
||||
return `${column} != {${name}:String}`;
|
||||
return `${column} != {${name}:${type}}`;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ export const customFormats = {
|
|||
},
|
||||
};
|
||||
|
||||
export function dateFormat(date, str, locale = 'en-US') {
|
||||
export function formatDate(date, str, locale = 'en-US') {
|
||||
return format(
|
||||
typeof date === 'string' ? new Date(date) : date,
|
||||
customFormats?.[locale]?.[str] || str,
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@ function getTimestampIntervalQuery(field: string): string {
|
|||
}
|
||||
}
|
||||
|
||||
function mapFilter(column, operator, name) {
|
||||
function mapFilter(column, operator, name, type = 'String') {
|
||||
switch (operator) {
|
||||
case OPERATORS.equals:
|
||||
return `${column} = {{${name}}}`;
|
||||
return `${column} = {${name}:${type}`;
|
||||
case OPERATORS.notEquals:
|
||||
return `${column} != {{${name}}}`;
|
||||
return `${column} != {${name}:${type}}`;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue