- New migration 003_teams.sql: teams, team_user, team_server tables - New Team model with CRUD, members, and server assignment - New TeamController with full team management - New views: teams/index, teams/create, teams/show - Server model: getUserRole and getAccessibleServerIds now include team-based access - Sidebar: Teams link under Administration (admin+ only) - Routes: old /team routes removed, new /teams routes added - Removed old ServerController team methods and views - Fixed sidebar empty accessible IDs returning all servers - Fixed dashboard and API to show empty when no accessible servers
79 lines
3.3 KiB
PHP
79 lines
3.3 KiB
PHP
<?php $teams = $teams ?? []; ?>
|
|
|
|
<div class="page-header">
|
|
<div class="page-header-left">
|
|
<h1 class="page-title">Teams</h1>
|
|
<p class="page-subtitle">Create and manage work teams with server access</p>
|
|
</div>
|
|
<div class="page-header-right">
|
|
<a href="/teams/create" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Create Team
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<?php if (empty($teams)): ?>
|
|
<div class="empty-state">
|
|
<i class="fas fa-users-cog"></i>
|
|
<p>No teams created yet.</p>
|
|
<a href="/teams/create" class="btn btn-primary">Create Your First Team</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
<th>Members</th>
|
|
<th>Servers</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($teams as $team): ?>
|
|
<tr>
|
|
<td>
|
|
<a href="/teams/<?= $team['id'] ?>" class="fw-semibold">
|
|
<?= htmlspecialchars($team['name']) ?>
|
|
</a>
|
|
</td>
|
|
<td class="text-muted"><?= htmlspecialchars(mb_substr($team['description'] ?? '', 0, 80)) ?></td>
|
|
<td><span class="badge badge-info"><?= (int) ($team['member_count'] ?? 0) ?></span></td>
|
|
<td><span class="badge badge-primary"><?= (int) ($team['server_count'] ?? 0) ?></span></td>
|
|
<td>
|
|
<div class="btn-group">
|
|
<a href="/teams/<?= $team['id'] ?>" class="btn btn-xs" title="Manage">
|
|
<i class="fas fa-cog"></i>
|
|
</a>
|
|
<button class="btn btn-xs btn-danger" title="Delete"
|
|
onclick="deleteTeam(<?= $team['id'] ?>, '<?= htmlspecialchars(addslashes($team['name'])) ?>')">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="deleteForm" method="POST" style="display:none">
|
|
<input type="hidden" name="_csrf_token" value="<?= $this->csrfToken() ?>">
|
|
</form>
|
|
|
|
<script>
|
|
function deleteTeam(id, name) {
|
|
if (confirm('Delete team "' + name + '"?\nThis will remove access for all members.')) {
|
|
const form = document.getElementById('deleteForm');
|
|
form.action = '/teams/' + id + '/delete';
|
|
form.submit();
|
|
}
|
|
}
|
|
</script>
|