Add server ownership, team access, role-based UI, and default admin role
- New migration 002_server_access.sql: created_by column + server_user table - Server model: ownership, permission checks, team management methods - Routes: /team routes, RoleMiddleware on /servers/create and /admin - ServerController: permission checks via server_user, team CRUD methods - TerminalController: server access checks - DashboardController: filter servers by accessible ones - ApiController: server access checks - Views: team.php, team_server.php, sidebar Team link, hide actions by role - Default user role changed from operator to admin on registration - Admin user form defaults to admin role
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
$server = $server ?? [];
|
||||
$metrics = $metrics ?? null;
|
||||
$historicalMetrics = $historicalMetrics ?? [];
|
||||
$server_role = $server_role ?? null;
|
||||
$canManage = $server_role === 'owner' || $server_role === 'manager';
|
||||
?>
|
||||
|
||||
<div class="page-header">
|
||||
@@ -20,12 +22,23 @@ $historicalMetrics = $historicalMetrics ?? [];
|
||||
</div>
|
||||
<div class="page-header-right">
|
||||
<div class="btn-group">
|
||||
<?php if ($server_role === 'owner'): ?>
|
||||
<a href="/team/<?= $server['id'] ?>" class="btn btn-secondary" title="Manage Team">
|
||||
<i class="fas fa-users-cog"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<span class="badge badge-<?= $server_role === 'owner' || $server_role === 'manager' ? 'warning' : 'info' ?>" style="align-self:center">
|
||||
<?= htmlspecialchars(ucfirst($server_role ?? 'viewer')) ?>
|
||||
</span>
|
||||
<a href="/terminal/<?= $server['id'] ?>" class="btn btn-dark">
|
||||
<i class="fas fa-terminal"></i> Terminal
|
||||
</a>
|
||||
<?php if ($canManage): ?>
|
||||
<a href="/servers/<?= $server['id'] ?>/edit" class="btn btn-secondary">
|
||||
<i class="fas fa-edit"></i> Edit
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManage): ?>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle">
|
||||
<i class="fas fa-cog"></i> Actions
|
||||
@@ -43,6 +56,7 @@ $historicalMetrics = $historicalMetrics ?? [];
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -154,6 +168,7 @@ $historicalMetrics = $historicalMetrics ?? [];
|
||||
<i class="fas fa-file-alt"></i>
|
||||
<span>System Logs</span>
|
||||
</a>
|
||||
<?php if ($canManage): ?>
|
||||
<a href="/servers/<?= $server['id'] ?>/nginx" class="action-card">
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24" style="opacity:0.8">
|
||||
<path d="M12 2L2 7.2v9.6L12 22l10-5.2V7.2L12 2zm0 1.5l8.5 4.4v8.2L12 20.5l-8.5-4.4V7.9L12 3.5zM7.4 8.5v7l1.5.9V11l3.1 4.3 1.5.9V8.5l-1.5.9v4.4L8.9 9.4l-1.5-.9zm9.2 0l-1.5.9-3.1 4.4V17l1.5-.9V11l3.1-4.3z"/>
|
||||
@@ -180,6 +195,7 @@ $historicalMetrics = $historicalMetrics ?? [];
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
<span>Restart Service</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user