- Move 12 markdown files from root to docs/ subdirectories - Organize documentation by category: • docs/troubleshooting/ (1 file) - Technical troubleshooting guides • docs/deployment/ (4 files) - Deployment and security documentation • docs/guides/ (3 files) - Feature-specific guides • docs/planning/ (4 files) - Planning and improvement proposals Root directory cleanup: - Reduced from 16 to 4 markdown files in root - Only essential project files remain: • CLAUDE.md (AI instructions) • README.md (Main project readme) • CLEANUP_PLAN.md (Current cleanup plan) • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements) This improves: ✅ Documentation discoverability ✅ Logical organization by purpose ✅ Clean root directory ✅ Better maintainability
90 lines
3.1 KiB
PHP
90 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Application\Admin;
|
|
|
|
use App\Application\Admin\Service\AdminLayoutProcessor;
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\Auth\Auth;
|
|
use App\Framework\Core\VersionInfo;
|
|
use App\Framework\DateTime\Clock;
|
|
use App\Framework\Http\Method;
|
|
use App\Framework\Meta\MetaData;
|
|
use App\Framework\Performance\MemoryMonitor;
|
|
use App\Framework\Router\Result\ViewResult;
|
|
use App\Framework\Router\AdminRoutes;
|
|
|
|
final readonly class Dashboard
|
|
{
|
|
public function __construct(
|
|
private VersionInfo $versionInfo,
|
|
private MemoryMonitor $memoryMonitor,
|
|
private Clock $clock,
|
|
private AdminLayoutProcessor $layoutProcessor,
|
|
) {
|
|
}
|
|
|
|
#[Auth]
|
|
#[Route(path: '/admin', method: Method::GET, name: AdminRoutes::DASHBOARD)]
|
|
public function show(): ViewResult
|
|
{
|
|
$data = [
|
|
'title' => 'Admin Dashboard',
|
|
'framework_version' => $this->versionInfo->getVersion(),
|
|
'uptime_formatted' => $this->getServerUptime(),
|
|
'memory_usage_formatted' => $this->memoryMonitor->getCurrentMemory()->toHumanReadable(),
|
|
'peak_memory_formatted' => $this->memoryMonitor->getPeakMemory()->toHumanReadable(),
|
|
'load_average' => $this->getLoadAverage(),
|
|
'db_pool_size' => 10,
|
|
'db_active_connections' => 3,
|
|
'cache_hit_rate' => 85,
|
|
'cache_total_operations' => number_format(12547),
|
|
'requests_today' => number_format(1247),
|
|
'errors_today' => 3,
|
|
'last_deployment' => $this->clock->now()->format('Y-m-d H:i'),
|
|
'clear_cache_url' => '/admin/infrastructure/cache/reset',
|
|
'logs_url' => '/admin/infrastructure/logs',
|
|
'migrations_url' => '/admin/infrastructure/migrations',
|
|
];
|
|
|
|
$finalData = $this->layoutProcessor->processLayoutFromArray($data);
|
|
|
|
// DEBUG: Log template data to see what's being passed
|
|
error_log("🎯 Dashboard::show() - Final template data keys: " . implode(', ', array_keys($finalData)));
|
|
error_log("🎯 Dashboard::show() - Navigation menu count: " . count($finalData['navigation_menu'] ?? []));
|
|
error_log("🎯 Dashboard::show() - Framework version: " . ($finalData['framework_version'] ?? 'MISSING'));
|
|
|
|
return new ViewResult(
|
|
template: 'dashboard',
|
|
metaData: new MetaData('Admin Dashboard', 'Administrative control panel'),
|
|
data: $finalData
|
|
);
|
|
}
|
|
|
|
private function getLoadAverage(): string
|
|
{
|
|
if (function_exists('sys_getloadavg')) {
|
|
$load = sys_getloadavg();
|
|
|
|
return sprintf('%.2f, %.2f, %.2f', $load[0], $load[1], $load[2]);
|
|
}
|
|
|
|
return 'N/A';
|
|
}
|
|
|
|
private function getServerUptime(): string
|
|
{
|
|
// Für Linux-Systeme
|
|
if (function_exists('shell_exec') && stripos(PHP_OS, 'Linux') !== false) {
|
|
$uptime = shell_exec('uptime -p');
|
|
if ($uptime) {
|
|
return $uptime;
|
|
}
|
|
}
|
|
|
|
// Fallback
|
|
return 'Nicht verfügbar';
|
|
}
|
|
}
|