Add user profile & dashboard insights

Introduce a user profile page and expand dashboard insights/UI. Added UserController::show and a new users/show view with user stats, domains, tags and groups; updated users index to include a "view profile" link and changed edit form action to /users/{id}/update. Enhanced DashboardController to compute registrar distribution, notification coverage, channel totals and dashboard tag usage; updated dashboard/index.php to show system status, expiring list, registrar/tag widgets and notification coverage panels. Minor controller hardening: DomainController now returns a permission message when a domain is inaccessible, and TagController enforces isolation-mode access checks. UI/JS improvements: add a Quick Actions dropdown in top-nav, refactor dropdown toggle/close logic in layout/base.php, and small notification markup tweak. Routes were adjusted to expose the new user profile endpoints.
This commit is contained in:
Hosteroid
2026-02-09 00:20:17 +02:00
parent e334f7c9d6
commit b3c3f3403c
11 changed files with 1476 additions and 177 deletions

View File

@@ -57,6 +57,37 @@ class DashboardController extends Controller
$formattedRecentDomains = \App\Helpers\DomainHelper::formatMultiple($recentDomains);
$formattedExpiringDomains = \App\Helpers\DomainHelper::formatMultiple($expiringThisMonth);
// Get all domains for registrar distribution & notification coverage
if ($isolationMode === 'isolated') {
$allDomains = $this->domainModel->getAllWithGroups($userId);
} else {
$allDomains = $this->domainModel->getAllWithGroups();
}
// Registrar distribution
$registrarCounts = [];
foreach ($allDomains as $d) {
$reg = !empty($d['registrar']) ? $d['registrar'] : 'Unknown';
$registrarCounts[$reg] = ($registrarCounts[$reg] ?? 0) + 1;
}
arsort($registrarCounts);
// Notification coverage
$domainsWithGroup = count(array_filter($allDomains, fn($d) => !empty($d['group_name'])));
$totalDomainCount = count($allDomains);
// Total channels
$totalChannels = 0;
foreach ($groups as $g) { $totalChannels += ($g['channel_count'] ?? 0); }
// Get user's tags with usage
$tagModel = new \App\Models\Tag();
if ($isolationMode === 'isolated') {
$dashTags = $tagModel->getAllWithUsage($userId);
} else {
$dashTags = $tagModel->getAllWithUsage();
}
$this->view('dashboard/index', [
'recentDomains' => $formattedRecentDomains,
'expiringThisMonth' => $formattedExpiringDomains,
@@ -64,6 +95,11 @@ class DashboardController extends Controller
'recentLogs' => $recentLogs,
'groups' => $groups,
'systemStatus' => $systemStatus,
'registrarCounts' => $registrarCounts,
'domainsWithGroup' => $domainsWithGroup,
'totalDomainCount' => $totalDomainCount,
'totalChannels' => $totalChannels,
'dashTags' => $dashTags,
'title' => 'Dashboard'
]);
}

View File

@@ -531,7 +531,7 @@ class DomainController extends Controller
}
if (!$domain) {
$_SESSION['error'] = 'Domain not found';
$_SESSION['error'] = 'You do not have permission to view this domain.';
$this->redirect('/domains');
return;
}

View File

@@ -250,6 +250,13 @@ class TagController extends Controller
$userId = \Core\Auth::id();
$settingModel = new \App\Models\Setting();
$isolationMode = $settingModel->getValue('user_isolation_mode', 'shared');
// Check if user can access this tag in isolation mode
if ($isolationMode === 'isolated' && !$this->tagModel->canUserAccessTag($id, $userId, true)) {
$_SESSION['error'] = 'You do not have permission to view this tag.';
$this->redirect('/tags');
return;
}
// Get domains for this tag with proper formatting
$domainModel = new \App\Models\Domain();

View File

@@ -195,6 +195,62 @@ class UserController extends Controller
}
}
/**
* Show user profile view (admin)
*/
public function show($params = [])
{
$userId = $params['id'] ?? 0;
$user = $this->userModel->find($userId);
if (!$user) {
$_SESSION['error'] = 'User not found';
$this->redirect('/users');
return;
}
// Get user's domains (formatted for display)
$domainModel = new \App\Models\Domain();
$domains = $domainModel->getAllWithGroups($userId);
$domains = \App\Helpers\DomainHelper::formatMultiple($domains);
$userDomainStats = $domainModel->getStatistics($userId);
// Get user's tags with domains per tag
$tagModel = new \App\Models\Tag();
$tags = $tagModel->getAllWithUsage($userId);
// Fetch domains for each tag (formatted for display)
foreach ($tags as &$tag) {
$tagDomains = $tagModel->getDomainsForTag($tag['id'], $userId);
$tag['domains'] = \App\Helpers\DomainHelper::formatMultiple($tagDomains);
}
unset($tag);
// Get user's notification groups with channels
$groupModel = new \App\Models\NotificationGroup();
$groups = $groupModel->getAllWithChannelCount($userId);
// Fetch channels for each group
$channelModel = new \App\Models\NotificationChannel();
foreach ($groups as &$group) {
$group['channels'] = $channelModel->getByGroupId($group['id']);
}
unset($group);
// Get 2FA status
$twoFactorStatus = $this->userModel->getTwoFactorStatus($userId);
$this->view('users/show', [
'title' => htmlspecialchars($user['full_name']) . ' - User Profile',
'user' => $user,
'domains' => $domains,
'userDomainStats' => $userDomainStats,
'tags' => $tags,
'groups' => $groups,
'twoFactorStatus' => $twoFactorStatus,
]);
}
/**
* Show edit user form
*/