mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
Merge pull request #1463 from guigrpa/add-yesterday
Add yesterday option
This commit is contained in:
commit
0bbfbc04c3
@ -18,6 +18,10 @@ export const filterOptions = [
|
||||
),
|
||||
value: '24hour',
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="label.yesterday" defaultMessage="Yesterday" />,
|
||||
value: '-1day',
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="label.this-week" defaultMessage="This week" />,
|
||||
value: '1week',
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Nom d'usuari",
|
||||
"label.view-details": "Veure els detalls",
|
||||
"label.websites": "Llocs web",
|
||||
"label.yesterday": "Ahir",
|
||||
"message.active-users": "{x} {x, plural, one {visitant actual} other {visitants actuals}}",
|
||||
"message.confirm-delete": "Segur que vols esborrar {target}?",
|
||||
"message.confirm-reset": "Segur que vols restablir les estadístiques de {target}?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Benutzername",
|
||||
"label.view-details": "Details anzeigen",
|
||||
"label.websites": "Webseiten",
|
||||
"label.yesterday": "Gestern",
|
||||
"message.active-users": "{x} {x, plural, one {aktiver Besucher} other {aktive Besucher}}",
|
||||
"message.confirm-delete": "Sind Sie sich sicher, {target} zu löschen?",
|
||||
"message.confirm-reset": "Sind Sie sicher, dass Sie die Statistiken von {target} zurücksetzen wollen?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Username",
|
||||
"label.view-details": "View details",
|
||||
"label.websites": "Websites",
|
||||
"label.yesterday": "Yesterday",
|
||||
"message.active-users": "{x} current {x, plural, one {visitor} other {visitors}}",
|
||||
"message.confirm-delete": "Are you sure you want to delete {target}?",
|
||||
"message.confirm-reset": "Are you sure you want to reset {target}'s statistics?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Username",
|
||||
"label.view-details": "View details",
|
||||
"label.websites": "Websites",
|
||||
"label.yesterday": "Yesterday",
|
||||
"message.active-users": "{x} current {x, plural, one {visitor} other {visitors}}",
|
||||
"message.confirm-delete": "Are you sure you want to delete {target}?",
|
||||
"message.confirm-reset": "Are you sure you want to reset {target}'s statistics?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Nombre de usuario",
|
||||
"label.view-details": "Ver detalles",
|
||||
"label.websites": "Sitios",
|
||||
"label.yesterday": "Ayer",
|
||||
"message.active-users": "{x} {x, plural, one {activo} other {activos}}",
|
||||
"message.confirm-delete": "¿Estás seguro(a) de querer eliminar {target}?",
|
||||
"message.confirm-reset": "¿Seguro que deseas restablecer las estadísticas de {target}?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Nom d'utilisateur",
|
||||
"label.view-details": "Voir les details",
|
||||
"label.websites": "Sites",
|
||||
"label.yesterday": "Hier",
|
||||
"message.active-users": "{x} {x, plural, one {visiteur} other {visiteurs}} actuellement",
|
||||
"message.confirm-delete": "Êtes-vous sûr de vouloir supprimer {target} ?",
|
||||
"message.confirm-reset": "Êtes-vous sûr de vouloir réinitialiser les statistiques de {target} ?",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"label.username": "Nome utente",
|
||||
"label.view-details": "Vedi dettagli",
|
||||
"label.websites": "Siti web",
|
||||
"label.yesterday": "Ieri",
|
||||
"message.active-users": "{x} {x, plural, one {visitatore} other {visitatori}} online",
|
||||
"message.confirm-delete": "Sei sicuro di voler eliminare {target}?",
|
||||
"message.confirm-reset": "Sei sicuro di voler azzerare le statistiche di {target}?",
|
||||
|
37
lib/date.js
37
lib/date.js
@ -7,6 +7,8 @@ import {
|
||||
addYears,
|
||||
subHours,
|
||||
subDays,
|
||||
subMonths,
|
||||
subYears,
|
||||
startOfMinute,
|
||||
startOfHour,
|
||||
startOfDay,
|
||||
@ -39,7 +41,7 @@ export function getDateRange(value, locale = 'en-US') {
|
||||
const now = new Date();
|
||||
const dateLocale = getDateLocale(locale);
|
||||
|
||||
const match = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/);
|
||||
const match = value.match(/^(?<num>[0-9-]+)(?<unit>hour|day|week|month|year)$/);
|
||||
|
||||
if (!match) return;
|
||||
|
||||
@ -78,6 +80,39 @@ export function getDateRange(value, locale = 'en-US') {
|
||||
}
|
||||
}
|
||||
|
||||
if (+num === -1) {
|
||||
switch (unit) {
|
||||
case 'day':
|
||||
return {
|
||||
startDate: subDays(startOfDay(now), 1),
|
||||
endDate: subDays(endOfDay(now), 1),
|
||||
unit: 'hour',
|
||||
value,
|
||||
};
|
||||
case 'week':
|
||||
return {
|
||||
startDate: subDays(startOfWeek(now, { locale: dateLocale }), 7),
|
||||
endDate: subDays(endOfWeek(now, { locale: dateLocale }), 1),
|
||||
unit: 'day',
|
||||
value,
|
||||
};
|
||||
case 'month':
|
||||
return {
|
||||
startDate: subMonths(startOfMonth(now), 1),
|
||||
endDate: subMonths(endOfMonth(now), 1),
|
||||
unit: 'day',
|
||||
value,
|
||||
};
|
||||
case 'year':
|
||||
return {
|
||||
startDate: subYears(startOfYear(now), 1),
|
||||
endDate: subYears(endOfYear(now), 1),
|
||||
unit: 'month',
|
||||
value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
switch (unit) {
|
||||
case 'day':
|
||||
return {
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Llocs web"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Ahir"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Webseiten"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Gestern"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Websites"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Yesterday"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Websites"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Yesterday"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Sitios"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Ayer"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -389,6 +389,12 @@
|
||||
"value": "Sites"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Hier"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@ -397,6 +397,12 @@
|
||||
"value": "Siti web"
|
||||
}
|
||||
],
|
||||
"label.yesterday": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Ieri"
|
||||
}
|
||||
],
|
||||
"message.active-users": [
|
||||
{
|
||||
"type": 1,
|
||||
|
Loading…
Reference in New Issue
Block a user