adasd
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App;
|
||||
use Desktop\AppRegistry;
|
||||
use Desktop\DesktopState;
|
||||
use Desktop\SkinResolver;
|
||||
use Desktop\WidgetRegistry;
|
||||
use Desktop\WindowManager;
|
||||
|
||||
final class App
|
||||
@@ -22,9 +23,11 @@ final class App
|
||||
public function desktopPayload(): array
|
||||
{
|
||||
$registry = new AppRegistry($this->projectRoot . '/config/apps.php');
|
||||
$widgetRegistry = new WidgetRegistry($this->projectRoot . '/config/widgets.php');
|
||||
$skins = SkinResolver::all();
|
||||
$activeSkin = SkinResolver::resolve($_GET['skin'] ?? null);
|
||||
$windows = (new WindowManager($registry))->defaultWindows();
|
||||
$activeWidgetIds = DesktopState::defaultWidgetIds();
|
||||
|
||||
return [
|
||||
'meta' => [
|
||||
@@ -44,8 +47,15 @@ final class App
|
||||
],
|
||||
'apps' => $registry->all(),
|
||||
'windows' => $windows,
|
||||
'widgets' => DesktopState::defaultWidgets(),
|
||||
'widgets' => [
|
||||
'active' => $widgetRegistry->active($activeWidgetIds),
|
||||
'registry' => $widgetRegistry->all(),
|
||||
'active_ids' => $activeWidgetIds,
|
||||
],
|
||||
'tray' => DesktopState::trayItems(),
|
||||
'menu' => [
|
||||
'quick_actions' => DesktopState::quickActions(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,22 +20,11 @@ final class DesktopState
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, string>>
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function defaultWidgets(): array
|
||||
public static function defaultWidgetIds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'widget_id' => 'public-home',
|
||||
'title' => 'Public Home',
|
||||
'content' => 'Oeffentliches Dashboard als Startzustand fuer nicht eingeloggte Nutzer.',
|
||||
],
|
||||
[
|
||||
'widget_id' => 'personal-links',
|
||||
'title' => 'Persoenliche Links',
|
||||
'content' => 'Platzhalter fuer spaetere user-spezifische Linklisten und Dashboards.',
|
||||
],
|
||||
];
|
||||
return ['public-home', 'personal-links', 'system-status'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,4 +38,28 @@ final class DesktopState
|
||||
['id' => 'account', 'label' => 'Gast'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, string>>
|
||||
*/
|
||||
public static function quickActions(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'action_id' => 'open-public-dashboard',
|
||||
'label' => 'Public Dashboard',
|
||||
'description' => 'Oeffnet die oeffentliche Startansicht als Fenster.',
|
||||
],
|
||||
[
|
||||
'action_id' => 'toggle-all-widgets',
|
||||
'label' => 'Widgets umschalten',
|
||||
'description' => 'Blendet alle registrierten Widgets ein oder aus.',
|
||||
],
|
||||
[
|
||||
'action_id' => 'cycle-skin',
|
||||
'label' => 'Skin wechseln',
|
||||
'description' => 'Wechselt zyklisch zwischen Windows, Apple und Linux.',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
40
src/Desktop/WidgetRegistry.php
Normal file
40
src/Desktop/WidgetRegistry.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Desktop;
|
||||
|
||||
final class WidgetRegistry
|
||||
{
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
private array $widgets;
|
||||
|
||||
public function __construct(string $configPath)
|
||||
{
|
||||
/** @var array<int, array<string, mixed>> $widgets */
|
||||
$widgets = require $configPath;
|
||||
$this->widgets = $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $widgetIds
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function active(array $widgetIds): array
|
||||
{
|
||||
$lookup = array_fill_keys($widgetIds, true);
|
||||
|
||||
return array_values(array_filter(
|
||||
$this->widgets,
|
||||
static fn (array $widget): bool => isset($lookup[$widget['widget_id'] ?? ''])
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user