mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-18 10:43:18 +01:00
Compare commits
9 Commits
feature/ex
...
b02e49c7e0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b02e49c7e0 | ||
|
|
8609635d74 | ||
|
|
5a07f798b3 | ||
|
|
3af69830ee | ||
|
|
a050153bcd | ||
|
|
9d9731c7ce | ||
|
|
dfe3206614 | ||
|
|
97fd882878 | ||
|
|
111e12df12 |
1
.github/VOUCHED.td
vendored
1
.github/VOUCHED.td
vendored
@@ -18,6 +18,7 @@ bufferhead-code
|
|||||||
candideu
|
candideu
|
||||||
kasparrosin
|
kasparrosin
|
||||||
korridor
|
korridor
|
||||||
|
nikbucher tasks table sorting
|
||||||
onatcer
|
onatcer
|
||||||
shrootbuck
|
shrootbuck
|
||||||
smilebeda
|
smilebeda
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $request->user()
|
return $request->user()
|
||||||
? Limit::perMinute(200)->by($request->user()->id)
|
? Limit::perMinute(config('app.api_rate_limit_authenticated_per_minute'))->by($request->user()->id)
|
||||||
: Limit::perMinute(60)->by($request->ip());
|
: Limit::perMinute(config('app.api_rate_limit_guest_per_minute'))->by($request->ip());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->routes(function (): void {
|
$this->routes(function (): void {
|
||||||
|
|||||||
@@ -155,9 +155,10 @@ class LocalizationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time group types have no server-side descriptor; Day and Week keys are ISO dates and
|
* Time group types have no server-side descriptor; their keys are ISO dates and are
|
||||||
* formatted here instead. A Week key is the first day of that week, so it renders as the
|
* formatted here instead. A Week key is the first day of that week, so it renders as the
|
||||||
* range it covers.
|
* range it covers. A Year key is already a bare year, so it is returned unchanged - it must
|
||||||
|
* not be parsed, Carbon reads a four digit string as a time of day.
|
||||||
*/
|
*/
|
||||||
public function formatTimeGroupKey(?string $key, TimeEntryAggregationType $groupType): ?string
|
public function formatTimeGroupKey(?string $key, TimeEntryAggregationType $groupType): ?string
|
||||||
{
|
{
|
||||||
@@ -175,6 +176,13 @@ class LocalizationService
|
|||||||
return $this->formatDate($weekStart).' - '.$this->formatDate($weekStart->copy()->addDays(6));
|
return $this->formatDate($weekStart).' - '.$this->formatDate($weekStart->copy()->addDays(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($groupType === TimeEntryAggregationType::Month) {
|
||||||
|
// Note: the leading "!" resets all fields the format does not name. Without it the
|
||||||
|
// day of the month is taken from today, and a day that the parsed month does not
|
||||||
|
// have overflows the date into the next month.
|
||||||
|
return Carbon::createFromFormat('!Y-m', $key)->format('F Y');
|
||||||
|
}
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,21 @@ return [
|
|||||||
|
|
||||||
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| API Rate Limiting
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The number of API requests allowed per minute, counted per user for
|
||||||
|
| authenticated requests and per IP address for guest requests. These
|
||||||
|
| limits are only enforced when the application runs in production.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'api_rate_limit_authenticated_per_minute' => (int) (env('API_RATE_LIMIT_AUTH_PER_MINUTE') ?: 200),
|
||||||
|
|
||||||
|
'api_rate_limit_guest_per_minute' => (int) (env('API_RATE_LIMIT_GUEST_PER_MINUTE') ?: 60),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Encryption Key
|
| Encryption Key
|
||||||
|
|||||||
@@ -25,25 +25,20 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|||||||
<template>
|
<template>
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
<DialogOverlay
|
<DialogOverlay
|
||||||
class="fixed inset-0 z-50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0">
|
class="fixed top-0 left-0 z-50 w-screen h-screen [height:100dvh] backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0">
|
||||||
<div class="absolute inset-0 bg-default-background opacity-30" />
|
<div class="absolute inset-0 bg-default-background opacity-30" />
|
||||||
|
<div class="absolute inset-0 overflow-y-auto overscroll-contain flex items-start justify-center px-2">
|
||||||
|
<DialogContent
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'my-3 md:my-14 xl:my-24 bg-default-background grid w-full max-w-lg border border-border-tertiary shadow-lg duration-200 rounded-lg outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
||||||
|
props.class
|
||||||
|
)
|
||||||
|
">
|
||||||
|
<slot />
|
||||||
|
</DialogContent>
|
||||||
|
</div>
|
||||||
</DialogOverlay>
|
</DialogOverlay>
|
||||||
<div
|
|
||||||
:class="
|
|
||||||
cn(
|
|
||||||
'fixed top-0 left-0 z-50 pointer-events-none w-screen h-screen flex items-start px-2 pt-3 md:pt-14 xl:pt-24 justify-center overflow-auto'
|
|
||||||
)
|
|
||||||
">
|
|
||||||
<DialogContent
|
|
||||||
v-bind="forwarded"
|
|
||||||
:class="
|
|
||||||
cn(
|
|
||||||
'pointer-events-auto bg-default-background grid w-full max-w-lg border border-border-tertiary shadow-lg duration-200 rounded-lg outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
||||||
props.class
|
|
||||||
)
|
|
||||||
">
|
|
||||||
<slot />
|
|
||||||
</DialogContent>
|
|
||||||
</div>
|
|
||||||
</DialogPortal>
|
</DialogPortal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { describe, expect, test } from 'vitest';
|
import { describe, expect, test } from 'vitest';
|
||||||
import { formatHumanReadableDuration, formatReportingDuration, formatWeekRange } from './time';
|
import {
|
||||||
|
formatHumanReadableDuration,
|
||||||
|
formatMonth,
|
||||||
|
formatReportingDuration,
|
||||||
|
formatWeekRange,
|
||||||
|
} from './time';
|
||||||
|
|
||||||
const seconds = 14 * 3600 + 45 * 60 + 6; // 14h 45m 06s
|
const seconds = 14 * 3600 + 45 * 60 + 6; // 14h 45m 06s
|
||||||
|
|
||||||
@@ -60,3 +65,9 @@ describe('formatWeekRange', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('formatMonth', () => {
|
||||||
|
test('renders the name of the month that the key covers', () => {
|
||||||
|
expect(formatMonth('2001-02')).toBe('February 2001');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -245,6 +245,15 @@ export function formatWeekRange(date: string, format?: DateFormat): string {
|
|||||||
return `${formatDate(date, format)} - ${formatDate(end, format)}`;
|
return `${formatDate(date, format)} - ${formatDate(end, format)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the month that the given key falls in. There is no `DateFormat` variant for a
|
||||||
|
* month, so this is not affected by the organization date format.
|
||||||
|
* @param date - a month, in the format of 'YYYY-MM'
|
||||||
|
*/
|
||||||
|
export function formatMonth(date: string): string {
|
||||||
|
return getDayJsInstance()(date).format('MMMM YYYY');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a human readable date format.
|
* Returns a human readable date format.
|
||||||
* @param date - date in the format of 'YYYY-MM-DD'
|
* @param date - date in the format of 'YYYY-MM-DD'
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ import {
|
|||||||
} from '@heroicons/vue/16/solid';
|
} from '@heroicons/vue/16/solid';
|
||||||
import { Coffee } from '@lucide/vue';
|
import { Coffee } from '@lucide/vue';
|
||||||
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
|
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
|
||||||
import { type DateFormat, formatDate, formatWeekRange } from '@/packages/ui/src/utils/time';
|
import {
|
||||||
|
type DateFormat,
|
||||||
|
formatDate,
|
||||||
|
formatMonth,
|
||||||
|
formatWeekRange,
|
||||||
|
} from '@/packages/ui/src/utils/time';
|
||||||
|
|
||||||
export type GroupingOption =
|
export type GroupingOption =
|
||||||
| 'project'
|
| 'project'
|
||||||
@@ -27,7 +32,9 @@ export type GroupingOption =
|
|||||||
| 'tag'
|
| 'tag'
|
||||||
| 'type'
|
| 'type'
|
||||||
| 'day'
|
| 'day'
|
||||||
| 'week';
|
| 'week'
|
||||||
|
| 'month'
|
||||||
|
| 'year';
|
||||||
|
|
||||||
export const useReportingStore = defineStore('reporting', () => {
|
export const useReportingStore = defineStore('reporting', () => {
|
||||||
// Cache query composables to avoid creating new subscriptions on every call
|
// Cache query composables to avoid creating new subscriptions on every call
|
||||||
@@ -94,6 +101,10 @@ export const useReportingStore = defineStore('reporting', () => {
|
|||||||
if (type === 'week') {
|
if (type === 'week') {
|
||||||
return formatWeekRange(key, dateFormat);
|
return formatWeekRange(key, dateFormat);
|
||||||
}
|
}
|
||||||
|
if (type === 'month') {
|
||||||
|
return formatMonth(key);
|
||||||
|
}
|
||||||
|
// A `year` key is already a bare year, so it falls through unchanged.
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -364,14 +364,27 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
|||||||
$this->assertSame('29/12/2025 - 04/01/2026', $formatted);
|
$this->assertSame('29/12/2025 - 04/01/2026', $formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_format_time_group_key_does_not_change_month_year_and_entity_group_types(): void
|
public function test_format_time_group_key_formats_a_month_key_and_does_not_change_year_and_entity_group_types(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
$this->localizationService->setDateFormat(DateFormat::SlashSeparatedDDMMYYYY);
|
$this->localizationService->setDateFormat(DateFormat::SlashSeparatedDDMMYYYY);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
$this->assertSame('2001-02', $this->localizationService->formatTimeGroupKey('2001-02', TimeEntryAggregationType::Month));
|
$this->assertSame('February 2001', $this->localizationService->formatTimeGroupKey('2001-02', TimeEntryAggregationType::Month));
|
||||||
$this->assertSame('2001', $this->localizationService->formatTimeGroupKey('2001', TimeEntryAggregationType::Year));
|
$this->assertSame('2001', $this->localizationService->formatTimeGroupKey('2001', TimeEntryAggregationType::Year));
|
||||||
$this->assertSame('some-uuid', $this->localizationService->formatTimeGroupKey('some-uuid', TimeEntryAggregationType::Project));
|
$this->assertSame('some-uuid', $this->localizationService->formatTimeGroupKey('some-uuid', TimeEntryAggregationType::Project));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_format_time_group_key_formats_a_month_key_independently_of_the_current_day_of_month(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
// Note: the current day of the month must not leak into the parsed month. The 31st does
|
||||||
|
// not exist in April, so a leaked day overflows the date into the following month.
|
||||||
|
$this->travelTo(Carbon::create(2026, 8, 31, 12, 0, 0, 'UTC'));
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
$this->assertSame('February 2001', $this->localizationService->formatTimeGroupKey('2001-02', TimeEntryAggregationType::Month));
|
||||||
|
$this->assertSame('April 2026', $this->localizationService->formatTimeGroupKey('2026-04', TimeEntryAggregationType::Month));
|
||||||
|
$this->assertSame('December 2026', $this->localizationService->formatTimeGroupKey('2026-12', TimeEntryAggregationType::Month));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user