add dashboard

This commit is contained in:
2026-11-30 16:51:14 +01:00
parent 6308f5e733
commit 1ec2d9c8e1
4 changed files with 182 additions and 1 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -219,6 +219,23 @@ class WebsiteManager implements WebsiteManagerContract
$menus = $menuRepository->getHydratedMenus();
$menusJson = json_encode($menus);
$completedTranslations = 0;
foreach ($pageTranslationCoverage as $coverage) {
$completedTranslations += $coverage['completeCount'];
}
$expectedTranslations = count($pages) * count($activeLanguages);
$dashboardSummary = [
'pageCount' => count($pages),
'uploadCount' => count($files),
'menuCount' => count($menus),
'completedTranslations' => $completedTranslations,
'expectedTranslations' => $expectedTranslations,
'translationCoveragePercent' => $expectedTranslations > 0
? (int) round($completedTranslations / $expectedTranslations * 100)
: null,
'activeLanguageCount' => count($activeLanguages),
];
$menuPages = [];
foreach ($pages as $page) {
$menuPages[] = [
@@ -1,6 +1,11 @@
<?php
return [
'dashboard' => [
'title' => 'Dashboard',
'include' => __DIR__ . '/dashboard.php',
'icon' => '<i class="ph ph-squares-four"></i>',
],
'pages' => [
'title' => phpb_trans('website-manager.pages'),
'include' => __DIR__ . '/pages.php',
@@ -0,0 +1,159 @@
<?php
$pageCount = $dashboardSummary['pageCount'];
$menuCount = $dashboardSummary['menuCount'];
$uploadCount = $dashboardSummary['uploadCount'];
$completedTranslations = $dashboardSummary['completedTranslations'];
$expectedTranslations = $dashboardSummary['expectedTranslations'];
$activeLanguageCount = $dashboardSummary['activeLanguageCount'];
$translationCoveragePercent = $dashboardSummary['translationCoveragePercent'];
$hasNoPages = $pageCount === 0;
$hasNoMenus = $menuCount === 0;
$hasNoActiveLanguages = $activeLanguageCount === 0 && $pageCount > 0;
$hasIncompleteTranslations = $expectedTranslations > 0 && $completedTranslations < $expectedTranslations;
$hasAttention = $hasNoPages || $hasNoMenus || $hasNoActiveLanguages || $hasIncompleteTranslations;
$translationCoverageLabel = $translationCoveragePercent === null
? '—'
: (phpb_e($translationCoveragePercent) . '%');
if ($expectedTranslations > 0) {
$translationDescription = sprintf('%d of %d page translations complete', $completedTranslations, $expectedTranslations);
} elseif ($activeLanguageCount === 0) {
$translationDescription = 'No active languages configured';
} else {
$translationDescription = 'Add a page to begin tracking translation coverage';
}
?>
<div class="space-y-8">
<header class="space-y-1">
<h2 class="text-xl font-bold tracking-tight text-base-content">Site overview</h2>
<p class="text-sm text-base-content/60">A quick view of your content and site setup.</p>
</header>
<section class="grid gap-4 sm:grid-cols-2 xl:grid-cols-4" aria-label="Site summary">
<article class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body p-5">
<div class="flex items-start justify-between gap-3">
<div class="stat p-0">
<div class="stat-title">Pages</div>
<div class="stat-value text-3xl"><?= phpb_e($pageCount) ?></div>
<div class="stat-desc">Pages on your site</div>
</div>
<i class="text-xl text-base-content/50 ph-duotone ph-files" aria-hidden="true"></i>
</div>
</div>
</article>
<article class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body p-5">
<div class="flex items-start justify-between gap-3">
<div class="stat p-0">
<div class="stat-title">Menus</div>
<div class="stat-value text-3xl"><?= phpb_e($menuCount) ?></div>
<div class="stat-desc">Navigation menus configured</div>
</div>
<i class="text-xl text-base-content/50 ph-duotone ph-list-dashes" aria-hidden="true"></i>
</div>
</div>
</article>
<article class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body p-5">
<div class="flex items-start justify-between gap-3">
<div class="stat p-0">
<div class="stat-title">Media files</div>
<div class="stat-value text-3xl"><?= phpb_e($uploadCount) ?></div>
<div class="stat-desc">Uploaded files</div>
</div>
<i class="text-xl text-base-content/50 ph-duotone ph-folder-notch-open" aria-hidden="true"></i>
</div>
</div>
</article>
<article class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body p-5">
<div class="flex items-start justify-between gap-3">
<div class="stat p-0">
<div class="stat-title">Translation coverage</div>
<div class="stat-value text-3xl"><?= $translationCoverageLabel ?></div>
<div class="stat-desc"><?= phpb_e($translationDescription) ?></div>
</div>
<i class="text-xl text-base-content/50 ph-duotone ph-translate" aria-hidden="true"></i>
</div>
</div>
</article>
</section>
<section class="space-y-3" aria-labelledby="dashboard-attention-heading">
<div>
<h2 id="dashboard-attention-heading" class="text-lg font-bold tracking-tight text-base-content">Needs attention</h2>
<p class="text-sm text-base-content/60">Setup items you may want to complete.</p>
</div>
<?php if (! $hasAttention): ?>
<div class="alert alert-success" role="status">
<i class="text-xl ph-duotone ph-check-circle" aria-hidden="true"></i>
<span>Your pages, menus, and translations are set up. You can run quality checks whenever you’re ready.</span>
</div>
<?php else: ?>
<div class="space-y-3">
<?php if ($hasNoPages): ?>
<div class="alert alert-warning flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between" role="status">
<span><i class="mr-2 text-xl ph-duotone ph-files" aria-hidden="true"></i>No pages yet. Create a page to start building your site.</span>
<a class="btn btn-sm" href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'create']) ?>">Create a page</a>
</div>
<?php endif; ?>
<?php if ($hasNoMenus): ?>
<div class="alert alert-warning flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between" role="status">
<span><i class="mr-2 text-xl ph-duotone ph-list-dashes" aria-hidden="true"></i>No navigation menus are set up yet.</span>
<a class="btn btn-sm" href="<?= phpb_url('website_manager', ['tab' => 'menus']) ?>">Manage menus</a>
</div>
<?php endif; ?>
<?php if ($hasNoActiveLanguages): ?>
<div class="alert alert-info flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between" role="status">
<span><i class="mr-2 text-xl ph-duotone ph-translate" aria-hidden="true"></i>No active languages are configured, so translation coverage cannot be measured.</span>
<a class="btn btn-sm" href="<?= phpb_url('website_manager', ['tab' => 'settings']) ?>">Review settings</a>
</div>
<?php endif; ?>
<?php if ($hasIncompleteTranslations): ?>
<div class="alert alert-warning flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between" role="status">
<span><i class="mr-2 text-xl ph-duotone ph-translate" aria-hidden="true"></i><?= phpb_e($completedTranslations) ?> of <?= phpb_e($expectedTranslations) ?> page translations are complete.</span>
<a class="btn btn-sm" href="<?= phpb_url('website_manager', ['tab' => 'pages']) ?>">Review pages</a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</section>
<section class="space-y-3" aria-labelledby="dashboard-actions-heading">
<div>
<h2 id="dashboard-actions-heading" class="text-lg font-bold tracking-tight text-base-content">Quick actions</h2>
<p class="text-sm text-base-content/60">Jump straight to a common task.</p>
</div>
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
<a class="card border border-base-300 bg-base-100 transition hover:border-base-content/30 hover:shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-base-content" href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'create']) ?>">
<div class="card-body gap-3 p-5">
<i class="text-2xl text-base-content/60 ph-duotone ph-plus-circle" aria-hidden="true"></i>
<h3 class="card-title text-base">Create a page</h3>
<p class="text-sm text-base-content/60">Add a page and start shaping your site.</p>
</div>
</a>
<a class="card border border-base-300 bg-base-100 transition hover:border-base-content/30 hover:shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-base-content" href="<?= phpb_url('website_manager', ['tab' => 'menus']) ?>">
<div class="card-body gap-3 p-5">
<i class="text-2xl text-base-content/60 ph-duotone ph-list-dashes" aria-hidden="true"></i>
<h3 class="card-title text-base">Manage menus</h3>
<p class="text-sm text-base-content/60">Choose which pages appear in navigation.</p>
</div>
</a>
<a class="card border border-base-300 bg-base-100 transition hover:border-base-content/30 hover:shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-base-content" href="<?= phpb_url('website_manager', ['tab' => 'files']) ?>">
<div class="card-body gap-3 p-5">
<i class="text-2xl text-base-content/60 ph-duotone ph-upload-simple" aria-hidden="true"></i>
<h3 class="card-title text-base">Upload files</h3>
<p class="text-sm text-base-content/60">Add images and other media to your library.</p>
</div>
</a>
<a class="card border border-base-300 bg-base-100 transition hover:border-base-content/30 hover:shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-base-content" href="<?= phpb_url('website_manager', ['tab' => 'quality']) ?>">
<div class="card-body gap-3 p-5">
<i class="text-2xl text-base-content/60 ph-duotone ph-check-circle" aria-hidden="true"></i>
<h3 class="card-title text-base">Run quality checks</h3>
<p class="text-sm text-base-content/60">Start an on-demand review of your site.</p>
</div>
</a>
</div>
</section>
</div>