Files
server-manager/views/teams/show.php
Agent 88f3c1f964 refactor: extract inline CSS/JS from views into separate asset files (20+ files)
Phase A — HTML removed from PHP files:
- RateLimitMiddleware.php: heredoc moved to views/errors/429.php
- public/index.php: inline HTML replaced with View::error()
- AuthMiddleware.php: <script> redirect replaced with <meta refresh>

Phase B — Inline CSS/JS extracted from views:
- CSS: landing.css (459 lines), legal.css (shared by terms+privacy)
- JS: 17 new files extracted from ~20 view files
  - main.js (layout sidebar + notifications)
  - dashboard-chart.js, server-show.js, server-services.js
  - nginx-manager.js, database-manager.js
  - terminal.js, team-show.js, team-index.js
  - server-list.js, server-permissions.js (shared by edit+create)
  - server-ssl.js, server-processes.js, system-users.js
  - admin-users.js, audit-log.js, admin-notifications.js, admin-security.js
  - notifications.js

Total: -3264 lines from views, +288 lines in new assets
2026-06-14 08:04:01 -04:00

154 lines
6.9 KiB
PHP

<?php
$team = $team ?? [];
$members = $members ?? [];
$servers = $servers ?? [];
$availableServers = $availableServers ?? [];
?>
<div class="page-header">
<div class="page-header-left">
<div class="back-link">
<a href="/teams"><i class="fas fa-arrow-left"></i> Back to Teams</a>
</div>
<h1 class="page-title"><?= htmlspecialchars($team['name'] ?? '') ?></h1>
<p class="page-subtitle"><?= htmlspecialchars($team['description'] ?? '') ?></p>
</div>
<div class="page-header-right">
<button class="btn btn-secondary" onclick="editTeam()">
<i class="fas fa-edit"></i> Edit
</button>
<button class="btn btn-danger" onclick="deleteTeam()">
<i class="fas fa-trash"></i> Delete
</button>
</div>
</div>
<div class="dashboard-grid">
<div class="dashboard-card">
<div class="card-header">
<h2><i class="fas fa-users"></i> Members</h2>
<span class="badge badge-info"><?= count($members) ?></span>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>User</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="membersList">
<?php foreach ($members as $member): ?>
<tr>
<td>
<strong><?= htmlspecialchars($member['username']) ?></strong>
<br><small class="text-muted"><?= htmlspecialchars($member['email']) ?></small>
</td>
<td>
<button class="btn btn-xs btn-danger"
onclick="removeMember(<?= $member['user_id'] ?>, '<?= htmlspecialchars(addslashes($member['username'])) ?>')">
<i class="fas fa-user-minus"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="autocomplete-wrapper" style="margin-top:1rem">
<label class="form-label">Add Member</label>
<div class="autocomplete" id="userAutocomplete">
<input type="text" class="form-input autocomplete-input"
id="addUserInput" placeholder="Search users..."
autocomplete="off">
<div class="autocomplete-dropdown" id="userDropdown"></div>
</div>
<small class="form-hint">Type at least 2 characters to search users.</small>
</div>
</div>
</div>
<div class="dashboard-card">
<div class="card-header">
<h2><i class="fas fa-server"></i> Servers</h2>
<span class="badge badge-primary"><?= count($servers) ?></span>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Server</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($servers as $s): ?>
<tr>
<td>
<a href="/servers/<?= $s['server_id'] ?>">
<?= htmlspecialchars($s['server_name']) ?>
</a>
</td>
<td>
<select class="form-select form-select-sm role-select"
onchange="updateServerRole(<?= $s['server_id'] ?>, this.value)"
style="width:auto">
<option value="viewer" <?= $s['role'] === 'viewer' ? 'selected' : '' ?>>Viewer</option>
<option value="manager" <?= $s['role'] === 'manager' ? 'selected' : '' ?>>Manager</option>
</select>
</td>
<td>
<button class="btn btn-xs btn-danger"
onclick="removeServer(<?= $s['server_id'] ?>, '<?= htmlspecialchars(addslashes($s['server_name'])) ?>')">
<i class="fas fa-unlink"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php if (!empty($availableServers)): ?>
<form class="form-inline" style="margin-top:1rem;display:flex;gap:0.5rem;align-items:end" onsubmit="addServer(event)">
<input type="hidden" name="_csrf_token" value="<?= $this->csrfToken() ?>">
<div class="form-group" style="flex:1;margin-bottom:0">
<select id="addServerId" class="form-select" required>
<option value="">Assign server...</option>
<?php foreach ($availableServers as $s): ?>
<option value="<?= $s['id'] ?>">
<?= htmlspecialchars($s['name']) ?> (<?= htmlspecialchars($s['ip_address']) ?>)
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group" style="margin-bottom:0">
<select id="addServerRole" class="form-select" required>
<option value="viewer">Viewer</option>
<option value="manager">Manager</option>
</select>
</div>
<button type="submit" class="btn btn-primary btn-sm">
<i class="fas fa-plus"></i> Assign
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
<form id="postForm" method="POST" style="display:none">
<input type="hidden" name="_csrf_token" value="<?= $this->csrfToken() ?>">
</form>
<script>
const teamId = <?= $team['id'] ?>;
const teamName = '<?= htmlspecialchars(addslashes($team['name'] ?? '')) ?>';
const teamDescription = '<?= htmlspecialchars(addslashes($team['description'] ?? '')) ?>';
</script>
<script src="/assets/js/team-show.js"></script>