Replace the demo home page with a dashboard

Everyone sees their open tasks on an agenda, their open jobs, this
week's hours and quick links. Admin and management also get a lazily
loaded management panel: things to do, the month so far against the
previous month, jobs and late work, and everyone's workload.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-25 09:20:02 +02:00
co-authored by Claude Sonnet 5.5
parent d4251d00d7
commit 487a7d34ba
46 changed files with 2032 additions and 62 deletions
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Modules\Dashboard\Domain\Enums;
/**
* Where an open task falls on the home page's agenda: late (due before
* today), today or tomorrow (due, starting or under way by tomorrow), later
* this week, or later still.
*/
enum AgendaBucket: string
{
case Overdue = 'overdue';
case Soon = 'soon';
case ThisWeek = 'this_week';
case Later = 'later';
/**
* Days are Y-m-d. A task with no dates is "later".
*/
public static function of(?string $dueOn, ?string $plannedFrom, string $today, string $tomorrow, string $weekEnd): self
{
if ($dueOn !== null && $dueOn < $today) {
return self::Overdue;
}
$nearest = min(array_filter([$dueOn, $plannedFrom]) ?: ['9999-12-31']);
return match (true) {
$nearest <= $tomorrow => self::Soon,
$nearest <= $weekEnd => self::ThisWeek,
default => self::Later,
};
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Modules\Dashboard\Domain\ValueObjects;
/**
* How a figure changed from the comparison period: the ratio of the
* difference to the earlier value, or null when there was nothing to
* compare with (the earlier value was zero).
*/
final readonly class Change
{
public function __construct(
public int $current,
public int $previous,
) {}
public function ratio(): ?float
{
return $this->previous === 0 ? null : ($this->current - $this->previous) / abs($this->previous);
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace App\Modules\Dashboard\Domain\ValueObjects;
/**
* A person's booked work in a week against what they can do in it: the
* daily maximum on each working day (weekends, public holidays and company
* days off excluded). Minutes.
*/
final readonly class Workload
{
public function __construct(
public int $bookedMinutes,
public int $capacityMinutes,
) {}
public static function of(int $bookedMinutes, int $dailyCapacityMinutes, int $workingDays): self
{
return new self($bookedMinutes, $dailyCapacityMinutes * $workingDays);
}
/**
* Booked work as a share of the capacity, null without working days.
*/
public function ratio(): ?float
{
return $this->capacityMinutes === 0 ? null : $this->bookedMinutes / $this->capacityMinutes;
}
public function isOverloaded(): bool
{
return $this->bookedMinutes > $this->capacityMinutes;
}
/**
* Weekdays (Monday to Friday) between the days (Y-m-d, both included)
* that are not among the holidays.
*
* @param list<string> $holidays
*/
public static function workingDays(string $from, string $to, array $holidays): int
{
$days = 0;
for ($day = new \DateTimeImmutable($from); $day->format('Y-m-d') <= $to; $day = $day->modify('+1 day')) {
if ((int) $day->format('N') <= 5 && ! in_array($day->format('Y-m-d'), $holidays, true)) {
$days++;
}
}
return $days;
}
}