Add code
This commit is contained in:
97
views/group_secrets.ejs
Normal file
97
views/group_secrets.ejs
Normal file
@ -0,0 +1,97 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Admin - Manage Secrets in Group: <%= group.name %></title>
|
||||
<link rel="stylesheet" href="/css/admin_styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-links">
|
||||
<a href="/admin">Back to Main Admin</a>
|
||||
<a href="/admin/clients">Manage Clients</a>
|
||||
<a href="/admin/logout" class="logout-link">Logout</a>
|
||||
</div>
|
||||
|
||||
<h1>Manage Secrets in Group: <em><%= group.name %></em> (ID: <%= group.id %>)</h1>
|
||||
|
||||
<% if (message && message.text) { %>
|
||||
<div class="alert <%= message.type === 'success' ? 'alert-success' : 'alert-error' %>">
|
||||
<%= message.text %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<%# Placeholder for "Add New Secret to This Group" form - Step 5c %>
|
||||
<h3>Add New Secret to Group "<%= group.name %>"</h3>
|
||||
<form action="/admin/groups/<%= group.id %>/secrets/add" method="POST" class="mb-3">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="form-group">
|
||||
<label for="secretKey">Secret Key:</label>
|
||||
<input type="text" id="secretKey" name="secretKey" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="secretValue">Secret Value (JSON format recommended):</label>
|
||||
<textarea id="secretValue" name="secretValue" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn">Add Secret to Group</button>
|
||||
</form>
|
||||
<hr>
|
||||
|
||||
<% if (typeof editingSecretKey !== 'undefined' && editingSecretKey && typeof secretToEdit !== 'undefined') { %>
|
||||
<h3>Edit Secret Value: <em><%= editingSecretKey %></em> in Group <em><%= group.name %></em></h3>
|
||||
<form action="/admin/groups/<%= group.id %>/secrets/<%= encodeURIComponent(editingSecretKey) %>/update" method="POST" class="mb-3">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="form-group">
|
||||
<label for="editSecretKeyDisplay">Secret Key (read-only):</label>
|
||||
<input type="text" id="editSecretKeyDisplay" name="secretKeyDisplay" value="<%= editingSecretKey %>" readonly class="form-control-plaintext">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editSecretValue">New Value (JSON format recommended):</label>
|
||||
<textarea id="editSecretValue" name="secretValue" required><%= typeof secretToEdit === 'string' ? secretToEdit : JSON.stringify(secretToEdit, null, 2) %></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn">Update Secret Value</button>
|
||||
<a href="/admin/groups/<%= group.id %>/secrets" class="btn btn-secondary ml-2">Cancel Edit</a>
|
||||
</form>
|
||||
<hr>
|
||||
<% } %>
|
||||
|
||||
|
||||
<h2>Secrets in this Group</h2>
|
||||
<% if (secretsInGroup && secretsInGroup.length > 0) { %>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value (Preview)</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% secretsInGroup.forEach(secret => { %>
|
||||
<tr>
|
||||
<td><%= secret.key %></td>
|
||||
<td>
|
||||
<%
|
||||
let preview = typeof secret.value === 'string' ? secret.value : JSON.stringify(secret.value);
|
||||
if (preview.length > 50) preview = preview.substring(0, 50) + '...';
|
||||
%>
|
||||
<%= preview %>
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="/admin/groups/<%= group.id %>/secrets/<%= encodeURIComponent(secret.key) %>/edit">Edit Value</a>
|
||||
<form action="/admin/groups/<%= group.id %>/secrets/<%= encodeURIComponent(secret.key) %>/delete" method="POST" class="form-inline" onsubmit="return confirm('Are you sure you want to delete the secret \"<%= secret.key %>\"? This action cannot be undone.');">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<button type="submit" class="delete">Delete Secret</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% } else { %>
|
||||
<p>No secrets currently in this group. You can add one above.</p>
|
||||
<% } %>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user