From e258dccaab57ef635b6ff856cc4b754943dd93c0 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:01:23 +0100 Subject: [PATCH 1/9] feat(screens): group cards, spacing, QR style, header choices and a tabbed settings form - A group card lies behind the widgets wholly inside it, drawing one card for them; groups nest, a group moves with all it holds and never shrinks off a widget, and widgets in a group draw no card of their own ("Show card" is locked off). - A screen's margin and the space between its widgets: none, small, medium or large; with none, tiles are square and their borders collapse into one line. - Choices with icons that show what they do: spacing, alignment, text and title sizes, theme, fit, aspect and orientation. - The QR code widget picks the logo, its colors, modules, eyes (a preset or outer and inner apart) and up to three filters, from the QR library's own parts, icons and labels; a style phones could not read is refused on save. - The header shows what is chosen: logo, title or a title of its own, team, projects, environment, period, problem count and live state; the clock can show the date and seconds. Offline always shows. - Screen settings in tabs (Display, Look, Data, Header); aspect and orientation move there from the toolbar. --- .../Mcp/Tools/Screens/UpdateScreen.php | 3 + .../Screens/Actions/ExportScreenAction.php | 3 + .../Screens/Actions/ImportScreenAction.php | 13 + .../Screens/Actions/UpdateScreenAction.php | 5 +- app/Domains/Screens/Enums/ScreenSpacing.php | 17 + .../Http/Requests/UpdateScreenRequest.php | 15 +- app/Domains/Screens/Models/Screen.php | 34 +- .../Screens/Presenters/ScreenPresenter.php | 3 + app/Domains/Screens/Support/ScreenLayout.php | 54 +- app/Domains/Screens/Support/ScreenQr.php | 42 +- app/Domains/Screens/Support/WidgetSchema.php | 89 +- database/factories/ScreenFactory.php | 3 + ...00_add_margin_and_gap_to_screens_table.php | 27 + ..._18_110000_add_header_to_screens_table.php | 27 + docs/mcp.md | 2 +- lang/en/ui/screens.php | 49 + resources/css/screen.css | 24 + resources/js/components/lj/screen/frame.tsx | 107 +- .../js/components/lj/screen/inspector.tsx | 1068 +++++++++++++---- resources/js/components/lj/screen/lib.ts | 64 +- resources/js/components/lj/screen/types.ts | 43 +- resources/js/components/lj/screen/widgets.tsx | 54 +- resources/js/pages/screens/edit.tsx | 182 +-- resources/js/pages/screens/kiosk.tsx | 15 +- .../Database/ShowcaseWidgetsSeederTest.php | 2 +- .../Http/Controllers/ScreenControllerTest.php | 18 +- .../Controllers/ScreenFileControllerTest.php | 16 +- .../Screens/Support/ScreenLayoutTest.php | 11 + .../Screens/Support/WidgetSchemaTest.php | 25 +- 29 files changed, 1643 insertions(+), 372 deletions(-) create mode 100644 app/Domains/Screens/Enums/ScreenSpacing.php create mode 100644 database/migrations/2026_11_18_100000_add_margin_and_gap_to_screens_table.php create mode 100644 database/migrations/2026_11_18_110000_add_header_to_screens_table.php diff --git a/app/Domains/Mcp/Tools/Screens/UpdateScreen.php b/app/Domains/Mcp/Tools/Screens/UpdateScreen.php index f2681373..321cf083 100644 --- a/app/Domains/Mcp/Tools/Screens/UpdateScreen.php +++ b/app/Domains/Mcp/Tools/Screens/UpdateScreen.php @@ -39,9 +39,12 @@ public function schema(JsonSchema $schema): array 'aspect' => $schema->string(), 'orientation' => $schema->string(), 'fit' => $schema->string(), + 'margin' => $schema->string()->description('Room around the grid: none, s, m or l.'), + 'gap' => $schema->string()->description('Room between widgets: none, s, m or l.'), 'show_header' => $schema->boolean(), 'show_clock' => $schema->boolean(), 'clock_format' => $schema->string()->description('24 or 12.'), + 'header' => $schema->object()->description('{hide: [logo|name|team|projects|environment|period|attention|live], title: a title instead of the name or null, date: bool, seconds: bool}: the clock\'s date and seconds.'), 'light_from' => $schema->string()->description('HH:MM.'), 'light_to' => $schema->string()->description('HH:MM.'), 'timezone' => $schema->string()->description('Null: each viewer\'s own.'), diff --git a/app/Domains/Screens/Actions/ExportScreenAction.php b/app/Domains/Screens/Actions/ExportScreenAction.php index 7f9a43a3..e9b5f676 100644 --- a/app/Domains/Screens/Actions/ExportScreenAction.php +++ b/app/Domains/Screens/Actions/ExportScreenAction.php @@ -57,9 +57,12 @@ public function execute(Screen $screen): array 'aspect' => $screen->aspect->value, 'orientation' => $screen->orientation->value, 'fit' => $screen->fit->value, + 'margin' => $screen->margin->value, + 'gap' => $screen->gap->value, 'show_header' => $screen->show_header, 'show_clock' => $screen->show_clock, 'clock_format' => $screen->clock_format, + 'header' => Screen::header($screen->header), 'theme' => $screen->theme->value, 'light_from' => $screen->light_from, 'light_to' => $screen->light_to, diff --git a/app/Domains/Screens/Actions/ImportScreenAction.php b/app/Domains/Screens/Actions/ImportScreenAction.php index 81e8ad67..d4ec7c1a 100644 --- a/app/Domains/Screens/Actions/ImportScreenAction.php +++ b/app/Domains/Screens/Actions/ImportScreenAction.php @@ -10,6 +10,7 @@ use App\Domains\Screens\Enums\ScreenAspect; use App\Domains\Screens\Enums\ScreenFit; use App\Domains\Screens\Enums\ScreenOrientation; +use App\Domains\Screens\Enums\ScreenSpacing; use App\Domains\Screens\Enums\ScreenTheme; use App\Domains\Screens\Models\Screen; use App\Domains\Screens\Support\ScreenFile; @@ -70,10 +71,19 @@ public function read(Team $team, array $document): ScreenImport 'screen.aspect' => ['required', Rule::enum(ScreenAspect::class)], 'screen.orientation' => ['required', Rule::enum(ScreenOrientation::class)], 'screen.fit' => ['required', Rule::enum(ScreenFit::class)], + // Files from before they could be chosen have neither. + 'screen.margin' => ['sometimes', Rule::enum(ScreenSpacing::class)], + 'screen.gap' => ['sometimes', Rule::enum(ScreenSpacing::class)], 'screen.show_header' => ['required', 'boolean'], // Files from before the clock could be hidden show it. 'screen.show_clock' => ['sometimes', 'boolean'], 'screen.clock_format' => ['sometimes', 'in:24,12'], + 'screen.header' => ['sometimes', 'array'], + 'screen.header.hide' => ['array'], + 'screen.header.hide.*' => ['string', Rule::in(Screen::HEADER_PARTS)], + 'screen.header.title' => ['nullable', 'string', 'max:100'], + 'screen.header.date' => ['boolean'], + 'screen.header.seconds' => ['boolean'], 'screen.theme' => ['required', Rule::enum(ScreenTheme::class)], 'screen.light_from' => $time, 'screen.light_to' => $time, @@ -213,9 +223,12 @@ public function read(Team $team, array $document): ScreenImport 'aspect' => ScreenAspect::from((string) $file['aspect']), 'orientation' => ScreenOrientation::from((string) $file['orientation']), 'fit' => ScreenFit::from((string) $file['fit']), + 'margin' => ScreenSpacing::from((string) ($file['margin'] ?? ScreenSpacing::Medium->value)), + 'gap' => ScreenSpacing::from((string) ($file['gap'] ?? ScreenSpacing::Medium->value)), 'show_header' => (bool) $file['show_header'], 'show_clock' => (bool) ($file['show_clock'] ?? true), 'clock_format' => in_array($file['clock_format'] ?? null, ['24', '12'], true) ? $file['clock_format'] : '24', + 'header' => Screen::header(is_array($file['header'] ?? null) ? $file['header'] : null), 'theme' => ScreenTheme::from((string) $file['theme']), 'light_from' => (string) $file['light_from'], 'light_to' => (string) $file['light_to'], diff --git a/app/Domains/Screens/Actions/UpdateScreenAction.php b/app/Domains/Screens/Actions/UpdateScreenAction.php index 36ecfa2f..7f17fae0 100644 --- a/app/Domains/Screens/Actions/UpdateScreenAction.php +++ b/app/Domains/Screens/Actions/UpdateScreenAction.php @@ -8,6 +8,7 @@ use App\Domains\Screens\Enums\ScreenAspect; use App\Domains\Screens\Enums\ScreenFit; use App\Domains\Screens\Enums\ScreenOrientation; +use App\Domains\Screens\Enums\ScreenSpacing; use App\Domains\Screens\Enums\ScreenTheme; use App\Domains\Screens\Models\Screen; use App\Models\User; @@ -23,11 +24,11 @@ public function __construct( * Name, the display's aspect and orientation and how it fits another, whether the header shows, theme and its schedule, time zone and * the default scope; open kiosks follow. * - * @param array{name?: string, aspect?: ScreenAspect, orientation?: ScreenOrientation, fit?: ScreenFit, show_header?: bool, show_clock?: bool, clock_format?: string, theme?: ScreenTheme, light_from?: string, light_to?: string, timezone?: string|null, scope?: array{projects: list, environment: string|null, period: string}} $settings + * @param array{name?: string, aspect?: ScreenAspect, orientation?: ScreenOrientation, fit?: ScreenFit, margin?: ScreenSpacing, gap?: ScreenSpacing, show_header?: bool, show_clock?: bool, clock_format?: string, header?: array{hide: list, title: string|null, date: bool, seconds: bool}, theme?: ScreenTheme, light_from?: string, light_to?: string, timezone?: string|null, scope?: array{projects: list, environment: string|null, period: string}} $settings */ public function execute(Screen $screen, array $settings, User|McpToken|null $by = null, ?int $revision = null): Screen { - $screen->fill(array_intersect_key($settings, array_flip(['name', 'aspect', 'orientation', 'fit', 'show_header', 'show_clock', 'clock_format', 'theme', 'light_from', 'light_to', 'timezone', 'scope']))); + $screen->fill(array_intersect_key($settings, array_flip(['name', 'aspect', 'orientation', 'fit', 'margin', 'gap', 'show_header', 'show_clock', 'clock_format', 'header', 'theme', 'light_from', 'light_to', 'timezone', 'scope']))); return $this->save->execute($screen, $by, $revision); } diff --git a/app/Domains/Screens/Enums/ScreenSpacing.php b/app/Domains/Screens/Enums/ScreenSpacing.php new file mode 100644 index 00000000..b8d1235d --- /dev/null +++ b/app/Domains/Screens/Enums/ScreenSpacing.php @@ -0,0 +1,17 @@ + ['sometimes', 'required', Rule::enum(ScreenAspect::class)], 'orientation' => ['sometimes', 'required', Rule::enum(ScreenOrientation::class)], 'fit' => ['sometimes', 'required', Rule::enum(ScreenFit::class)], + 'margin' => ['sometimes', 'required', Rule::enum(ScreenSpacing::class)], + 'gap' => ['sometimes', 'required', Rule::enum(ScreenSpacing::class)], 'show_header' => ['sometimes', 'required', 'boolean'], 'show_clock' => ['sometimes', 'required', 'boolean'], 'clock_format' => ['sometimes', 'required', Rule::in(['24', '12'])], + 'header' => ['sometimes', 'required', 'array'], + 'header.hide' => ['array'], + 'header.hide.*' => ['string', Rule::in(Screen::HEADER_PARTS)], + 'header.title' => ['nullable', 'string', 'max:100'], + 'header.date' => ['boolean'], + 'header.seconds' => ['boolean'], 'light_from' => ['sometimes', 'required', ...$time], 'light_to' => ['sometimes', 'required', ...$time], // Empty: the viewer's own time zone. @@ -76,7 +85,7 @@ public static function settingsFrom(array $input): array { $settings = array_intersect_key($input, array_flip(['name', 'light_from', 'light_to', 'timezone', 'clock_format'])); - foreach (['theme' => ScreenTheme::class, 'aspect' => ScreenAspect::class, 'orientation' => ScreenOrientation::class, 'fit' => ScreenFit::class] as $key => $enum) { + foreach (['theme' => ScreenTheme::class, 'aspect' => ScreenAspect::class, 'orientation' => ScreenOrientation::class, 'fit' => ScreenFit::class, 'margin' => ScreenSpacing::class, 'gap' => ScreenSpacing::class] as $key => $enum) { if (array_key_exists($key, $input)) { $settings[$key] = $enum::from((string) $input[$key]); } @@ -88,6 +97,10 @@ public static function settingsFrom(array $input): array } } + if (array_key_exists('header', $input)) { + $settings['header'] = Screen::header((array) $input['header']); + } + if (array_key_exists('scope', $input)) { $environment = $input['scope']['environment'] ?? null; $settings['scope'] = [ diff --git a/app/Domains/Screens/Models/Screen.php b/app/Domains/Screens/Models/Screen.php index 4f5cf453..6f39a3cb 100644 --- a/app/Domains/Screens/Models/Screen.php +++ b/app/Domains/Screens/Models/Screen.php @@ -8,6 +8,7 @@ use App\Domains\Screens\Enums\ScreenAspect; use App\Domains\Screens\Enums\ScreenFit; use App\Domains\Screens\Enums\ScreenOrientation; +use App\Domains\Screens\Enums\ScreenSpacing; use App\Domains\Screens\Enums\ScreenTheme; use App\Domains\Teams\Models\Team; use Carbon\CarbonImmutable; @@ -39,6 +40,9 @@ * @property bool $show_header whether the TV shows the name, scope, live state and clock above the grid * @property bool $show_clock whether that header shows the clock * @property string $clock_format '24' or '12' hours + * @property array|null $header what the header shows; see header() + * @property ScreenSpacing $margin the room around the grid + * @property ScreenSpacing $gap the room between widgets * @property ScreenTheme $theme * @property string $light_from HH:MM * @property string $light_to HH:MM @@ -52,7 +56,7 @@ * @property CarbonImmutable|null $created_at * @property CarbonImmutable|null $updated_at */ -#[Fillable(['team_id', 'name', 'cols', 'rows', 'aspect', 'orientation', 'fit', 'show_header', 'show_clock', 'clock_format', 'theme', 'light_from', 'light_to', 'timezone', 'scope', 'widgets', 'share_key', 'share_key_hash', 'share_titles'])] +#[Fillable(['team_id', 'name', 'cols', 'rows', 'aspect', 'orientation', 'fit', 'margin', 'gap', 'show_header', 'show_clock', 'clock_format', 'header', 'theme', 'light_from', 'light_to', 'timezone', 'scope', 'widgets', 'share_key', 'share_key_hash', 'share_titles'])] #[Hidden(['share_key', 'share_key_hash'])] #[UseEloquentBuilder(ScreenBuilder::class)] #[UseFactory(ScreenFactory::class)] @@ -62,8 +66,11 @@ class Screen extends Model use HasFactory; use HasUuids; + /** Parts of the header a screen can hide; being offline always shows. */ + public const array HEADER_PARTS = ['logo', 'name', 'team', 'projects', 'environment', 'period', 'attention', 'live']; + /** What a version of a screen holds; not its identity or share link. */ - public const array DESIGN = ['name', 'cols', 'rows', 'aspect', 'orientation', 'fit', 'show_header', 'show_clock', 'clock_format', 'theme', 'light_from', 'light_to', 'timezone', 'scope', 'widgets']; + public const array DESIGN = ['name', 'cols', 'rows', 'aspect', 'orientation', 'fit', 'margin', 'gap', 'show_header', 'show_clock', 'clock_format', 'header', 'theme', 'light_from', 'light_to', 'timezone', 'scope', 'widgets']; public const int MIN_COLS = 2; @@ -94,17 +101,40 @@ public function getRouteKeyName(): string return 'uuid'; } + /** + * What the header shows, whole: the parts hidden, a title instead of the name, and + * whether the clock has the date and seconds. Stored or given, with anything else + * dropped; nothing stored is everything, as before it could be chosen. + * + * @param array|null $given + * @return array{hide: list, title: string|null, date: bool, seconds: bool} + */ + public static function header(?array $given): array + { + $title = trim((string) ($given['title'] ?? '')); + + return [ + 'hide' => array_values(array_unique(array_intersect(array_filter((array) ($given['hide'] ?? []), is_string(...)), self::HEADER_PARTS))), + 'title' => $title !== '' ? $title : null, + 'date' => (bool) ($given['date'] ?? false), + 'seconds' => (bool) ($given['seconds'] ?? false), + ]; + } + protected function casts(): array { return [ 'aspect' => ScreenAspect::class, 'orientation' => ScreenOrientation::class, 'fit' => ScreenFit::class, + 'margin' => ScreenSpacing::class, + 'gap' => ScreenSpacing::class, 'show_header' => 'boolean', 'show_clock' => 'boolean', 'theme' => ScreenTheme::class, 'cols' => 'integer', 'rows' => 'integer', + 'header' => 'array', 'scope' => 'array', 'widgets' => 'array', 'share_key' => 'encrypted', diff --git a/app/Domains/Screens/Presenters/ScreenPresenter.php b/app/Domains/Screens/Presenters/ScreenPresenter.php index 56b93be9..9021f1bf 100644 --- a/app/Domains/Screens/Presenters/ScreenPresenter.php +++ b/app/Domains/Screens/Presenters/ScreenPresenter.php @@ -50,9 +50,12 @@ public function present(Screen $screen): array 'aspect' => $screen->aspect->value, 'orientation' => $screen->orientation->value, 'fit' => $screen->fit->value, + 'margin' => $screen->margin->value, + 'gap' => $screen->gap->value, 'show_header' => $screen->show_header, 'show_clock' => $screen->show_clock, 'clock_format' => $screen->clock_format, + 'header' => Screen::header($screen->header), 'theme' => $screen->theme->value, 'light_from' => $screen->light_from, 'light_to' => $screen->light_to, diff --git a/app/Domains/Screens/Support/ScreenLayout.php b/app/Domains/Screens/Support/ScreenLayout.php index cd7ee989..c31d253d 100644 --- a/app/Domains/Screens/Support/ScreenLayout.php +++ b/app/Domains/Screens/Support/ScreenLayout.php @@ -69,34 +69,70 @@ public static function positioned(array $widgets, int $cols, int $rows): array } /** - * Indexes of widgets that cover a cell an earlier widget already covers. + * Indexes of widgets that cover a cell an earlier widget already covers, besides a + * widget lying wholly inside a group. * * @param list> $widgets positioned * @return list */ public static function overlapping(array $widgets): array { - $taken = []; + $kept = []; $overlapping = []; foreach ($widgets as $i => $widget) { - $x = (int) $widget['x']; - $y = (int) $widget['y']; - $w = max(1, (int) $widget['w']); - $h = max(1, (int) $widget['h']); - - if (! self::free($taken, $x, $y, $w, $h)) { + if (collect($kept)->contains(fn (array $other): bool => self::clash($widget, $other))) { $overlapping[] = $i; continue; } - self::take($taken, $x, $y, $w, $h); + $kept[] = $widget; } return $overlapping; } + /** + * Whether a group holds a widget, a group too: one wholly inside it, on fewer cells (a + * 1 x 1 group holds nothing). The group draws one card behind the widgets it holds. + * + * @param array $group positioned + * @param array $widget positioned + */ + public static function holds(array $group, array $widget): bool + { + [$g, $w] = [self::box($group), self::box($widget)]; + + return ($group['type'] ?? null) === 'group' && $w !== $g + && $w['x'] >= $g['x'] && $w['y'] >= $g['y'] + && $w['x'] + $w['w'] <= $g['x'] + $g['w'] && $w['y'] + $w['h'] <= $g['y'] + $g['h']; + } + + /** + * Whether two widgets cover a common cell, unless one is a group holding the other. + * + * @param array $a + * @param array $b + */ + private static function clash(array $a, array $b): bool + { + [$p, $q] = [self::box($a), self::box($b)]; + $apart = $p['x'] >= $q['x'] + $q['w'] || $q['x'] >= $p['x'] + $p['w'] + || $p['y'] >= $q['y'] + $q['h'] || $q['y'] >= $p['y'] + $p['h']; + + return ! $apart && ! self::holds($a, $b) && ! self::holds($b, $a); + } + + /** + * @param array $widget positioned + * @return array{x: int, y: int, w: int, h: int} + */ + private static function box(array $widget): array + { + return ['x' => (int) $widget['x'], 'y' => (int) $widget['y'], 'w' => max(1, (int) $widget['w']), 'h' => max(1, (int) $widget['h'])]; + } + /** @param array $widget */ private static function hasPosition(array $widget): bool { diff --git a/app/Domains/Screens/Support/ScreenQr.php b/app/Domains/Screens/Support/ScreenQr.php index e8516b56..299dd5e0 100644 --- a/app/Domains/Screens/Support/ScreenQr.php +++ b/app/Domains/Screens/Support/ScreenQr.php @@ -7,6 +7,7 @@ use ExeQue\Qr\Builders\Rendered; use ExeQue\Qr\Facades\Qr; use ExeQue\Qr\Rendering\ScanSafety; +use ExeQue\Qr\Validation\StyleRule; /** * The QR codes Lumberjack draws, in the `lumberjack` style of config/qr.php: amber on @@ -50,10 +51,43 @@ public static function widgetSvg(array $options): ?string default => $value('url') === '' ? null : Qr::url($value('url')), }; - // Transparent, so the tile shows through. Amber has too little contrast for the - // guard on white, so that one guard is off; the rest still apply. The mark has - // no plate. - return $qr?->style('lumberjack')->background(null)->scanSafety(new ScanSafety(minContrast: null, inverted: null))->logo(file: resource_path('images/qr-mark.svg'), size: self::LOGO_SIZE, shape: 'circle')->svg()->contents(); + if ($qr === null) { + return null; + } + + // Transparent unless a background is picked, so the tile shows through. Without + // one there is nothing to measure the colors against, so the contrast guard is + // off; a code lighter than its ground is fine on a dark screen. The rest apply. + $background = $value('qr_background') ?: null; + $qr = $qr->style(StyleRule::toStyle(self::style($options), base: 'lumberjack')) + ->background($background) + ->scanSafety(new ScanSafety(minContrast: $background === null ? null : 3.0, inverted: null)); + + // The mark has no plate. + return (($options['qr_logo'] ?? true) ? $qr->logo(file: resource_path('images/qr-mark.svg'), size: self::LOGO_SIZE, shape: 'circle') : $qr) + ->svg() + ->contents(); + } + + /** + * A QR code widget's style options (WidgetSchema's qr_style section) as the library's + * style input, over the `lumberjack` style: the same modules and eyes when none are picked. + * + * @param array $options + * @return array + */ + private static function style(array $options): array + { + $paint = $options['qr_color'] ?? null; + $eyes = ($options['qr_eyes'] ?? 'mix') === 'custom' + ? ['outer' => ['shape' => $options['qr_outer'] ?? 'rounded'], 'inner' => ['shape' => $options['qr_inner'] ?? 'soft']] + : ['preset' => $options['qr_eyes'] ?? 'mix']; + + return array_filter([ + 'modules' => array_filter(['shape' => $options['qr_module'] ?? 'rounded', 'paint' => $paint]), + 'eyes' => array_filter([...$eyes, 'paint' => $paint]), + 'filters' => array_map(fn (string $name): array => ['name' => $name], (array) ($options['qr_filters'] ?? [])), + ]); } /** diff --git a/app/Domains/Screens/Support/WidgetSchema.php b/app/Domains/Screens/Support/WidgetSchema.php index dbb31097..6a796e50 100644 --- a/app/Domains/Screens/Support/WidgetSchema.php +++ b/app/Domains/Screens/Support/WidgetSchema.php @@ -11,7 +11,12 @@ use App\Domains\Shared\Enums\Period; use Closure; use DateTimeZone; +use ExeQue\Qr\Exceptions\ScanSafetyException; +use ExeQue\Qr\Facades\Qr; +use ExeQue\Qr\Qr as QrManager; use Illuminate\Validation\Rule; +use ReflectionClass; +use Throwable; /** * The shape of a status screen widget and the options each type takes: one schema that @@ -47,7 +52,7 @@ final class WidgetSchema ]; /** Widgets drawn by the client alone, without a source. */ - public const array LAYOUT_TYPES = ['clock', 'countdown', 'message', 'qr', 'media', 'empty']; + public const array LAYOUT_TYPES = ['clock', 'countdown', 'message', 'qr', 'media', 'empty', 'group']; /** Types that can rotate through several sources on one tile. */ public const array ROTATING_TYPES = ['stat', 'gauge', 'chart', 'list', 'health']; @@ -57,6 +62,12 @@ final class WidgetSchema public const int MAX_WIDGETS = 48; + /** Filters of the QR library that need options of their own (colors, shapes, regions), so none here. */ + private const array QR_FILTERS_WITH_OPTIONS = ['mixed-shape', 'palette', 'gradient-fill', 'by-role', 'region', 'eye-palette', 'compound']; + + /** Filters on one QR code, at most. */ + public const int MAX_QR_FILTERS = 3; + /** Addresses one media widget shows in turn. */ public const int MAX_SLIDES = 20; @@ -287,6 +298,8 @@ public static function rules(string $prefix, mixed $widget, int $cols, int $rows }], // A local date and time, as an gives it. 'datetime' => ['nullable', 'date_format:Y-m-d\TH:i'], + 'color' => ['nullable', 'string', 'regex:/^#[0-9a-fA-F]{6}$/'], + 'choices' => ['nullable', 'array', 'max:'.($field['max'] ?? count($field['options']))], 'textarea' => ['nullable', 'string', 'max:500'], default => ['nullable', 'string', 'max:200'], }; @@ -294,6 +307,23 @@ public static function rules(string $prefix, mixed $widget, int $cols, int $rows if ($field['type'] === 'checks') { $rules["{$attribute}.*"] = ['string', 'uuid']; } + + if ($field['type'] === 'choices') { + $rules["{$attribute}.*"] = ['string', Rule::in($field['options'])]; + } + } + + // A QR code's colors and filters must still scan: drawn once as the TV will, on a link. + if ($type === 'qr') { + $rules["{$prefix}.options"][] = function (string $attribute, mixed $value, Closure $fail): void { + try { + ScreenQr::widgetSvg([...(array) $value, 'content' => 'link', 'url' => 'https://lumberjack.example/a/link/of/some/length']); + } catch (ScanSafetyException) { + $fail(__('ui/screens.validation.qr_unscannable')); + } catch (Throwable) { + // A name it does not know: the field's own rule says so. + } + }; } return $rules; @@ -395,7 +425,7 @@ private static function cleanOptions(array $fields, array $given): array $options[$key] = match ($field['type']) { 'toggle' => (bool) $value, 'number' => (float) $value, - 'checks' => array_values(array_unique(array_map('strval', (array) $value))), + 'checks', 'choices' => array_values(array_unique(array_map('strval', (array) $value))), default => (string) $value, }; } @@ -403,6 +433,39 @@ private static function cleanOptions(array $fields, array $given): array return $options; } + /** + * A pick of the QR library's parts (modules, eyes, filters): every one it has, each with + * the icon it ships and its label. With custom, the eyes can also be picked part by part. + * + * @return array + */ + private static function qrPicker(string $key, string $kind, ?string $default, bool $custom = false): array + { + $manifest = Qr::manifest(); + $names = array_values(array_diff(array_map(strval(...), array_keys($manifest[$kind])), $kind === 'filters' ? self::QR_FILTERS_WITH_OPTIONS : [])); + $folder = dirname((string) (new ReflectionClass(QrManager::class))->getFileName(), 2).'/resources/icons/'.match ($kind) { + 'outerEyes' => 'outer-eyes', + 'innerEyes' => 'inner-eyes', + default => $kind, + }; + $icons = collect($names) + ->mapWithKeys(fn (string $name): array => [$name => @file_get_contents("{$folder}/{$name}.svg") ?: null]) + ->filter() + ->all(); + $labels = collect($names)->mapWithKeys(fn (string $name): array => [$name => $manifest['labels'][$manifest['locales'][0]][$kind][$name] ?? $name])->all(); + + return [ + 'key' => $key, + 'type' => 'select', + 'options' => $custom ? [...$names, 'custom'] : $names, + 'icons' => $icons, + 'labels' => $custom ? [...$labels, 'custom' => __('ui/screens.fields.'.$key.'.custom')] : $labels, + 'default' => $default, + 'data' => true, + 'span' => 2, + ]; + } + /** * @param list> $fields * @return array{id: string, fields: list>} @@ -606,6 +669,20 @@ private static function build(): array ]), $text('caption', 2), ]), + // The QR library's style, a section each: closed, the grids are long. + $section('qr_look', [ + $toggle('qr_logo', true, true), + // Unset: the brand amber, no background; swatch is what the color picker opens on. + ['key' => 'qr_color', 'type' => 'color', 'default' => null, 'swatch' => config('qr.colors.amber'), 'data' => true, 'span' => 1], + ['key' => 'qr_background', 'type' => 'color', 'default' => null, 'swatch' => '#ffffff', 'data' => true, 'span' => 1], + ]), + $section('qr_modules', [self::qrPicker('qr_module', 'modules', 'rounded')]), + $section('qr_eyes', [ + self::qrPicker('qr_eyes', 'eyes', 'mix', custom: true), + [...self::qrPicker('qr_outer', 'outerEyes', 'rounded'), 'when' => ['qr_eyes' => ['custom']]], + [...self::qrPicker('qr_inner', 'innerEyes', 'soft'), 'when' => ['qr_eyes' => ['custom']]], + ]), + $section('qr_filters', [[...self::qrPicker('qr_filters', 'filters', null), 'type' => 'choices', 'max' => self::MAX_QR_FILTERS]]), $display(false), ], 'media' => [ @@ -622,6 +699,14 @@ private static function build(): array $display(false), ], 'empty' => [], + // One card behind the widgets wholly inside it (ScreenLayout::holds()), its title off at first. + 'group' => [ + $section('display', [ + $toggle('show_title', false), + $select('title_size', ['s', 'm', 'l', 'xl'], 'm'), + $select('align', ['left', 'center'], 'left'), + ]), + ], ]; } } diff --git a/database/factories/ScreenFactory.php b/database/factories/ScreenFactory.php index 84d4dec9..2cfc0a3c 100644 --- a/database/factories/ScreenFactory.php +++ b/database/factories/ScreenFactory.php @@ -9,6 +9,7 @@ use App\Domains\Screens\Enums\ScreenAspect; use App\Domains\Screens\Enums\ScreenFit; use App\Domains\Screens\Enums\ScreenOrientation; +use App\Domains\Screens\Enums\ScreenSpacing; use App\Domains\Screens\Enums\ScreenTheme; use App\Domains\Screens\Models\Screen; use App\Domains\Teams\Models\Team; @@ -29,6 +30,8 @@ public function definition(): array 'aspect' => ScreenAspect::Wide, 'orientation' => ScreenOrientation::Landscape, 'fit' => ScreenFit::Keep, + 'margin' => ScreenSpacing::Medium, + 'gap' => ScreenSpacing::Medium, 'show_header' => true, 'show_clock' => true, 'clock_format' => '24', diff --git a/database/migrations/2026_11_18_100000_add_margin_and_gap_to_screens_table.php b/database/migrations/2026_11_18_100000_add_margin_and_gap_to_screens_table.php new file mode 100644 index 00000000..ac826e89 --- /dev/null +++ b/database/migrations/2026_11_18_100000_add_margin_and_gap_to_screens_table.php @@ -0,0 +1,27 @@ +string('margin', 4)->default('m')->after('fit'); + $table->string('gap', 4)->default('m')->after('margin'); + }); + } + + public function down(): void + { + Schema::table('screens', function (Blueprint $table): void { + $table->dropColumn(['margin', 'gap']); + }); + } +}; diff --git a/database/migrations/2026_11_18_110000_add_header_to_screens_table.php b/database/migrations/2026_11_18_110000_add_header_to_screens_table.php new file mode 100644 index 00000000..9b8d1972 --- /dev/null +++ b/database/migrations/2026_11_18_110000_add_header_to_screens_table.php @@ -0,0 +1,27 @@ +json('header')->nullable()->after('clock_format'); + }); + } + + public function down(): void + { + Schema::table('screens', function (Blueprint $table): void { + $table->dropColumn('header'); + }); + } +}; diff --git a/docs/mcp.md b/docs/mcp.md index c0674ed4..2a343380 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -311,7 +311,7 @@ For `weekly_summary`, `settings` is `{day, time}`: `day` 1 to 7 (1 is Monday) an | `preview_screen` | `screens: read` | Signed preview link. | **`screen`** | | `get_screen_design_guide` | `screens: read` | Design guide for agents. | none | | `create_screen` | `screens: write` | New screen. | **`name`**, `template` | -| `update_screen` | `screens: write` | Name, theme, settings. | **`screen`**, **`revision`**, `name`, `theme`, `aspect`, `orientation`, `fit`, `show_header`, `show_clock`, `clock_format`, `light_from`, `light_to`, `timezone`, `scope` | +| `update_screen` | `screens: write` | Name, theme, settings. | **`screen`**, **`revision`**, `name`, `theme`, `aspect`, `orientation`, `fit`, `margin`, `gap`, `show_header`, `show_clock`, `clock_format`, `header`, `light_from`, `light_to`, `timezone`, `scope` | | `update_screen_layout` | `screens: write` | Grid layout. | **`screen`**, **`revision`**, **`cols`**, **`rows`**, **`widgets`** | | `update_screen_widget` | `screens: write` | One widget. | **`screen`**, **`revision`**, **`id`**, **`widget`** | | `restore_screen_version` | `screens: write` | Restore a version. | **`screen`**, **`revision`**, **`version`** | diff --git a/lang/en/ui/screens.php b/lang/en/ui/screens.php index 7f533cc4..dd9aebd0 100644 --- a/lang/en/ui/screens.php +++ b/lang/en/ui/screens.php @@ -149,6 +149,7 @@ 'qr' => 'QR code', 'media' => 'Image, video or page', 'empty' => 'Empty cell', + 'group' => 'Group', ], // What each type is for, under its name in the palette. @@ -166,6 +167,7 @@ 'qr' => 'A link, the guest wifi or any text to scan', 'media' => 'A picture or camera, a video, YouTube or a web page', 'empty' => 'Blank space; not shown on the TV', + 'group' => 'One card behind the widgets you put on it', ], 'palette' => [ @@ -242,6 +244,8 @@ 'external' => 'External', ], 'inspector' => [ + 'card_in_group' => 'The group it lies in draws the card.', + 'reset' => 'Reset', 'label' => 'Settings', 'period' => 'Over', 'period_screen' => 'Screen default', @@ -291,6 +295,7 @@ 'no_checks' => 'The team has no health checks yet.', 'checks_hint' => 'None picked: every check of the projects, new ones included. One picked: that check alone, with its uptime and timeline.', 'empty_hint' => 'Keeps this space empty on the TV. Resize it to make a gap of any size.', + 'group_hint' => 'Drop widgets on it to show them as one card. Drag it between them to move it with all it holds.', ], // The display a screen is designed for: its shape, then which way it stands. @@ -322,8 +327,39 @@ 'timezone_hint' => 'For the clock and for switching between light and dark. Empty: each TV uses its own (the browser\'s) time zone.', 'browser_timezone' => 'The browser\'s time zone', 'show_clock' => 'Show the clock in the header', + 'header_title' => 'Title', + 'header_shows' => 'Shows', + 'header_shows_hint' => 'Lit parts show. Offline always shows, so stale numbers never pass for live ones.', + 'header_parts' => [ + 'logo' => 'Logo', + 'name' => 'Title', + 'team' => 'Team', + 'projects' => 'Projects', + 'environment' => 'Environment', + 'period' => 'Period', + 'attention' => 'Problems', + 'live' => 'Live', + ], + 'clock_date' => 'Date', + 'clock_seconds' => 'Seconds', 'fit' => 'On a different screen', 'fit_hint' => 'A display of another shape than the screen\'s shows it as designed, centered with bars around it, or stretched to fill it.', + 'margin' => 'Margin', + 'gap' => 'Spacing', + 'schedule_short' => 'Day and night', + 'sections' => [ + 'display' => 'Display', + 'appearance' => 'Look', + 'data' => 'Data', + 'time' => 'Header', + ], + ], + // How much room a screen leaves around its grid and between its widgets. + 'spacing' => [ + 'none' => 'None', + 's' => 'Small', + 'm' => 'Medium', + 'l' => 'Large', ], 'sections' => [ @@ -338,6 +374,10 @@ 'countdown' => 'Countdown', 'message' => 'Message', 'qr' => 'QR code', + 'qr_look' => 'Logo and colors', + 'qr_modules' => 'Modules', + 'qr_eyes' => 'Eyes', + 'qr_filters' => 'Filters', 'media' => 'Media', 'rotation' => 'Rotation', 'scope' => 'Scope', @@ -468,6 +508,14 @@ 'security' => ['label' => 'Security', 'options' => ['WPA' => 'WPA', 'WEP' => 'WEP', 'nopass' => 'None']], 'hidden_network' => ['label' => 'Hidden network'], 'qr_text' => ['label' => 'Text', 'placeholder' => 'Anything a phone should read'], + 'qr_logo' => ['label' => 'Lumberjack logo in the middle'], + 'qr_color' => ['label' => 'Code color', 'unset' => 'Amber', 'reset' => 'Back to amber'], + 'qr_background' => ['label' => 'Background', 'unset' => 'None', 'reset' => 'No background'], + 'qr_module' => ['label' => 'Modules'], + 'qr_eyes' => ['label' => 'Eyes', 'custom' => 'Outer and inner apart'], + 'qr_outer' => ['label' => 'Outer eye'], + 'qr_inner' => ['label' => 'Inner eye'], + 'qr_filters' => ['label' => 'Filters', 'hint' => 'Up to :max, applied in the order picked.'], 'caption' => ['label' => 'Line under the code', 'placeholders' => ['link' => 'Our status page', 'wifi' => 'Guest wifi', 'text' => 'Scan me', 'image' => 'The loading dock', 'video' => 'This week\'s release', 'page' => 'Grafana']], 'media' => ['label' => 'Shows', 'options' => ['image' => 'An image or camera', 'video' => 'A video', 'page' => 'A web page or YouTube']], 'media_url' => ['label' => 'Addresses', 'placeholder' => 'https://', 'hint' => 'Several show in turn, the same one on every TV at once.'], @@ -834,5 +882,6 @@ 'source' => 'This widget cannot show that.', 'duplicate_id' => 'Two widgets have the same id.', 'overlap' => 'This widget covers a cell another widget already uses.', + 'qr_unscannable' => 'Phones could not read this code reliably: pick colors further apart, or fewer or milder filters.', ], ]; diff --git a/resources/css/screen.css b/resources/css/screen.css index 1a666fa0..938e64a7 100644 --- a/resources/css/screen.css +++ b/resources/css/screen.css @@ -174,6 +174,30 @@ outline-offset: 2px; } +/* A group's title line, the room the widgets on its top row leave it (GROUP_TITLE_LINE). */ +.lj-tile[data-kind='group'] .lj-tile-title { + line-height: 1.2; +} + +/* + * No space between widgets: square corners, and each tile half a pixel over its + * neighbours, so two borders make one line. A tile with a problem lies on top, its + * color whole. + */ +.lj-grid[data-gap='none'] > .lj-tile { + margin: -0.5px; + border-radius: 0; +} + +.lj-grid[data-gap='none'] + > .lj-tile:is( + [data-status='degraded'], + [data-status='down'], + [data-status='recovering'] + ) { + z-index: 1; +} + /* Kiosk: an empty cell is a gap, not a tile. */ .lj-kiosk .lj-tile[data-kind='empty'] { border-color: transparent; diff --git a/resources/js/components/lj/screen/frame.tsx b/resources/js/components/lj/screen/frame.tsx index d277d0ca..28fb4d9a 100644 --- a/resources/js/components/lj/screen/frame.tsx +++ b/resources/js/components/lj/screen/frame.tsx @@ -3,7 +3,7 @@ import type { ComponentProps, ReactNode, Ref } from 'react'; import { LogMark } from '@/components/lj/logo'; import { useT } from '@/lib/i18n'; import { cn } from '@/lib/utils'; -import type { Screen } from './types'; +import type { HeaderPart, Screen } from './types'; type Size = { w: number; h: number }; @@ -80,6 +80,9 @@ function useWindowSize(): Size { return size; } +/** How much of the medium margin and gap each spacing is. */ +const SPACING: Record = { none: 0, s: 0.5, m: 1, l: 1.6 }; + /** * A screen as the TV shows it, header and grid, laid out at a display's size: the * kiosk's whole window, or the designer's preview of a resolution. Everything inside @@ -122,6 +125,7 @@ export function KioskFrame({ const turned = kiosk && !view && rotation !== 0; const size = view ?? windowSize; const box = fitBox(size, ratioOf(screen), screen.fit); + const margin = SPACING[screen.margin] ?? 1; return (
- -
-

- {header.title} -

- - {header.subtitle} + {!screen.header.hide.includes('logo') && ( + + )} +
+ {!screen.header.hide.includes('name') && ( +

+ {header.title} +

+ )} + {header.subtitle && ( + + {header.subtitle} + + )}
@@ -184,7 +196,7 @@ export function KioskFrame({ (screen.show_header ? ( banner ) : ( -
+
{banner}
))} @@ -193,13 +205,15 @@ export function KioskFrame({
screen.scope.projects.includes(p.uuid)) .map((p) => p.name) : [t('screens.kiosk.all_projects')]; + const parts: [HeaderPart, string][] = [ + ['team', team], + ['projects', names.join(', ')], + [ + 'environment', + screen.scope.environment ?? t('screens.kiosk.all_environments'), + ], + ['period', t(`screens.periods.${screen.scope.period}`)], + ]; - return [ - team, - names.join(', '), - screen.scope.environment ?? t('screens.kiosk.all_environments'), - t(`screens.periods.${screen.scope.period}`), - ].join(' · '); + return parts + .filter(([part]) => !screen.header.hide.includes(part)) + .map(([, text]) => text) + .join(' · '); } /** A time as the screen's clock shows it, in the screen's time zone (else the browser's). */ @@ -243,6 +269,10 @@ export function kioskClock(screen: Screen, at: number): string { timeZone: screen.timezone ?? undefined, hour: '2-digit', minute: '2-digit', + second: screen.header.seconds ? '2-digit' : undefined, + weekday: screen.header.date ? 'short' : undefined, + day: screen.header.date ? 'numeric' : undefined, + month: screen.header.date ? 'short' : undefined, hourCycle: screen.clock_format === '12' ? 'h12' : 'h23', }).format(new Date(at)); } @@ -312,7 +342,10 @@ export function KioskStatus({ attention, offline, clock, + hide = [], }: { + /** Parts the screen's header hides; being offline always shows. */ + hide?: HeaderPart[]; attention: number; /** "Offline since 12:03", or null while live. */ offline: string | null; @@ -323,19 +356,23 @@ export function KioskStatus({ return ( <> - {attention > 0 && offline === null && ( - - {t('screens.kiosk.attention', {}, attention)} - - )} + {attention > 0 && + offline === null && + !hide.includes('attention') && ( + + {t('screens.kiosk.attention', {}, attention)} + + )} {offline === null ? ( - - + !hide.includes('live') && ( + + + ) ) : ( = { }; import { TreeSelect } from '@/components/lj/tree-select'; -import { Plus, Settings, X } from 'lucide-react'; +import { + AlignCenter, + AlignLeft, + AlignVerticalJustifyCenter, + AlignVerticalJustifyStart, + Expand, + Moon, + Plus, + RectangleHorizontal, + RectangleVertical, + Scaling, + Shrink, + SlidersHorizontal, + Sun, + SunMoon, + Settings, + X, +} from 'lucide-react'; import { useEffect, useRef, useState, useSyncExternalStore } from 'react'; import type { ReactNode } from 'react'; import { @@ -28,12 +45,13 @@ import type { Schema, SchemaField, Screen, + ScreenSpacing, Source, Sources, Widget, WidgetScope, } from './types'; -import { MAX_SLIDES, MAX_ZONES, ROTATING_KINDS } from './types'; +import { HEADER_PARTS, MAX_SLIDES, MAX_ZONES, ROTATING_KINDS } from './types'; export type Catalog = { schema: Schema; @@ -75,6 +93,10 @@ export type Catalog = { filters?: Record; /** What some filter names are shown as, by name. */ filterLabels?: Record; + /** Widgets a group holds: the group draws their card. */ + grouped?: string[]; + /** The shapes a screen can have, such as 16:9 (ScreenAspect). */ + aspects?: string[]; }; const ALL = '*'; @@ -87,6 +109,216 @@ const chip = (on: boolean) => : 'border-line-strong bg-rail text-ink-2 hover:text-ink', ); +/** A letter as large as each text size draws, relative to the others. */ +const SIZE_GLYPHS: Record = Object.fromEntries( + Object.entries({ s: 11, m: 14, l: 17, xl: 20 }).map(([size, px]) => [ + size, + + A + , + ]), +); + +/** Options picked from icons that show what each does, with the icon per value. */ +const CHOICE_ICONS: Record> = { + align: { left: , center: }, + valign: { + top: , + middle: , + }, + text_size: { auto: , ...SIZE_GLYPHS }, + title_size: SIZE_GLYPHS, +}; + +/** Room around the grid or between widgets, per ScreenSpacing, in the icons' units. */ +const SPACING_ROOM: Record = { + none: 0, + s: 1.5, + m: 3, + l: 4.5, +}; + +/** + * A screen's margin or gap as a picture: a widget inset that far in the screen, or two + * widgets that far apart (square and on one line at none, as the screen draws them). + */ +function SpacingIcon({ + kind, + value, +}: { + kind: 'margin' | 'gap'; + value: ScreenSpacing; +}) { + const room = SPACING_ROOM[value]; + const w = (14 - room) / 2; + + return ( + + ); +} + +/** A screen's shape as a picture: a frame of its width over its height. */ +function AspectIcon({ ratio }: { ratio: number }) { + const w = ratio >= 1 ? 14 : 14 * ratio; + const h = ratio >= 1 ? 14 / ratio : 14; + + return ( + + ); +} + +/** + * Values as icons, each over its name, the picked ones lit: a row of a few, or a grid of + * many (the QR library's parts). Several values make it a pick of several. + */ +function IconChoice({ + label, + value, + options, + onChange, + grid = false, +}: { + label: string; + value: string | string[]; + options: { value: string; label: string; icon: ReactNode }[]; + onChange: (value: string) => void; + grid?: boolean; +}) { + const many = Array.isArray(value); + const on = (v: string) => (many ? value.includes(v) : v === value); + const box = useRef(null); + + // A scrolling grid shows what is picked, the first time it shows (its section opened). + useEffect(() => { + const el = box.current; + + if (!el) { + return; + } + + const seen = new ResizeObserver(() => { + if (el.clientHeight === 0) { + return; + } + + seen.disconnect(); + const first = el.querySelector( + '[aria-checked="true"], [aria-pressed="true"]', + ); + + if (first) { + el.scrollTop = + first.getBoundingClientRect().top - + el.getBoundingClientRect().top - + 4; + } + }); + seen.observe(el); + + return () => seen.disconnect(); + }, []); + + return ( +
+ {options.map((o) => ( + + ))} +
+ ); +} + function Section({ title, open, @@ -501,6 +733,137 @@ export function WidgetInspector({ ); } + // The QR library's parts come with pictures of their own, as SVG it ships. + const pictures = field.icons + ? Object.fromEntries( + Object.entries(field.icons).map(([v, svg]) => [ + v, + , + ]), + ) + : undefined; + const icons = CHOICE_ICONS[field.key] ?? pictures; + // A field's name, with a way back to the default once it is changed. + const labelWithReset = (key: string, changed: boolean) => ( + + {fieldLabel(key)} + {changed && ( + + )} + + ); + const optionLabel = (v: string) => + field.labels?.[v] ?? t(`screens.fields.${field.key}.options.${v}`); + + if (field.type === 'color') { + const color = typeof raw === 'string' ? raw : null; + + return ( +
+ +
+ + target.set(field.key, e.target.value) + } + className="h-8 w-10 shrink-0 cursor-pointer rounded border border-line-strong bg-rail p-0.5" + /> + {color ? ( + + ) : ( + + {t(`screens.fields.${field.key}.unset`)} + + )} +
+
+ ); + } + + if (field.type === 'choices' && icons) { + const picked = Array.isArray(raw) ? raw : []; + const max = field.max ?? Infinity; + + return ( +
+ {labelWithReset(field.key, picked.length > 0)} + ({ + value: v, + label: optionLabel(v), + icon: icons[v], + }))} + onChange={(v) => { + const next = picked.includes(v) + ? picked.filter((p) => p !== v) + : [...picked, v].slice(-max); + + target.set( + field.key, + next.length > 0 ? next : null, + ); + }} + /> + + {t(`screens.fields.${field.key}.hint`, { max })} + +
+ ); + } + + if (icons && field.type === 'select' && !scope && !inherited) { + return ( +
+ {labelWithReset( + field.key, + raw !== undefined && raw !== null, + )} + 5} + label={fieldLabel(field.key)} + value={String(raw ?? field.default)} + options={(field.options ?? []).map((v) => ({ + value: v, + label: optionLabel(v), + icon: icons[v] ?? , + }))} + onChange={(v) => + target.set( + field.key, + v === field.default ? null : v, + ) + } + /> +
+ ); + } + // An External JSON value's paths are set in a dialog, summed up here. // A connected source's answer has no history to compare with or to draw. if (connected && ['compare', 'sparkline'].includes(field.key)) { @@ -642,6 +1005,10 @@ export function WidgetInspector({ source?.low_is_bad ?? false) : option(schema, widget, field.key) === true; + // In a group the group's card is the one drawn: none of its own to show. + const lockedOff = + field.key === 'card' && + (catalog.grouped ?? []).includes(widget.id); return ( ); } @@ -1335,9 +1711,9 @@ export function WidgetInspector({ const value = ( <> - {widget.type === 'empty' && ( + {(widget.type === 'empty' || widget.type === 'group') && (

- {t('screens.inspector.empty_hint')} + {t(`screens.inspector.${widget.type}_hint`)}

)} @@ -1768,6 +2144,12 @@ export function WidgetInspector({ } /** Settings of the whole screen, shown while no widget is selected. */ +const SETTINGS_TABS = ['display', 'appearance', 'data', 'time'] as const; +type SettingsTab = (typeof SETTINGS_TABS)[number]; + +/** The settings tab open last, kept while the designer is open: back from a widget, it is still there. */ +let lastSettingsTab: SettingsTab = 'display'; + export function ScreenSettings({ screen, catalog, @@ -1782,9 +2164,17 @@ export function ScreenSettings({ }) { const t = useT(); const scope = screen.scope; + const hint = 'col-span-2 text-xs text-ink-3'; + const [tab, setTab] = useState(lastSettingsTab); + const pickTab = (id: SettingsTab) => { + lastSettingsTab = id; + setTab(id); + }; + const setHeader = (changes: Partial) => + onChange({ header: { ...screen.header, ...changes } }); return ( -
+

{t('screens.settings.title')} @@ -1804,227 +2194,501 @@ export function ScreenSettings({ onChange={(e) => onChange({ name: e.target.value })} />

-
- - {t('screens.settings.projects')} - - {catalog.teamProjects.map((p) => ( -
+ + {tab === 'display' && ( +
+
+ + {t('screens.designer.aspect')} + + { + const [w, h] = a.split(':').map(Number); + + return { + value: a, + label: t(`screens.aspect.${a}`), + icon: ( + + ), + }; + }, + )} + onChange={(v) => onChange({ aspect: v })} + /> +
+
+ + {t('screens.designer.orientation')} + + ({ + value: o, + label: t(`screens.orientation.${o}`), + icon: + o === 'landscape' ? ( + + ) : ( + + ), + }), + )} + onChange={(v) => onChange({ - scope: { - ...scope, - projects: e.target.checked - ? [...scope.projects, p.uuid] - : scope.projects.filter( - (u) => u !== p.uuid, - ), - }, + orientation: v as Screen['orientation'], }) } /> - {p.name} - - ))} - - {t('screens.settings.projects_hint')} - - -
-
- - + { + value: 'fill', + label: t('screens.fit.fill'), + icon: , + }, + ]} + onChange={(v) => + onChange({ fit: v as Screen['fit'] }) + } + /> +
+ + {t('screens.settings.fit_hint')} +
-
- - + )} + + {tab === 'appearance' && ( +
+
+ + {t('screens.designer.theme')} + + , + }, + { + value: 'light', + label: t('screens.theme.light'), + icon: , + }, + { + value: 'schedule', + label: t('screens.settings.schedule_short'), + icon: , + }, + ]} + onChange={(v) => + onChange({ theme: v as Screen['theme'] }) + } + /> +
+ {screen.theme === 'schedule' && ( + <> + {(['light_from', 'light_to'] as const).map( + (key) => ( +
+ + + e.target.value && + onChange({ + [key]: e.target.value, + }) + } + /> +
+ ), + )} + + {t('screens.theme.schedule')} ·{' '} + {t('screens.designer.now_theme', { + theme: t(`screens.theme.${theme}`), + })} + + + )} + {(['margin', 'gap'] as const).map((key) => ( +
+ + {t(`screens.settings.${key}`)} + + ({ + value: s, + label: t(`screens.spacing.${s}`), + icon: ( + + ), + }), + )} + onChange={(v) => + onChange({ [key]: v as ScreenSpacing }) + } + /> +
+ ))}
-
-
- - onChange({ timezone: zone || null })} - /> - - {t('screens.settings.timezone_hint')} - -
- - {screen.show_header && ( - )} - {screen.show_header && screen.show_clock && ( -
- - + onChange({ + scope: { + ...scope, + environment: e.target.value || null, + }, + }) + } + > + - ))} - + {catalog.environments.map((env) => ( + + ))} + +
+
+ + +
)} -
- - - {screen.theme === 'schedule' && ( - <> -
-
+ + {screen.show_header && ( + <> +
- e.target.value && - onChange({ light_from: e.target.value }) + setHeader({ + title: e.target.value || null, + }) } />
-
- - - e.target.value && - onChange({ light_to: e.target.value }) +
+ + {t('screens.settings.header_shows')} + +
+ {HEADER_PARTS.map((part) => { + const on = + !screen.header.hide.includes(part); + + return ( + + ); + })} +
+ + {t('screens.settings.header_shows_hint')} + +
+ + + )} + {screen.show_header && screen.show_clock && ( + <> +
+ + {t('screens.fields.format.label')} + + ({ + value: format, + label: t( + `screens.fields.format.options.${format}`, + ), + icon: ( + + {format} + + ), + }), + )} + onChange={(v) => + onChange({ + clock_format: v as '24' | '12', + }) } />
-
- - {t('screens.designer.now_theme', { - theme: t(`screens.theme.${theme}`), - })} - - - )} -
-
- - - - {t('screens.settings.fit_hint')} - -
+ {(['date', 'seconds'] as const).map((key) => ( + + ))} + + )} +
+ + + onChange({ timezone: zone || null }) + } + /> +
+ + {t('screens.settings.timezone_hint')} + +
+ )}
); } diff --git a/resources/js/components/lj/screen/lib.ts b/resources/js/components/lj/screen/lib.ts index f5c59018..23b6b85f 100644 --- a/resources/js/components/lj/screen/lib.ts +++ b/resources/js/components/lj/screen/lib.ts @@ -565,7 +565,7 @@ export function newWidgetId(): string { return 'w' + Math.random().toString(36).slice(2, 10); } -type Box = Pick; +type Box = Pick & { type?: WidgetKind }; /** Whether a widget lies inside the grid, so the TV shows it. */ export function fits(box: Box, cols: number, rows: number): boolean { @@ -577,7 +577,25 @@ export function fits(box: Box, cols: number, rows: number): boolean { ); } -/** Whether no widget but `except` covers a cell of the box, inside the grid or not. */ +/** + * Whether a group holds a widget, a group too: one wholly inside it, on fewer cells (a + * 1 x 1 group holds nothing). ScreenLayout::holds(). + */ +export function groupHolds(group: Box, box: Box): boolean { + return ( + group.type === 'group' && + (box.w < group.w || box.h < group.h) && + box.x >= group.x && + box.y >= group.y && + box.x + box.w <= group.x + group.w && + box.y + box.h <= group.y + group.h + ); +} + +/** + * Whether no widget but `except` covers a cell of the box, inside the grid or not; a + * group holding the box, or held by it, is no obstacle. + */ export function isFree(widgets: Widget[], box: Box, except?: string): boolean { return widgets.every( (o) => @@ -585,10 +603,48 @@ export function isFree(widgets: Widget[], box: Box, except?: string): boolean { o.x >= box.x + box.w || box.x >= o.x + o.w || o.y >= box.y + box.h || - box.y >= o.y + o.h, + box.y >= o.y + o.h || + groupHolds(o, box) || + groupHolds(box, o), ); } +/** + * Widgets in the order they are drawn: groups first, outer before inner, so each lies + * behind what it holds; the others keep their order. + */ +export function layered(widgets: Widget[]): Widget[] { + const order = (w: Widget) => (w.type === 'group' ? -w.w * w.h : 0); + + return [...widgets].sort((a, b) => order(a) - order(b)); +} + +/** + * A widget moved to a top left, a group with all it holds: the new top left of each, or + * null when one would leave the grid or land on another widget. + */ +export function moveTo( + widgets: Widget[], + cols: number, + rows: number, + widget: Widget, + to: { x: number; y: number }, +): Record | null { + const going = widgets.filter( + (o) => o.id === widget.id || groupHolds(widget, o), + ); + const rest = widgets.filter((o) => !going.includes(o)); + const moved = going.map((o) => ({ + ...o, + x: o.x + to.x - widget.x, + y: o.y + to.y - widget.y, + })); + + return moved.every((o) => canPlace(rest, cols, rows, o)) + ? Object.fromEntries(moved.map((o) => [o.id, { x: o.x, y: o.y }])) + : null; +} + /** Whether a widget can go there: inside the grid, on cells no other widget covers. */ export function canPlace( widgets: Widget[], @@ -685,9 +741,11 @@ export function swapTarget( moving: Widget, cell: { x: number; y: number }, ): string | null { + // A group under the pointer is where the widget goes, not one to trade places with. const other = widgets.find( (o) => o.id !== moving.id && + o.type !== 'group' && cell.x >= o.x && cell.x < o.x + o.w && cell.y >= o.y && diff --git a/resources/js/components/lj/screen/types.ts b/resources/js/components/lj/screen/types.ts index 5167648c..394e4939 100644 --- a/resources/js/components/lj/screen/types.ts +++ b/resources/js/components/lj/screen/types.ts @@ -40,7 +40,8 @@ export type WidgetKind = | 'message' | 'qr' | 'media' - | 'empty'; + | 'empty' + | 'group'; export type WidgetScope = { projects?: string[]; @@ -57,6 +58,22 @@ export type ScreenTheme = 'dark' | 'light' | 'schedule'; /** ScreenAspect: the display's shape, landscape; ScreenOrientation turns it on its side. */ export type ScreenOrientation = 'landscape' | 'portrait'; +/** None, small, medium (what screens had before it could be chosen) or large. */ +export type ScreenSpacing = 'none' | 's' | 'm' | 'l'; + +/** Parts of the header a screen can hide; being offline always shows. Screen::HEADER_PARTS. */ +export const HEADER_PARTS = [ + 'logo', + 'name', + 'team', + 'projects', + 'environment', + 'period', + 'attention', + 'live', +] as const; +export type HeaderPart = (typeof HEADER_PARTS)[number]; + export type Screen = { uuid: string; name: string; @@ -67,12 +84,25 @@ export type Screen = { orientation: ScreenOrientation; /** On a display of another shape: keep the screen's (bars around it) or fill it. */ fit: 'keep' | 'fill'; + /** Room around the grid; see ScreenSpacing. */ + margin: ScreenSpacing; + /** Room between widgets; see ScreenSpacing. */ + gap: ScreenSpacing; /** Whether the TV shows the name, scope, live state and clock above the grid. */ show_header: boolean; /** Whether that header shows the clock. */ show_clock: boolean; /** The header's clock: '24' or '12' hours. */ clock_format: '24' | '12'; + /** What the header shows; see Screen::header(). */ + header: { + hide: HeaderPart[]; + /** Instead of the screen's name; null: the name. */ + title: string | null; + /** The clock's date and seconds. */ + date: boolean; + seconds: boolean; + }; theme: ScreenTheme; light_from: string; light_to: string; @@ -99,11 +129,21 @@ export type SchemaField = { | 'textarea' | 'number' | 'checks' + | 'color' + | 'choices' | 'data_source' | 'timezone' | 'projects' | 'environment'; options?: string[]; + /** An SVG picture per option (the QR library's parts), picked from a grid of them. */ + icons?: Record; + /** Each option's label, where it comes with the options (the QR library's). */ + labels?: Record; + /** Choices: how many may be picked. */ + max?: number; + /** A color field: what the picker opens on while unset. */ + swatch?: string; /** The options under headings: group id to its values. */ groups?: Record; default: string | boolean | null; @@ -167,6 +207,7 @@ export const LAYOUT_KINDS: WidgetKind[] = [ 'qr', 'media', 'empty', + 'group', ]; export const ROTATING_KINDS: WidgetKind[] = [ 'stat', diff --git a/resources/js/components/lj/screen/widgets.tsx b/resources/js/components/lj/screen/widgets.tsx index 05ea47cc..05d153d8 100644 --- a/resources/js/components/lj/screen/widgets.tsx +++ b/resources/js/components/lj/screen/widgets.tsx @@ -222,6 +222,9 @@ const TITLE_SIZE: Record = { xl: 'calc(var(--lj-cell-font) * 1.7)', }; +/** A group's title line, as tall as its font times this (screen.css). */ +const GROUP_TITLE_LINE = 1.2; + const TEXT_SCALE: Record = { auto: 1, s: 0.85, @@ -365,6 +368,8 @@ export type TileProps = { incident?: boolean; designer?: boolean; flash?: boolean; + /** The groups holding the tile, which draw its card: it has none of its own. */ + holders?: Widget[]; /** Extra content above the tile's own: the designer's badge and resize handle. */ decoration?: ReactNode; /** In the tile's top right corner, the period label moving aside: the designer's gear. */ @@ -373,6 +378,29 @@ export type TileProps = { onStatus?: (id: string, status: Status) => void; } & Omit, 'children'>; +/** + * How far down a widget on a group's top row starts: below the group's top padding and + * title line, for each group holding it whose title shows. + */ +function titleInset( + schema: Schema, + holders: Widget[], + widget: Widget, +): string | undefined { + const above = holders + .filter( + (g) => + g.y === widget.y && + option(schema, g, 'show_title') !== false, + ) + .map( + (g) => + `0.8 * var(--lj-cell-font) + ${TITLE_SIZE[option(schema, g, 'title_size') ?? 'm']} * ${GROUP_TITLE_LINE}`, + ); + + return above.length > 0 ? `calc(${above.join(' + ')})` : undefined; +} + /** * One tile of a screen, the same in the designer and on the TV. Its type draws the data * of the source it shows now; its state colors it. @@ -389,6 +417,7 @@ export function WidgetTile({ incident = false, designer = false, flash = false, + holders = [], decoration, corner, onStatus, @@ -472,7 +501,9 @@ export function WidgetTile({ single ?? source?.label ?? t(`screens.kinds.${widget.type}`)); - const showTitle = opt('show_title') !== false; + // An empty cell has no title. + const showTitle = + opt('show_title') !== false && widget.type !== 'empty'; useEffect(() => { onStatus?.(widget.id, status); @@ -530,7 +561,9 @@ export function WidgetTile({ let body: ReactNode = null; - if (widget.type === 'empty') { + if (widget.type === 'group') { + body = null; + } else if (widget.type === 'empty') { body = designer ? ( {t('screens.kinds.empty')} @@ -608,7 +641,11 @@ export function WidgetTile({ className={cn('lj-tile', className)} data-kind={widget.type} // No card: no background or border while calm; a problem still brings them. - data-plain={opt('card') === false || undefined} + data-plain={ + holders.length > 0 || + opt('card') === false || + undefined + } // Media to the tile's edges; its title and line keep their room. data-bare={ (widget.type === 'media' && @@ -625,6 +662,7 @@ export function WidgetTile({ style={{ gridColumn: `${widget.x + 1} / span ${widget.w}`, gridRow: `${widget.y + 1} / span ${widget.h}`, + marginTop: titleInset(schema, holders, stored), textAlign: align, ['--lj-text-scale' as string]: TEXT_SCALE[textSize] ?? 1, visibility: hidden && !designer ? 'hidden' : undefined, @@ -633,18 +671,14 @@ export function WidgetTile({ }} > {decoration} - {(corner || - (showTitle && - widget.type !== 'empty' && - title && - cornerText)) && ( + {(corner || (showTitle && title && cornerText)) && ( // The corner label, as far from the top as from the right edge, with the // designer's gear taking its place while it shows. - {showTitle && widget.type !== 'empty' && title && ( + {showTitle && title && ( )} - {showTitle && widget.type !== 'empty' && title && ( + {showTitle && title && ( // Invisible twins of the label keep room for it on the right, and on the // left too for a centered title, so that stays centered on the tile.
= { qr: null, media: null, empty: null, + group: null, }; /** A transparent pixel, as the drag picture of a tile moved on the grid. */ @@ -256,9 +260,12 @@ type Settings = Pick< | 'aspect' | 'orientation' | 'fit' + | 'margin' + | 'gap' | 'show_header' | 'show_clock' | 'clock_format' + | 'header' | 'theme' | 'light_from' | 'light_to' @@ -315,9 +322,12 @@ const SETTINGS: (keyof Settings)[] = [ 'aspect', 'orientation', 'fit', + 'margin', + 'gap', 'show_header', 'show_clock', 'clock_format', + 'header', 'theme', 'light_from', 'light_to', @@ -461,7 +471,7 @@ export default function EditScreen(props: Props) { w: number; h: number; ok: boolean; - /** Dropping here moves these widgets to the dragged one's old cells. */ + /** Dropping here moves these widgets too: to the dragged one's old cells, or along with a group. */ swap?: Record; } | null>(null); const resizing = useRef<{ @@ -516,6 +526,10 @@ export default function EditScreen(props: Props) { periods: PERIODS, filters, filterLabels: props.filter_labels ?? {}, + aspects: props.aspects, + grouped: screen.widgets + .filter((w) => screen.widgets.some((g) => groupHolds(g, w))) + .map((w) => w.id), }; // The data follows what is saved, so a widget refetches once its new settings are stored. const { data } = useScreenData( @@ -652,11 +666,45 @@ export default function EditScreen(props: Props) { setSelected(widget.id); }; - /** Whether the widget may take that box; the screen's other widgets stay put. */ + /** + * Whether the widget may take that box; the screen's other widgets stay put. A group + * keeps all it holds, so it never gets smaller than its widgets. + */ const placeable = ( id: string | undefined, - box: { x: number; y: number; w: number; h: number }, - ) => canPlace(latest.current.widgets, screen.cols, screen.rows, box, id); + box: { x: number; y: number; w: number; h: number; type?: WidgetKind }, + ) => { + const widgets = latest.current.widgets; + const widget = widgets.find((w) => w.id === id); + const next = { type: widget?.type, ...box }; + + return ( + canPlace(widgets, screen.cols, screen.rows, next, id) && + (!widget || + widgets.every( + (o) => !groupHolds(widget, o) || groupHolds(next, o), + )) + ); + }; + + /** A widget moved, a group with all it holds, when they all fit there. */ + const move = (widget: Widget, to: { x: number; y: number }) => { + const moves = moveTo( + latest.current.widgets, + screen.cols, + screen.rows, + widget, + to, + ); + + if (moves) { + setWidgets((widgets) => + widgets.map((w) => + moves[w.id] ? { ...w, ...moves[w.id] } : w, + ), + ); + } + }; const remove = (id: string) => { setWidgets((widgets) => widgets.filter((w) => w.id !== id)); @@ -773,14 +821,18 @@ export default function EditScreen(props: Props) { const fromTop = widget.y > 0 && widget.y + widget.h >= screen.rows; const w = Math.max(1, widget.w + (fromLeft ? -dx : dx)); const h = Math.max(1, widget.h + (fromTop ? -dy : dy)); - const box = e.shiftKey - ? { - x: fromLeft ? widget.x + widget.w - w : widget.x, - y: fromTop ? widget.y + widget.h - h : widget.y, - w, - h, - } - : { x: widget.x + dx, y: widget.y + dy, w: widget.w, h: widget.h }; + if (!e.shiftKey) { + move(widget, { x: widget.x + dx, y: widget.y + dy }); + + return; + } + + const box = { + x: fromLeft ? widget.x + widget.w - w : widget.x, + y: fromTop ? widget.y + widget.h - h : widget.y, + w, + h, + }; if (placeable(widget.id, box)) { patch(widget.id, box); @@ -914,14 +966,31 @@ export default function EditScreen(props: Props) { const cell = cellAt(e.clientX, e.clientY); let box = { x: cell.x - d.dx, y: cell.y - d.dy, w: d.w, h: d.h }; - let ok = placeable(d.tile, box); - let swap: Record | undefined; const moving = d.tile ? latest.current.widgets.find((w) => w.id === d.tile) : undefined; + // A group takes all it holds along. + const moves = moving + ? moveTo( + latest.current.widgets, + screen.cols, + screen.rows, + moving, + box, + ) + : null; + let ok = moving + ? moves !== null + : placeable(undefined, { ...box, type: d.kind }); + let swap: Record | undefined = + moves && moving + ? Object.fromEntries( + Object.entries(moves).filter(([id]) => id !== moving.id), + ) + : undefined; // Onto other widgets: swap places when they fit, the footprint shows where it goes. - if (!ok && moving) { + if (!ok && moving && moving.type !== 'group') { // Whole widgets under the footprint trade places with it as a group. const group = swapGroup( latest.current.widgets, @@ -1031,10 +1100,10 @@ export default function EditScreen(props: Props) { const outside = screen.widgets.filter( (w) => !fits(w, screen.cols, screen.rows), ); - // Top left to bottom right, so Tab follows the screen. - const tiles = screen.widgets - .filter(inGrid) - .sort((a, b) => a.y - b.y || a.x - b.x); + // Top left to bottom right, so Tab follows the screen; groups behind what they hold. + const tiles = layered( + screen.widgets.filter(inGrid).sort((a, b) => a.y - b.y || a.x - b.x), + ); const current = screen.widgets.find((w) => w.id === selected) ?? null; const theme = themeAt(screen, now); const [aw, ah] = screen.aspect.split(':').map(Number); @@ -1141,6 +1210,9 @@ export default function EditScreen(props: Props) { clockFormat={screen.clock_format} pinned={widget.id === selected ? pinned : undefined} incident={incident} + holders={screen.widgets.filter((g) => + groupHolds(g, widget), + )} designer tabIndex={0} role="button" @@ -1820,73 +1892,6 @@ export default function EditScreen(props: Props) { ))} - -
- {(['landscape', 'portrait'] as const).map( - (o) => ( - - ), - )} -
+ ); +} + +function DangerSection({ project, move_targets }: Props) { const t = useT(); const [confirming, setConfirming] = useState(false); const [typed, setTyped] = useState(''); @@ -2493,6 +2671,7 @@ function DangerSection({ project }: Props) { return (
+

{t('settings.danger.description')}

{!confirming ? (
diff --git a/routes/web/projects.php b/routes/web/projects.php index 41b7c7ce..81615532 100644 --- a/routes/web/projects.php +++ b/routes/web/projects.php @@ -18,6 +18,7 @@ Route::prefix('projects/{project}')->scopeBindings()->middleware(['can:view,project', FollowProjectTeam::class])->group(function () { Route::get('/', OverviewController::class)->name('projects.show'); Route::delete('/', [ProjectController::class, 'destroy'])->name('projects.destroy'); + Route::put('team', [ProjectController::class, 'move'])->name('projects.move'); require __DIR__.'/projects/issues.php'; require __DIR__.'/projects/performance.php'; diff --git a/tests/Feature/Domains/Projects/Http/Controllers/MoveProjectTest.php b/tests/Feature/Domains/Projects/Http/Controllers/MoveProjectTest.php new file mode 100644 index 00000000..29812115 --- /dev/null +++ b/tests/Feature/Domains/Projects/Http/Controllers/MoveProjectTest.php @@ -0,0 +1,181 @@ +project = Project::factory()->withToken('lj_srv_move-token')->create(['slug' => 'shop', 'issue_prefix' => 'SHOP']); + $this->from = $this->project->team; + $this->to = Team::factory()->create(['name' => 'Agency']); + $this->user = User::factory()->inTeam($this->from, TeamRole::Admin)->create(); + $this->to->members()->attach($this->user, ['role' => TeamRole::Owner->value]); + $this->move = fn (array $input = []) => $this->actingAs($this->user) + ->put(route('projects.move', $this->project), [...['team' => $this->to->uuid, 'slug' => 'shop', 'issue_prefix' => 'SHOP'], ...$input]); +}); + +describe('moving a project', function () { + it('moves it with its data, and its ingest token keeps working', function () { + $issue = Issue::factory()->for($this->project)->create(); + Occurrence::factory()->for($issue)->create(['project_id' => $this->project->id]); + + ($this->move)()->assertSessionHasNoErrors()->assertRedirect(route('projects.settings', $this->project)); + + expect($this->project->refresh()->team_id)->toBe($this->to->id) + ->and(Issue::query()->where('project_id', $this->project->id)->count())->toBe(1) + ->and(Occurrence::query()->where('project_id', $this->project->id)->count())->toBe(1); + + $this->postJson('/api/ingest', $this->batch([$this->exceptionEvent()]), ['Authorization' => 'Bearer lj_srv_move-token'])->assertStatus(202); + }); + + it('is logged once, naming who moved it and both teams', function () { + ($this->move)(); + + $entry = AdminAuditEntry::query()->where('action', AdminAction::ProjectMoved)->sole(); + expect($entry->user_id)->toBe($this->user->id) + ->and($entry->data)->toMatchArray(['project' => $this->project->uuid, 'from' => $this->from->name, 'to' => 'Agency']); + }); +}); + +describe('who may move it', function () { + it('forbids a member of the source team', function () { + $this->from->members()->updateExistingPivot($this->user->id, ['role' => TeamRole::Member->value]); + + ($this->move)()->assertForbidden(); + expect($this->project->refresh()->team_id)->toBe($this->from->id); + }); + + it('forbids an admin of the source team who does not administer the target', function () { + $this->to->members()->updateExistingPivot($this->user->id, ['role' => TeamRole::Member->value]); + + ($this->move)()->assertForbidden(); + expect($this->project->refresh()->team_id)->toBe($this->from->id); + }); + + it('offers only the other teams the user administers', function () { + Team::factory()->create()->members()->attach($this->user, ['role' => TeamRole::Member->value]); + + $this->actingAs($this->user)->get(route('projects.settings', $this->project)) + ->assertInertia(fn ($page) => $page->where('move_targets', [['uuid' => $this->to->uuid, 'name' => 'Agency', 'slug' => 'shop', 'issue_prefix' => 'SHOP']])); + }); +}); + +describe('a slug the target team has already', function () { + beforeEach(fn () => Project::factory()->for($this->to)->create(['slug' => 'shop', 'issue_prefix' => 'SHOP'])); + + it('is suggested with a number', function () { + $this->actingAs($this->user)->get(route('projects.settings', $this->project)) + ->assertInertia(fn ($page) => $page->where('move_targets.0.slug', 'shop-2')->where('move_targets.0.issue_prefix', 'SHOP2')); + }); + + it('is rejected', function () { + ($this->move)()->assertSessionHasErrors(['slug', 'issue_prefix']); + expect($this->project->refresh()->team_id)->toBe($this->from->id); + }); + + it('moves under a new one', function () { + ($this->move)(['slug' => 'shop-2', 'issue_prefix' => 'shop2'])->assertSessionHasNoErrors(); + + expect($this->project->refresh())->team_id->toBe($this->to->id)->slug->toBe('shop-2')->issue_prefix->toBe('SHOP2'); + }); +}); + +describe('alerts', function () { + it('takes its own channels along and lets go of the old team\'s rules and channels', function () { + $own = NotificationChannel::factory()->create(['team_id' => $this->from->id, 'project_id' => $this->project->id]); + $shared = NotificationChannel::factory()->create(['team_id' => $this->from->id]); + $teamRule = AlertRule::query()->where('team_id', $this->from->id)->firstOrFail(); + $ownRule = AlertRule::factory()->regression()->for($this->project)->create(); + $teamRule->addOnsFor($this->project)->attach($own); + $ownRule->channels()->attach([$own->id, $shared->id]); + + ($this->move)()->assertSessionHasNoErrors(); + + expect($own->refresh()->team_id)->toBe($this->to->id) + ->and($shared->refresh()->team_id)->toBe($this->from->id) + ->and(DB::table('project_alert_rule_channel')->where('project_id', $this->project->id)->exists())->toBeFalse() + ->and($ownRule->channels()->pluck('notification_channels.id')->all())->toBe([$own->id]); + }); +}); + +describe('MCP tokens', function () { + it('lose the project', function () { + $token = McpToken::factory()->create(['team_id' => $this->from->id, 'all_projects' => false]); + $token->projects()->attach($this->project); + + ($this->move)(); + + expect($token->projects()->exists())->toBeFalse(); + }); +}); + +describe('screens of the old team', function () { + it('drop the project, and a scope left empty shows nothing rather than everything', function () { + $other = Project::factory()->for($this->from)->create(); + $widget = fn (string $id, array $projects): array => ['id' => $id, 'type' => 'stat', 'source' => 'requests', 'x' => 0, 'y' => 0, 'w' => 1, 'h' => 1, 'scope' => ['projects' => $projects]]; + $shared = Screen::factory()->scopedTo($this->project, $other)->create(['team_id' => $this->from->id, 'widgets' => [$widget('a', [$this->project->uuid]), $widget('b', [$this->project->uuid, $other->uuid]), $widget('c', [])]]); + $alone = Screen::factory()->scopedTo($this->project)->create(['team_id' => $this->from->id]); + $untouched = Screen::factory()->scopedTo($other)->create(['team_id' => $this->from->id]); + $revision = $untouched->revision; + + ($this->move)()->assertSessionHasNoErrors(); + + $widgets = $shared->refresh()->widgets; + expect($shared->scope['projects'])->toBe([$other->uuid]) + ->and($widgets[0]['scope']['projects'])->toBe([WidgetScope::NO_PROJECT]) + ->and($widgets[1]['scope']['projects'])->toBe([$other->uuid]) + ->and($widgets[2]['scope']['projects'])->toBe([]) + ->and($alone->refresh()->scope['projects'])->toBe([WidgetScope::NO_PROJECT]) + ->and($untouched->refresh()->revision)->toBe($revision); + }); + + it('still save as they are after it', function () { + $widget = ['id' => 'a', 'type' => 'stat', 'source' => 'requests', 'x' => 0, 'y' => 0, 'w' => 1, 'h' => 1, 'scope' => ['projects' => [$this->project->uuid]]]; + $screen = Screen::factory()->scopedTo($this->project)->create(['team_id' => $this->from->id, 'widgets' => [$widget]]); + + ($this->move)(); + $screen->refresh(); + + $this->actingAs($this->user)->put(route('screens.update', $screen), ['scope' => $screen->scope])->assertSessionHasNoErrors(); + $this->actingAs($this->user)->putJson(route('screens.layout', $screen), ['cols' => 4, 'rows' => 4, 'widgets' => $screen->widgets])->assertSuccessful(); + }); +}); + +describe('people on its issues', function () { + it('clears assignees and watchers who are not in the new team, and keeps those who are', function () { + $stays = User::factory()->inTeam($this->to, TeamRole::Member)->create(); + $leaves = User::factory()->inTeam($this->from, TeamRole::Member)->create(); + $kept = Issue::factory()->for($this->project)->create(['assigned_user_id' => $stays->id]); + $cleared = Issue::factory()->for($this->project)->create(['assigned_user_id' => $leaves->id]); + IssueWatcher::factory()->create(['issue_id' => $kept->id, 'user_id' => $stays->id]); + IssueWatcher::factory()->create(['issue_id' => $kept->id, 'user_id' => $leaves->id]); + + ($this->move)()->assertSessionHasNoErrors(); + + expect($kept->refresh()->assigned_user_id)->toBe($stays->id) + ->and($cleared->refresh()->assigned_user_id)->toBeNull() + ->and(IssueWatcher::query()->where('issue_id', $kept->id)->pluck('user_id')->all())->toBe([$stays->id]); + }); +}); From 18477f95adfaa44d9f7b1f8011adea117e2c350f Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:03:25 +0100 Subject: [PATCH 3/9] refactor(screens): put a screen's fit first in the Display tab What follows (aspect and orientation) reads from whether the screen keeps its shape on another display. --- .../js/components/lj/screen/inspector.tsx | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/resources/js/components/lj/screen/inspector.tsx b/resources/js/components/lj/screen/inspector.tsx index a365c844..c6bec008 100644 --- a/resources/js/components/lj/screen/inspector.tsx +++ b/resources/js/components/lj/screen/inspector.tsx @@ -2228,6 +2228,33 @@ export function ScreenSettings({ aria-labelledby="screen-tab-display-button" className="grid grid-cols-2 gap-2.5" > +
+ + {t('screens.settings.fit')} + + , + }, + { + value: 'fill', + label: t('screens.fit.fill'), + icon: , + }, + ]} + onChange={(v) => + onChange({ fit: v as Screen['fit'] }) + } + /> +
+ + {t('screens.settings.fit_hint')} +
{t('screens.designer.aspect')} @@ -2285,33 +2312,6 @@ export function ScreenSettings({ } />
-
- - {t('screens.settings.fit')} - - , - }, - { - value: 'fill', - label: t('screens.fit.fill'), - icon: , - }, - ]} - onChange={(v) => - onChange({ fit: v as Screen['fit'] }) - } - /> -
- - {t('screens.settings.fit_hint')} -
)} From 5d5b5b57f16d33e1ca6edf362bc7cb6231dd9b32 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:30:01 +0100 Subject: [PATCH 4/9] feat(screens): format the header's date, pick its language and size, and switches for its parts and projects - The header's date in a format of five, or one of its own from tokens (YYYY, MMMM, ddd, D...) with text in [brackets], checked as it is typed and on save. - Its date and clock in the app's language, the TV's own, or one picked. - The header drawn small, medium (as before), large or huge. - The header's parts and the screen's projects as switches, with All projects on while none is picked. - MCP: the design guide covers groups and the new settings, and list_widget_types leaves out the designer's icons. --- .../Tools/Screens/GetScreenDesignGuide.php | 9 +- .../Mcp/Tools/Screens/ListWidgetTypes.php | 14 +- .../Mcp/Tools/Screens/UpdateScreen.php | 2 +- .../Mcp/Tools/Screens/UpdateScreenLayout.php | 2 +- .../Screens/Actions/ImportScreenAction.php | 11 + .../Screens/Actions/UpdateScreenAction.php | 2 +- .../Http/Requests/UpdateScreenRequest.php | 11 + app/Domains/Screens/Models/Screen.php | 42 ++- lang/en/ui/screens.php | 15 +- resources/js/components/lj/screen/frame.tsx | 101 +++++- .../js/components/lj/screen/inspector.tsx | 341 +++++++++++++++--- resources/js/components/lj/screen/types.ts | 18 + resources/js/pages/screens/edit.tsx | 2 + resources/js/pages/screens/kiosk.tsx | 2 + .../Http/Controllers/ScreenControllerTest.php | 15 +- .../Controllers/ScreenFileControllerTest.php | 2 +- 16 files changed, 513 insertions(+), 76 deletions(-) diff --git a/app/Domains/Mcp/Tools/Screens/GetScreenDesignGuide.php b/app/Domains/Mcp/Tools/Screens/GetScreenDesignGuide.php index 75355d0b..685e3673 100644 --- a/app/Domains/Mcp/Tools/Screens/GetScreenDesignGuide.php +++ b/app/Domains/Mcp/Tools/Screens/GetScreenDesignGuide.php @@ -51,13 +51,20 @@ class GetScreenDesignGuide extends Tool ## Widgets {id, type, source, x, y, w, h, title, options, scope} - id: unique on the screen, any short string; keep it when moving a widget. - - x, y from 0; w, h in cells. Inside the grid, no overlaps. + - x, y from 0; w, h in cells. Inside the grid, no overlaps, but for groups. + - A group (type group) is one card behind the widgets wholly inside it, on fewer cells than + it; those draw no card of their own. Groups nest. Moving a group, move what it holds too. - source: an id from list_widget_types, for types that have sources. - options: only the keys of the type's fields. - scope: over the screen's scope: projects (uuids), environment, period, and for some sources release, filter, domain. Empty projects means every project. - rotate: on rotating types, source ids or {source, seconds, title, options, scope}. + ## Screen settings + update_screen also sets the room around the grid (margin) and between widgets (gap), and what + the header shows (header: parts to hide, a title, the clock's date, its format and language, + seconds, size). + ## Data sources Use source external_json with options.data_source set to the uuid; a list wants a rows source. Use source calendar for an iCalendar feed. A connected source fetches on first diff --git a/app/Domains/Mcp/Tools/Screens/ListWidgetTypes.php b/app/Domains/Mcp/Tools/Screens/ListWidgetTypes.php index a9da2345..fea70c8a 100644 --- a/app/Domains/Mcp/Tools/Screens/ListWidgetTypes.php +++ b/app/Domains/Mcp/Tools/Screens/ListWidgetTypes.php @@ -47,7 +47,19 @@ public function handle(Request $request): Response } return isset($widgets[$type]) - ? Response::json(['type' => $type, 'schema' => $widgets[$type], 'sources' => $sources[$type] ?? []]) + ? Response::json(['type' => $type, 'schema' => self::withoutIcons($widgets[$type]), 'sources' => $sources[$type] ?? []]) : Response::error('Unknown widget type; see list_widget_types without a type.'); } + + /** + * A type's sections without the pictures its choices have for the designer (the QR + * library's SVGs): an agent picks by name and label. + * + * @param list>}> $sections + * @return list>}> + */ + private static function withoutIcons(array $sections): array + { + return array_map(fn (array $section): array => [...$section, 'fields' => array_map(fn (array $field): array => array_diff_key($field, ['icons' => true]), $section['fields'])], $sections); + } } diff --git a/app/Domains/Mcp/Tools/Screens/UpdateScreen.php b/app/Domains/Mcp/Tools/Screens/UpdateScreen.php index 321cf083..71ef9a00 100644 --- a/app/Domains/Mcp/Tools/Screens/UpdateScreen.php +++ b/app/Domains/Mcp/Tools/Screens/UpdateScreen.php @@ -44,7 +44,7 @@ public function schema(JsonSchema $schema): array 'show_header' => $schema->boolean(), 'show_clock' => $schema->boolean(), 'clock_format' => $schema->string()->description('24 or 12.'), - 'header' => $schema->object()->description('{hide: [logo|name|team|projects|environment|period|attention|live], title: a title instead of the name or null, date: bool, seconds: bool}: the clock\'s date and seconds.'), + 'header' => $schema->object()->description('{hide: [logo|name|team|projects|environment|period|attention|live], title: a title instead of the name or null, date: bool, seconds: bool, date_format: short|long|medium|numeric|iso|custom, date_pattern: tokens for custom (YYYY YY MMMM MMM MM M DD D dddd ddd, [literal text]), locale: null for the app\'s language, browser, or a tag such as da or en-GB, size: s|m|l|xl, how large the header is}: the clock\'s date and seconds.'), 'light_from' => $schema->string()->description('HH:MM.'), 'light_to' => $schema->string()->description('HH:MM.'), 'timezone' => $schema->string()->description('Null: each viewer\'s own.'), diff --git a/app/Domains/Mcp/Tools/Screens/UpdateScreenLayout.php b/app/Domains/Mcp/Tools/Screens/UpdateScreenLayout.php index 4b5e5699..ddad0fe2 100644 --- a/app/Domains/Mcp/Tools/Screens/UpdateScreenLayout.php +++ b/app/Domains/Mcp/Tools/Screens/UpdateScreenLayout.php @@ -23,7 +23,7 @@ class UpdateScreenLayout extends Tool protected string $name = 'update_screen_layout'; - protected string $description = 'Replaces a screen grid and all its widgets, live on every TV showing it. Send every widget you want to keep. Widgets may not overlap.'; + protected string $description = 'Replaces a screen grid and all its widgets, live on every TV showing it. Send every widget you want to keep. Widgets may not overlap, but for those wholly inside a group (type group).'; public function __construct( private readonly UpdateScreenLayoutAction $update, diff --git a/app/Domains/Screens/Actions/ImportScreenAction.php b/app/Domains/Screens/Actions/ImportScreenAction.php index d4ec7c1a..4e6e054e 100644 --- a/app/Domains/Screens/Actions/ImportScreenAction.php +++ b/app/Domains/Screens/Actions/ImportScreenAction.php @@ -18,6 +18,7 @@ use App\Domains\Screens\Support\WidgetSchema; use App\Domains\Shared\Enums\Period; use App\Domains\Teams\Models\Team; +use Closure; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; @@ -84,6 +85,16 @@ public function read(Team $team, array $document): ScreenImport 'screen.header.title' => ['nullable', 'string', 'max:100'], 'screen.header.date' => ['boolean'], 'screen.header.seconds' => ['boolean'], + 'screen.header.date_format' => ['string', Rule::in(Screen::DATE_FORMATS)], + 'screen.header.date_pattern' => ['nullable', 'required_if:screen.header.date_format,custom', 'string', 'max:60', function (string $attribute, mixed $value, Closure $fail): void { + $problem = is_string($value) ? Screen::datePatternProblem($value) : null; + + if ($problem !== null) { + $fail($problem === '' ? __('ui/screens.validation.date_empty') : __('ui/screens.validation.date_token', ['token' => $problem])); + } + }], + 'screen.header.locale' => ['nullable', 'string', 'regex:'.Screen::LOCALE_PATTERN], + 'screen.header.size' => ['string', Rule::in(Screen::HEADER_SIZES)], 'screen.theme' => ['required', Rule::enum(ScreenTheme::class)], 'screen.light_from' => $time, 'screen.light_to' => $time, diff --git a/app/Domains/Screens/Actions/UpdateScreenAction.php b/app/Domains/Screens/Actions/UpdateScreenAction.php index 7f17fae0..cdcf3a9b 100644 --- a/app/Domains/Screens/Actions/UpdateScreenAction.php +++ b/app/Domains/Screens/Actions/UpdateScreenAction.php @@ -24,7 +24,7 @@ public function __construct( * Name, the display's aspect and orientation and how it fits another, whether the header shows, theme and its schedule, time zone and * the default scope; open kiosks follow. * - * @param array{name?: string, aspect?: ScreenAspect, orientation?: ScreenOrientation, fit?: ScreenFit, margin?: ScreenSpacing, gap?: ScreenSpacing, show_header?: bool, show_clock?: bool, clock_format?: string, header?: array{hide: list, title: string|null, date: bool, seconds: bool}, theme?: ScreenTheme, light_from?: string, light_to?: string, timezone?: string|null, scope?: array{projects: list, environment: string|null, period: string}} $settings + * @param array{name?: string, aspect?: ScreenAspect, orientation?: ScreenOrientation, fit?: ScreenFit, margin?: ScreenSpacing, gap?: ScreenSpacing, show_header?: bool, show_clock?: bool, clock_format?: string, header?: array{hide: list, title: string|null, date: bool, seconds: bool, date_format: string, date_pattern: string|null, locale: string|null, size: string}, theme?: ScreenTheme, light_from?: string, light_to?: string, timezone?: string|null, scope?: array{projects: list, environment: string|null, period: string}} $settings */ public function execute(Screen $screen, array $settings, User|McpToken|null $by = null, ?int $revision = null): Screen { diff --git a/app/Domains/Screens/Http/Requests/UpdateScreenRequest.php b/app/Domains/Screens/Http/Requests/UpdateScreenRequest.php index ad513666..80716d6f 100644 --- a/app/Domains/Screens/Http/Requests/UpdateScreenRequest.php +++ b/app/Domains/Screens/Http/Requests/UpdateScreenRequest.php @@ -12,6 +12,7 @@ use App\Domains\Screens\Enums\ScreenTheme; use App\Domains\Screens\Models\Screen; use App\Domains\Shared\Enums\Period; +use Closure; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -56,6 +57,16 @@ public static function rulesFor(Screen $screen): array 'header.title' => ['nullable', 'string', 'max:100'], 'header.date' => ['boolean'], 'header.seconds' => ['boolean'], + 'header.date_format' => ['string', Rule::in(Screen::DATE_FORMATS)], + 'header.date_pattern' => ['nullable', 'required_if:header.date_format,custom', 'string', 'max:60', function (string $attribute, mixed $value, Closure $fail): void { + $problem = is_string($value) ? Screen::datePatternProblem($value) : null; + + if ($problem !== null) { + $fail($problem === '' ? __('ui/screens.validation.date_empty') : __('ui/screens.validation.date_token', ['token' => $problem])); + } + }], + 'header.locale' => ['nullable', 'string', 'regex:'.Screen::LOCALE_PATTERN], + 'header.size' => ['string', Rule::in(Screen::HEADER_SIZES)], 'light_from' => ['sometimes', 'required', ...$time], 'light_to' => ['sometimes', 'required', ...$time], // Empty: the viewer's own time zone. diff --git a/app/Domains/Screens/Models/Screen.php b/app/Domains/Screens/Models/Screen.php index 6f39a3cb..295a331d 100644 --- a/app/Domains/Screens/Models/Screen.php +++ b/app/Domains/Screens/Models/Screen.php @@ -69,6 +69,35 @@ class Screen extends Model /** Parts of the header a screen can hide; being offline always shows. */ public const array HEADER_PARTS = ['logo', 'name', 'team', 'projects', 'environment', 'period', 'attention', 'live']; + /** How the header's clock writes the date: a format the browser words, or custom (date_pattern). */ + public const array DATE_FORMATS = ['short', 'long', 'medium', 'numeric', 'iso', 'custom']; + + /** + * A custom date's pieces: [text] as it is, a token, other letters (not a token, so + * refused) or anything else as it is. The tokens as frame.tsx's kioskDate() writes them. + */ + public const string DATE_TOKENS = '/\[[^\]]*\]|YYYY|YY|MMMM|MMM|MM|M|dddd|ddd|DD|D|[A-Za-z]+|[^A-Za-z\[]+|\[/'; + + /** + * What is wrong with a custom date pattern, as frame.tsx's datePatternProblem(): the + * first piece outside [brackets] that is no token, '' when it has no token, else null. + */ + public static function datePatternProblem(string $pattern): ?string + { + preg_match_all(self::DATE_TOKENS, $pattern, $matches); + $pieces = collect($matches[0]); + $token = fn (string $piece): bool => preg_match('/^(YYYY|YY|MMMM|MMM|MM|M|dddd|ddd|DD|D)$/', $piece) === 1; + + return $pieces->first(fn (string $piece): bool => ! $token($piece) && preg_match('/^\[.*\]$/', $piece) !== 1 && preg_match('/[A-Za-z\[]/', $piece) === 1) + ?? ($pieces->contains($token) ? null : ''); + } + + /** How large the header is drawn, medium as before. */ + public const array HEADER_SIZES = ['s', 'm', 'l', 'xl']; + + /** The header's language: browser, or a language tag such as da or en-GB; null is the app's. */ + public const string LOCALE_PATTERN = '/^(browser|[a-z]{2,3}(-[A-Z]{2})?)$/'; + /** What a version of a screen holds; not its identity or share link. */ public const array DESIGN = ['name', 'cols', 'rows', 'aspect', 'orientation', 'fit', 'margin', 'gap', 'show_header', 'show_clock', 'clock_format', 'header', 'theme', 'light_from', 'light_to', 'timezone', 'scope', 'widgets']; @@ -102,22 +131,29 @@ public function getRouteKeyName(): string } /** - * What the header shows, whole: the parts hidden, a title instead of the name, and - * whether the clock has the date and seconds. Stored or given, with anything else + * What the header shows, whole: the parts hidden, a title instead of the name, whether + * the clock has the date and seconds, how it writes the date and in which language, + * and how large it is. Stored or given, with anything else * dropped; nothing stored is everything, as before it could be chosen. * * @param array|null $given - * @return array{hide: list, title: string|null, date: bool, seconds: bool} + * @return array{hide: list, title: string|null, date: bool, seconds: bool, date_format: string, date_pattern: string|null, locale: string|null, size: string} */ public static function header(?array $given): array { $title = trim((string) ($given['title'] ?? '')); + $pattern = trim((string) ($given['date_pattern'] ?? '')); + $locale = (string) ($given['locale'] ?? ''); return [ 'hide' => array_values(array_unique(array_intersect(array_filter((array) ($given['hide'] ?? []), is_string(...)), self::HEADER_PARTS))), 'title' => $title !== '' ? $title : null, 'date' => (bool) ($given['date'] ?? false), 'seconds' => (bool) ($given['seconds'] ?? false), + 'date_format' => in_array($given['date_format'] ?? null, self::DATE_FORMATS, true) ? $given['date_format'] : 'short', + 'date_pattern' => $pattern !== '' ? $pattern : null, + 'locale' => preg_match(self::LOCALE_PATTERN, $locale) === 1 ? $locale : null, + 'size' => in_array($given['size'] ?? null, self::HEADER_SIZES, true) ? $given['size'] : 'm', ]; } diff --git a/lang/en/ui/screens.php b/lang/en/ui/screens.php index dd9aebd0..c556b0fc 100644 --- a/lang/en/ui/screens.php +++ b/lang/en/ui/screens.php @@ -322,14 +322,16 @@ 'hint' => 'What every widget shows unless it picks its own. Click a widget to change it.', 'name' => 'Name', 'projects' => 'Projects', - 'projects_hint' => 'None ticked: every project of the team, new ones included.', + 'all_projects' => 'All projects', + 'projects_hint' => 'All projects takes in new ones too; picked projects stay as they are.', 'timezone' => 'Time zone', 'timezone_hint' => 'For the clock and for switching between light and dark. Empty: each TV uses its own (the browser\'s) time zone.', 'browser_timezone' => 'The browser\'s time zone', 'show_clock' => 'Show the clock in the header', 'header_title' => 'Title', + 'header_size' => 'Header size', 'header_shows' => 'Shows', - 'header_shows_hint' => 'Lit parts show. Offline always shows, so stale numbers never pass for live ones.', + 'header_shows_hint' => 'Offline always shows, so stale numbers never pass for live ones.', 'header_parts' => [ 'logo' => 'Logo', 'name' => 'Title', @@ -342,6 +344,13 @@ ], 'clock_date' => 'Date', 'clock_seconds' => 'Seconds', + 'date_format' => 'Date format', + 'date_custom' => 'Own format…', + 'date_pattern' => 'Own format', + 'date_pattern_hint' => 'YYYY year, MMMM, MMM, MM or M month, dddd or ddd weekday, DD or D day; other text in [brackets]. Now: :example', + 'locale' => 'Language of the date', + 'locale_app' => 'The app\'s language', + 'locale_browser' => 'The TV\'s own (browser)', 'fit' => 'On a different screen', 'fit_hint' => 'A display of another shape than the screen\'s shows it as designed, centered with bars around it, or stretched to fill it.', 'margin' => 'Margin', @@ -882,6 +891,8 @@ 'source' => 'This widget cannot show that.', 'duplicate_id' => 'Two widgets have the same id.', 'overlap' => 'This widget covers a cell another widget already uses.', + 'date_token' => '":token" is no part of a date; put text in [brackets].', + 'date_empty' => 'Put at least one part of the date in, such as D, MMM or YYYY.', 'qr_unscannable' => 'Phones could not read this code reliably: pick colors further apart, or fewer or milder filters.', ], ]; diff --git a/resources/js/components/lj/screen/frame.tsx b/resources/js/components/lj/screen/frame.tsx index 28fb4d9a..bbcf94ce 100644 --- a/resources/js/components/lj/screen/frame.tsx +++ b/resources/js/components/lj/screen/frame.tsx @@ -80,6 +80,9 @@ function useWindowSize(): Size { return size; } +/** How large each header size draws it, medium as before. */ +const HEADER_ZOOM: Record = { s: 0.8, m: 1, l: 1.3, xl: 1.65 }; + /** How much of the medium margin and gap each spacing is. */ const SPACING: Record = { none: 0, s: 0.5, m: 1, l: 1.6 }; @@ -162,7 +165,11 @@ export function KioskFrame({ }} > {screen.show_header && ( -
+
{!screen.header.hide.includes('logo') && ( = { + short: { weekday: 'short', day: 'numeric', month: 'short' }, + long: { weekday: 'long', day: 'numeric', month: 'long' }, + medium: { day: 'numeric', month: 'short', year: 'numeric' }, + numeric: { day: '2-digit', month: '2-digit', year: 'numeric' }, +}; + +/** + * A custom date's pieces, as Screen::DATE_TOKENS reads them: [text] as it is, a token, + * other letters (no token: refused) or anything else as it is. + */ +const DATE_PIECES = + /\[[^\]]*\]|YYYY|YY|MMMM|MMM|MM|M|dddd|ddd|DD|D|[A-Za-z]+|[^A-Za-z[]+|\[/g; +const DATE_TOKEN = /^(YYYY|YY|MMMM|MMM|MM|M|dddd|ddd|DD|D)$/; + +/** A custom pattern's first piece that is no token, '' when it has no token, else null. */ +export function datePatternProblem(pattern: string): string | null { + const pieces = pattern.match(DATE_PIECES) ?? []; + const unknown = pieces.find( + (p) => + !DATE_TOKEN.test(p) && !/^\[.*\]$/.test(p) && /[A-Za-z[]/.test(p), + ); + + return unknown ?? (pieces.some((p) => DATE_TOKEN.test(p)) ? null : ''); +} + +/** The date by the header's clock, as the screen writes it; null without one. */ +export function kioskDate(screen: Screen, at: number): string | null { + const { date, date_format: format, date_pattern: pattern } = screen.header; + + if (!date) { + return null; + } + + const locale = kioskLocale(screen); + const timeZone = screen.timezone ?? undefined; + const part = (options: Intl.DateTimeFormatOptions, type: string) => + new Intl.DateTimeFormat(locale, { timeZone, ...options }) + .formatToParts(new Date(at)) + .find((p) => p.type === type)?.value ?? ''; + const tokens: Record string> = { + YYYY: () => part({ year: 'numeric' }, 'year'), + YY: () => part({ year: '2-digit' }, 'year'), + MMMM: () => part({ month: 'long' }, 'month'), + MMM: () => part({ month: 'short' }, 'month'), + MM: () => part({ month: '2-digit' }, 'month'), + M: () => part({ month: 'numeric' }, 'month'), + dddd: () => part({ weekday: 'long' }, 'weekday'), + ddd: () => part({ weekday: 'short' }, 'weekday'), + DD: () => part({ day: '2-digit' }, 'day'), + D: () => part({ day: 'numeric' }, 'day'), + }; + + if (format === 'iso') { + return `${tokens.YYYY()}-${tokens.MM()}-${tokens.DD()}`; + } + + if (format === 'custom') { + return pattern && datePatternProblem(pattern) === null + ? (pattern.match(DATE_PIECES) ?? []) + .map((p) => tokens[p]?.() ?? p.replace(/^\[(.*)\]$/, '$1')) + .join('') + : null; + } + + return new Intl.DateTimeFormat(locale, { + timeZone, + ...(DATE_OPTIONS[format] ?? DATE_OPTIONS.short), + }).format(new Date(at)); +} + /** * Room for a screen in the designer: at a previewed size, scaled down to the width it has * and the window's height less the toolbar (never up), the outside taking the scaled @@ -342,8 +425,11 @@ export function KioskStatus({ attention, offline, clock, + date = null, hide = [], }: { + /** The date by the clock, as the screen writes it; null without one. */ + date?: string | null; /** Parts the screen's header hides; being offline always shows. */ hide?: HeaderPart[]; attention: number; @@ -382,6 +468,11 @@ export function KioskStatus({ {offline} )} + {clock !== null && date !== null && ( + + {date} + + )} {clock !== null && ( {clock} diff --git a/resources/js/components/lj/screen/inspector.tsx b/resources/js/components/lj/screen/inspector.tsx index c6bec008..232ca090 100644 --- a/resources/js/components/lj/screen/inspector.tsx +++ b/resources/js/components/lj/screen/inspector.tsx @@ -44,6 +44,7 @@ import type { RotateItem, Schema, SchemaField, + DateFormat, Screen, ScreenSpacing, Source, @@ -51,7 +52,14 @@ import type { Widget, WidgetScope, } from './types'; -import { HEADER_PARTS, MAX_SLIDES, MAX_ZONES, ROTATING_KINDS } from './types'; +import { datePatternProblem, kioskDate } from './frame'; +import { + DATE_FORMATS, + HEADER_PARTS, + MAX_SLIDES, + MAX_ZONES, + ROTATING_KINDS, +} from './types'; export type Catalog = { schema: Schema; @@ -2144,6 +2152,35 @@ export function WidgetInspector({ } /** Settings of the whole screen, shown while no widget is selected. */ +/** Languages a screen's header can write the date in, besides the app's and the TV's. */ +const LOCALES = [ + 'da', + 'en', + 'en-GB', + 'de', + 'sv', + 'nb', + 'fi', + 'fr', + 'es', + 'nl', + 'it', + 'pl', +]; + +/** A language's name, in the page's language. */ +function languageName(code: string): string { + try { + return ( + new Intl.DisplayNames([document.documentElement.lang || 'en'], { + type: 'language', + }).of(code) ?? code + ); + } catch { + return code; + } +} + const SETTINGS_TABS = ['display', 'appearance', 'data', 'time'] as const; type SettingsTab = (typeof SETTINGS_TABS)[number]; @@ -2170,6 +2207,12 @@ export function ScreenSettings({ lastSettingsTab = id; setTab(id); }; + const setProjects = (projects: string[]) => + onChange({ scope: { ...scope, projects } }); + const patternProblem = + screen.header.date_format === 'custom' + ? datePatternProblem(screen.header.date_pattern ?? '') + : null; const setHeader = (changes: Partial) => onChange({ header: { ...screen.header, ...changes } }); @@ -2431,37 +2474,52 @@ export function ScreenSettings({ {t('screens.settings.projects')} -
- {catalog.teamProjects.map((p) => { - const on = scope.projects.includes(p.uuid); - - return ( - - ); - })} + /> + {p.name} + + ))}
@@ -2538,6 +2596,31 @@ export function ScreenSettings({ /> {t('screens.designer.show_header')} + {screen.show_header && ( +
+ + {t('screens.settings.header_size')} + + ({ + value: size, + label: t( + `screens.fields.title_size.options.${size}`, + ), + icon: SIZE_GLYPHS[size], + }), + )} + onChange={(v) => + setHeader({ + size: v as Screen['header']['size'], + }) + } + /> +
+ )} {screen.show_header && ( <>
@@ -2567,38 +2650,42 @@ export function ScreenSettings({ {t('screens.settings.header_shows')} -
+
{HEADER_PARTS.map((part) => { const on = !screen.header.hide.includes(part); + const label = t( + `screens.settings.header_parts.${part}`, + ); return ( - + + setHeader({ + hide: show + ? screen.header.hide.filter( + (p) => + p !== + part, + ) + : [ + ...screen + .header + .hide, + part, + ], + }) + } + /> + {label} + ); })}
@@ -2666,6 +2753,148 @@ export function ScreenSettings({ {t(`screens.settings.clock_${key}`)} ))} + {screen.header.date && ( + <> +
+ + +
+ {screen.header.date_format === 'custom' && ( +
+ + + setHeader({ + date_pattern: + e.target.value || + null, + }) + } + /> + + {patternProblem === null + ? t( + 'screens.settings.date_pattern_hint', + { + example: + kioskDate( + screen, + Date.now(), + ) ?? '', + }, + ) + : patternProblem === '' + ? t( + 'screens.validation.date_empty', + ) + : t( + 'screens.validation.date_token', + { + token: patternProblem, + }, + )} + +
+ )} +
+ + +
+ + )} )}
diff --git a/resources/js/components/lj/screen/types.ts b/resources/js/components/lj/screen/types.ts index 394e4939..74afaf4d 100644 --- a/resources/js/components/lj/screen/types.ts +++ b/resources/js/components/lj/screen/types.ts @@ -74,6 +74,17 @@ export const HEADER_PARTS = [ ] as const; export type HeaderPart = (typeof HEADER_PARTS)[number]; +/** Screen::DATE_FORMATS. */ +export const DATE_FORMATS = [ + 'short', + 'long', + 'medium', + 'numeric', + 'iso', + 'custom', +] as const; +export type DateFormat = (typeof DATE_FORMATS)[number]; + export type Screen = { uuid: string; name: string; @@ -102,6 +113,13 @@ export type Screen = { /** The clock's date and seconds. */ date: boolean; seconds: boolean; + date_format: DateFormat; + /** Tokens for a custom date; see kioskDate(). */ + date_pattern: string | null; + /** Null: the app's language; browser: the TV's; else a tag such as da. */ + locale: string | null; + /** How large the header is drawn: s, m (as before), l or xl. */ + size: 's' | 'm' | 'l' | 'xl'; }; theme: ScreenTheme; light_from: string; diff --git a/resources/js/pages/screens/edit.tsx b/resources/js/pages/screens/edit.tsx index 29117ada..d8f27576 100644 --- a/resources/js/pages/screens/edit.tsx +++ b/resources/js/pages/screens/edit.tsx @@ -14,6 +14,7 @@ import { KioskStatus, PreviewScale, kioskClock, + kioskDate, kioskSubtitle, kioskTitle, } from '@/components/lj/screen/frame'; @@ -2112,6 +2113,7 @@ export default function EditScreen(props: Props) { right: ( actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['hide' => ['logo', 'team', 'logo'], 'title' => ' Ops, 3rd floor ', 'date' => true, 'seconds' => true]])->assertOk(); + $this->actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['hide' => ['logo', 'team', 'logo'], 'title' => ' Ops, 3rd floor ', 'date' => true, 'seconds' => true, 'date_format' => 'custom', 'date_pattern' => ' ddd D. MMM ', 'locale' => 'da', 'size' => 'xl']])->assertOk(); - expect($this->screen->refresh()->header)->toBe(['hide' => ['logo', 'team'], 'title' => 'Ops, 3rd floor', 'date' => true, 'seconds' => true]); + expect($this->screen->refresh()->header)->toBe(['hide' => ['logo', 'team'], 'title' => 'Ops, 3rd floor', 'date' => true, 'seconds' => true, 'date_format' => 'custom', 'date_pattern' => 'ddd D. MMM', 'locale' => 'da', 'size' => 'xl']); - $this->actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['hide' => ['offline'], 'date' => 'soon']]) - ->assertJsonValidationErrors(['header.hide.0', 'header.date']); + $this->actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['hide' => ['offline'], 'date' => 'soon', 'date_format' => 'emoji', 'locale' => 'danish']]) + ->assertJsonValidationErrors(['header.hide.0', 'header.date', 'header.date_format', 'header.locale']); + + foreach (['Week D' => 'Week', '[Day]' => null, '' => null] as $pattern => $token) { + $this->actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['date_format' => 'custom', 'date_pattern' => $pattern]]) + ->assertJsonValidationErrors(['header.date_pattern' => $token === null ? [] : __('ui/screens.validation.date_token', ['token' => $token])]); + } + + $this->actingAs($this->user)->putJson(route('screens.update', $this->screen), ['header' => ['date_format' => 'custom', 'date_pattern' => '[Week of] D. MMMM YYYY']])->assertOk(); }); it('saves the display\'s aspect and orientation, and refuses others', function () { diff --git a/tests/Feature/Domains/Screens/Http/Controllers/ScreenFileControllerTest.php b/tests/Feature/Domains/Screens/Http/Controllers/ScreenFileControllerTest.php index ade5e5d2..ba9fb68e 100644 --- a/tests/Feature/Domains/Screens/Http/Controllers/ScreenFileControllerTest.php +++ b/tests/Feature/Domains/Screens/Http/Controllers/ScreenFileControllerTest.php @@ -90,7 +90,7 @@ describe('importing a screen', function () { it('gives an equal screen in another team, its references found by slug', function () { - $this->screen->update(['margin' => ScreenSpacing::Small, 'gap' => ScreenSpacing::None, 'header' => ['hide' => ['live'], 'title' => 'Ops', 'date' => true, 'seconds' => false]]); + $this->screen->update(['margin' => ScreenSpacing::Small, 'gap' => ScreenSpacing::None, 'header' => ['hide' => ['live'], 'title' => 'Ops', 'date' => true, 'seconds' => false, 'date_format' => 'iso', 'date_pattern' => null, 'locale' => 'browser', 'size' => 'l']]); ($this->import)(($this->file)())->assertSessionHasNoErrors()->assertSessionHas('status', 'Screen imported.'); $copy = $this->otherProject->team->screens()->sole(); From d8bc8a01127a658837867401dc2334f3d575b683 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:32:55 +0100 Subject: [PATCH 5/9] style(screens): draw the header's title as large as the clock when it is alone on its line --- resources/js/components/lj/screen/frame.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/js/components/lj/screen/frame.tsx b/resources/js/components/lj/screen/frame.tsx index bbcf94ce..57c16798 100644 --- a/resources/js/components/lj/screen/frame.tsx +++ b/resources/js/components/lj/screen/frame.tsx @@ -181,7 +181,15 @@ export function KioskFrame({ )}
{!screen.header.hide.includes('name') && ( -

+

{header.title}

)} From d52ee47b3c57380253b4cb5433280228edf305d5 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:33:46 +0100 Subject: [PATCH 6/9] feat(screens): pick the header's language from a searchable tree, countries under their language --- .../js/components/lj/screen/inspector.tsx | 111 +++++++++++++----- 1 file changed, 80 insertions(+), 31 deletions(-) diff --git a/resources/js/components/lj/screen/inspector.tsx b/resources/js/components/lj/screen/inspector.tsx index 232ca090..7caa7e8e 100644 --- a/resources/js/components/lj/screen/inspector.tsx +++ b/resources/js/components/lj/screen/inspector.tsx @@ -7,6 +7,7 @@ const CONNECTED_SHAPES: Record = { }; import { TreeSelect } from '@/components/lj/tree-select'; +import type { TreeOption } from '@/components/lj/tree-select'; import { AlignCenter, AlignLeft, @@ -2152,28 +2153,47 @@ export function WidgetInspector({ } /** Settings of the whole screen, shown while no widget is selected. */ -/** Languages a screen's header can write the date in, besides the app's and the TV's. */ +/** + * Languages a screen's header can write the date in, besides the app's and the TV's: a + * language alone, or by country where they write dates differently. + */ const LOCALES = [ 'da', - 'en', - 'en-GB', - 'de', 'sv', 'nb', 'fi', - 'fr', - 'es', - 'nl', + 'is', + 'en-GB', + 'en-US', + 'en-AU', + 'de-DE', + 'de-AT', + 'de-CH', + 'fr-FR', + 'fr-BE', + 'fr-CA', + 'nl-NL', + 'nl-BE', + 'es-ES', + 'es-MX', + 'pt-PT', + 'pt-BR', 'it', 'pl', + 'cs', + 'et', + 'lv', + 'lt', + 'ja', + 'zh-CN', ]; -/** A language's name, in the page's language. */ -function languageName(code: string): string { +/** A language's or country's name, in the page's language. */ +function displayName(code: string, type: 'language' | 'region'): string { try { return ( new Intl.DisplayNames([document.documentElement.lang || 'en'], { - type: 'language', + type, }).of(code) ?? code ); } catch { @@ -2181,6 +2201,34 @@ function languageName(code: string): string { } } +/** The languages for a tree: the TV's own first, a language with countries under its name. */ +function localeOptions(browser: string): TreeOption[] { + const base = (code: string) => code.split('-')[0]; + + return [ + { value: 'browser', label: browser }, + ...LOCALES.map((code) => { + const [language, region] = code.split('-'); + const countries = LOCALES.filter( + (c) => base(c) === language, + ).length; + + return countries > 1 && region + ? { + value: code, + label: displayName(region, 'region'), + path: [displayName(language, 'language')], + keywords: code, + } + : { + value: code, + label: displayName(code, 'language'), + keywords: code, + }; + }), + ]; +} + const SETTINGS_TABS = ['display', 'appearance', 'data', 'time'] as const; type SettingsTab = (typeof SETTINGS_TABS)[number]; @@ -2866,32 +2914,33 @@ export function ScreenSettings({ > {t('screens.settings.locale')} - + placeholder={t( + 'screens.settings.locale_app', + )} + clearLabel={t( + 'screens.settings.locale_app', + )} + searchPlaceholder={t( + 'screens.picker.search', + )} + noMatches={t( + 'screens.picker.no_matches', + )} + />
)} From d1c865471bbf90f522eb1dc24270958b4f54f1d6 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:37:43 +0100 Subject: [PATCH 7/9] style(screens): group the app's and the TV's language apart from the languages --- lang/en/ui/screens.php | 2 + .../js/components/lj/screen/inspector.tsx | 40 ++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lang/en/ui/screens.php b/lang/en/ui/screens.php index c556b0fc..b28b0aae 100644 --- a/lang/en/ui/screens.php +++ b/lang/en/ui/screens.php @@ -351,6 +351,8 @@ 'locale' => 'Language of the date', 'locale_app' => 'The app\'s language', 'locale_browser' => 'The TV\'s own (browser)', + 'locale_automatic' => 'Automatic', + 'locale_languages' => 'Languages', 'fit' => 'On a different screen', 'fit_hint' => 'A display of another shape than the screen\'s shows it as designed, centered with bars around it, or stretched to fill it.', 'margin' => 'Margin', diff --git a/resources/js/components/lj/screen/inspector.tsx b/resources/js/components/lj/screen/inspector.tsx index 7caa7e8e..07efb79e 100644 --- a/resources/js/components/lj/screen/inspector.tsx +++ b/resources/js/components/lj/screen/inspector.tsx @@ -2201,12 +2201,21 @@ function displayName(code: string, type: 'language' | 'region'): string { } } -/** The languages for a tree: the TV's own first, a language with countries under its name. */ -function localeOptions(browser: string): TreeOption[] { +/** + * The languages for a tree: the app's and the TV's own under Automatic (app stands for + * none), then every language, those with countries by country under its name. + */ +function localeOptions( + automatic: string, + app: string, + browser: string, + languages: string, +): TreeOption[] { const base = (code: string) => code.split('-')[0]; return [ - { value: 'browser', label: browser }, + { value: 'app', label: app, path: [automatic] }, + { value: 'browser', label: browser, path: [automatic] }, ...LOCALES.map((code) => { const [language, region] = code.split('-'); const countries = LOCALES.filter( @@ -2217,12 +2226,13 @@ function localeOptions(browser: string): TreeOption[] { ? { value: code, label: displayName(region, 'region'), - path: [displayName(language, 'language')], + path: [languages, displayName(language, 'language')], keywords: code, } : { value: code, label: displayName(code, 'language'), + path: [languages], keywords: code, }; }), @@ -2917,23 +2927,35 @@ export function ScreenSettings({ setHeader({ - locale: locale || null, + locale: + locale && + locale !== 'app' + ? locale + : null, }) } placeholder={t( 'screens.settings.locale_app', )} - clearLabel={t( - 'screens.settings.locale_app', - )} searchPlaceholder={t( 'screens.picker.search', )} From 4bee0404d7fe93f602dcc1caf6693093ee985468 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:39:35 +0100 Subject: [PATCH 8/9] docs: groups, spacing, QR style, the header and moving a project, in the guides and the changelog --- CHANGELOG.md | 12 ++++++++++ docs/projects.md | 16 ++++++++++++++ docs/screens.md | 57 +++++++++++++++++++++++++++++++----------------- docs/widgets.md | 27 ++++++++++++++++++++--- 4 files changed, 89 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6187a275..ba5d8086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,20 @@ All notable changes are written here, newest first, in the [Keep a Changelog](ht ## [Unreleased] +### Added + +- **Group** widget on status screens: one card behind the widgets wholly inside it, which then draw no card of their own (**Show card** is locked off). Groups nest, a group moves with all it holds when dragged by the space between its widgets, and it cannot be made smaller than them. Its title is off by default. +- A screen's **Margin** around the grid and **Spacing** between its widgets: none, small, medium (as before) or large. With no spacing, tiles have square corners and neighbours share one border. +- The **QR code** widget's style: the Lumberjack logo on or off, the code's color and a background, its modules, its eyes as a set or outer and inner apart, and up to 3 filters, each picked from pictures of the QR library's own parts, with **Reset** per section. A style phones could not read reliably is refused when saved. +- What a screen's header shows: the logo, the title (or a title of its own), team, projects, environment, period, the count of widgets needing attention and the live state can each be turned off; offline always shows. The header comes in four sizes, and its title grows to the clock's size with nothing under it. The clock can show seconds and the date, in a format of five or one of its own from tokens (`ddd D. MMM`), in the app's language, the TV's own, or one picked. +- **Move to another team** in a project's danger zone, for owners and admins of both teams. The project's own alert rules and channels go with it; links to the old team's rules and channels, MCP token access, the old team's screens' references and assignees or watchers outside the new team are dropped. A taken slug or issue prefix is replaced in the dialog, and each move is in the audit log. +- MCP: `update_screen` sets `margin`, `gap` and `header`; the design guide covers groups and these settings. + ### Changed +- Screen settings are in tabs (**Display**, **Look**, **Data**, **Header**); **Aspect** and **Orientation** moved there from the designer's toolbar. +- Spacing, alignment, text and title sizes, theme, fit, aspect and orientation are picked from pictures of what they do, and a screen's projects and header parts from switches. +- `list_widget_types` leaves out the designer's pictures of the QR code's parts. - The **Mail domain** check's form and docs say what a DKIM selector is entered as (the name only, such as `dkim`) and where to find it. ## [0.11.1] - 2026-11-15 diff --git a/docs/projects.md b/docs/projects.md index 64093783..d7ed6ce5 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -277,6 +277,22 @@ or through MCP. Lumberjack warns 14 days before the token expires. +## Moving a project to another team + +**Move to another team** in the **Danger zone** moves the project with its data, tokens and +connections to a team you are owner or admin of; you must be owner or admin of its team +too. A slug or issue prefix the other team already has is replaced in the dialog. The move +also: + +- moves the project's own alert rules and channels, and drops links to the old team's; + the project then follows the new team's rules and channels; +- takes the project out of MCP tokens: give a token access again where it should have it; +- takes it out of the old team's screens; a screen or widget left with no project shows + nothing; +- clears assignees and watchers of its issues who are not in the new team. + +Each move is in the [audit log](./administration). + ## Deleting a project The **Danger zone** deletes the project and all its data, after you type the project's diff --git a/docs/screens.md b/docs/screens.md index c800e085..9bb377df 100644 --- a/docs/screens.md +++ b/docs/screens.md @@ -78,16 +78,17 @@ every kiosk, paired TV and share link that shows the screen reload its page. size swaps them. - **Resize**: drag any edge or corner. A widget only grows into free cells. - **Remove**: select the widget and press Delete. +- **Group**: add a [Group](./widgets#group) and drop widgets on it. The group draws one + card behind the widgets wholly inside it; drag it by the space between them to move it + with all it holds. ![Dragging a widget onto a free cell](./screenshots/screen-designer-drop.png) ### The grid -A screen is a grid of 2 to 12 columns and 2 to 12 rows. A widget's size in cells is its -size on the TV. +A screen is a grid of 2 to 12 columns and 2 to 12 rows, set in the toolbar. A widget's +size in cells is its size on the TV. -- **Aspect** is the shape of the display: 16:9 (the default), 16:10, 4:3, 21:9 or 32:9, - landscape or portrait. - **Preview at** shows the screen at a given resolution: **Fit** (the default), the size each TV showing the screen reports, common resolutions for the aspect, or **Custom**. It is a setting of your browser, not of the screen. @@ -97,22 +98,38 @@ not show on the TV until you place them again or remove them. ### Screen settings -Click the grid's background, press Escape, or use **Screen settings** in the toolbar: - -- **Name**. -- **Projects**, environment and period: what every widget shows unless it picks its own. - No project ticked means every project of the team, new ones included. Ticked projects - are also a limit: a widget can then only pick among them, its health checks, data - sources and filter names come from them alone, and **All of the screen's projects** - replaces **All in the team**. A widget that pointed at another project before shows - nothing until it is set again. A share link names only the screen's projects. -- **Time zone**: for the clock and the theme schedule. Empty means each TV uses its own. -- **Show header**, and **Show the clock in the header** in 24 or 12 hours. The header - shows the screen's name, projects and period, how many widgets need attention, whether - it is live, and the time. -- The [theme](#theme). -- **On a different screen**: on a display of another shape, **Keep its shape** (the - default) centers the screen with bars around it, and **Fill the display** stretches it. +Click the grid's background, press Escape, or use **Screen settings** in the toolbar. The +**Name** is at the top, the rest in four tabs: + +- **Display**: + - **On a different screen**: on a display of another shape, **Keep its shape** (the + default) centers the screen with bars around it, and **Fill the display** stretches it. + - **Aspect**, the shape of the display: 16:9 (the default), 16:10, 4:3, 21:9, 43:18 or + 32:9, and **Orientation**, landscape or portrait. +- **Look**: + - The [theme](#theme). + - **Margin**, the room around the grid, and **Spacing**, the room between widgets: + **None**, **Small**, **Medium** (the default) or **Large**. With no spacing, tiles + have square corners and neighbours share one border. +- **Data**: **All projects**, or the projects picked, the environment and the period: what + every widget shows unless it picks its own. **All projects** takes in new ones too. + Picked projects are also a limit: a widget can then only pick among them, its health + checks, data sources and filter names come from them alone, and **All of the screen's + projects** replaces **All in the team**. A widget that pointed at another project before + shows nothing until it is set again. A share link names only the screen's projects. +- **Header**: + - **Show header**, its **Header size** (small, medium, large or huge), and a + **Title** of its own instead of the screen's name. + - **Shows**: the logo, the title, the team, the projects, the environment, the period, + how many widgets need attention, and whether it is live. Each can be turned off; when + a TV is offline, that always shows. With nothing under the title, the title is as + large as the clock. + - **Show the clock in the header**, in 24 or 12 hours, with **Seconds** and the + **Date**. The date takes a format (such as Tue 18 Nov, 18.11.2026 or 2026-11-18) or + **Own format** from tokens: `YYYY` or `YY` year, `MMMM`, `MMM`, `MM` or `M` month, + `dddd` or `ddd` weekday, `DD` or `D` day, other text in `[brackets]`. **Language of + the date**: the app's, the TV's own, or one picked. + - **Time zone**: for the clock and the theme schedule. Empty means each TV uses its own. ### Incident mode diff --git a/docs/widgets.md b/docs/widgets.md index 6c7ae1ad..f43ac553 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -7,8 +7,8 @@ screen's grid. The designer's palette has two groups: something Lumberjack measured. Each picks what it shows under **Shows** and uses the screen's projects, environment and period unless it sets its own. When the screen has projects ticked, a widget's own projects are among them. -- **Layout** widgets (Clock and text, Countdown, Message, QR code, Image, video or page) - show their own settings. They have no source, scope or period. +- **Layout** widgets (Clock and text, Countdown, Message, QR code, Image, video or page, + Group) show their own settings. They have no source, scope or period. The screenshots on this page come from the **Widget gallery** screen. Run `php artisan db:seed --class=ShowcaseWidgetsSeeder` to add it to the Local Team of a @@ -57,7 +57,8 @@ The default, and **Align** center with **Vertically** in the middle. - **Green border while all is ok** (data widgets). - **Show card**: when off, the tile has no background or border while all is well. They - come back when it is degraded, down or recovering. + come back when it is degraded, down or recovering. A widget in a [group](#group) has no + card of its own; the group draws one. ![A health check with the default green border](./screenshots/widget-display-ok.png) ![The same check without the green border](./screenshots/widget-display-no-ok-border.png) ![The same check without a card](./screenshots/widget-display-no-card.png) @@ -524,6 +525,18 @@ A link, a wifi network or any text as a QR code. - **Text**. - **Line under the code**: such as "Guest wifi". +Its style is in four sections, each with **Reset** back to Lumberjack's own: + +- **Logo and colors**: **Lumberjack logo in the middle**, the **Code color** (amber by + default) and a **Background** (none by default, so the tile shows through). +- **Modules**: the shape of the code's dots, such as squares, dots, hearts or flowing. +- **Eyes**: the three corner squares, as one of the sets, or **Outer and inner apart**. +- **Filters**: up to 3, such as mixed rotation, jitter or a wave, applied in the order + picked. + +A style phones could not read reliably, such as colors too close together or filters too +strong, is refused when saved. + Share links show the code too, wifi password included. ## Image, video or page @@ -551,6 +564,14 @@ take turns as a slideshow. The address must be http or https, reachable from the TV, and https when Lumberjack runs on https. Pages that forbid framing stay blank. +## Group + +One card behind other widgets, so they read as one. A widget belongs to a group while it +lies wholly inside it, on fewer cells than the group; it keeps its place on the grid and +draws no card of its own. Groups nest. Drag a group by the space between its widgets to +move it with all it holds; it cannot be made smaller than its widgets. Its title is off +by default. + ## Empty cell Older screens may have an **Empty cell** widget. It still works but is no longer offered, From d432d5a8486e88ccb0aa1e056f1619280e30b62f Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Wed, 18 Nov 2026 11:43:35 +0100 Subject: [PATCH 9/9] style(docs): align the MCP tools table after its longer rows --- docs/mcp.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/mcp.md b/docs/mcp.md index 2a343380..f371a5f3 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -301,29 +301,29 @@ For `weekly_summary`, `settings` is `{day, time}`: `day` 1 to 7 (1 is Monday) an ### Screens -| Tool | Needs | Does | Arguments | -| ------------------------- | ----------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `list_screens` | `screens: read` | Screens in the team. | none | -| `get_screen` | `screens: read` | Layout and widgets. | **`screen`** | -| `list_widget_types` | `screens: read` | Widgets and their options. | `type` | -| `get_screen_data` | `screens: read` | Widget data as shown. | **`screen`**, `widget` | -| `list_screen_versions` | `screens: read` | Saved versions. | **`screen`** | -| `preview_screen` | `screens: read` | Signed preview link. | **`screen`** | -| `get_screen_design_guide` | `screens: read` | Design guide for agents. | none | -| `create_screen` | `screens: write` | New screen. | **`name`**, `template` | +| Tool | Needs | Does | Arguments | +| ------------------------- | ----------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `list_screens` | `screens: read` | Screens in the team. | none | +| `get_screen` | `screens: read` | Layout and widgets. | **`screen`** | +| `list_widget_types` | `screens: read` | Widgets and their options. | `type` | +| `get_screen_data` | `screens: read` | Widget data as shown. | **`screen`**, `widget` | +| `list_screen_versions` | `screens: read` | Saved versions. | **`screen`** | +| `preview_screen` | `screens: read` | Signed preview link. | **`screen`** | +| `get_screen_design_guide` | `screens: read` | Design guide for agents. | none | +| `create_screen` | `screens: write` | New screen. | **`name`**, `template` | | `update_screen` | `screens: write` | Name, theme, settings. | **`screen`**, **`revision`**, `name`, `theme`, `aspect`, `orientation`, `fit`, `margin`, `gap`, `show_header`, `show_clock`, `clock_format`, `header`, `light_from`, `light_to`, `timezone`, `scope` | -| `update_screen_layout` | `screens: write` | Grid layout. | **`screen`**, **`revision`**, **`cols`**, **`rows`**, **`widgets`** | -| `update_screen_widget` | `screens: write` | One widget. | **`screen`**, **`revision`**, **`id`**, **`widget`** | -| `restore_screen_version` | `screens: write` | Restore a version. | **`screen`**, **`revision`**, **`version`** | -| `export_screen` | `screens: read` | Screen as a file. | **`screen`** | -| `list_displays` | `screens: read` | Paired displays. | none | -| `list_screen_viewers` | `screens: read` | Who has it open. | **`screen`** | -| `duplicate_screen` | `screens: write` | Copy a screen. | **`screen`** | -| `reload_screen` | `screens: write` | Reload its TVs. | **`screen`** | -| `import_screen` | `screens: manage` | Screen from a file. | **`json`** | -| `assign_display` | `screens: manage` | What a display shows. | **`display`**, **`screen`** | -| `set_screen_share` | `screens: manage` | Public share link. Can make data public. | **`screen`**, **`enabled`**, `include_titles` | -| `delete_screen` | `screens: manage` | Delete a screen. Deletes. | **`screen`** | +| `update_screen_layout` | `screens: write` | Grid layout. | **`screen`**, **`revision`**, **`cols`**, **`rows`**, **`widgets`** | +| `update_screen_widget` | `screens: write` | One widget. | **`screen`**, **`revision`**, **`id`**, **`widget`** | +| `restore_screen_version` | `screens: write` | Restore a version. | **`screen`**, **`revision`**, **`version`** | +| `export_screen` | `screens: read` | Screen as a file. | **`screen`** | +| `list_displays` | `screens: read` | Paired displays. | none | +| `list_screen_viewers` | `screens: read` | Who has it open. | **`screen`** | +| `duplicate_screen` | `screens: write` | Copy a screen. | **`screen`** | +| `reload_screen` | `screens: write` | Reload its TVs. | **`screen`** | +| `import_screen` | `screens: manage` | Screen from a file. | **`json`** | +| `assign_display` | `screens: manage` | What a display shows. | **`display`**, **`screen`** | +| `set_screen_share` | `screens: manage` | Public share link. Can make data public. | **`screen`**, **`enabled`**, `include_titles` | +| `delete_screen` | `screens: manage` | Delete a screen. Deletes. | **`screen`** | ### Project settings