File size: 3,990 Bytes
5c5b371 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
<%- include("partials/shared_header", { title: "Users - OAI Reverse Proxy Admin" }) %>
<h1>User Token List</h1>
<% if (users.length === 0) { %>
<p>No users found.</p>
<% } else { %>
<label for="toggle-nicknames"><input type="checkbox" id="toggle-nicknames" onchange="toggleNicknames()" /> Show Nicknames</label>
<table class="striped full-width">
<thead>
<tr>
<th>User</th>
<th <% if (sort.includes("ip")) { %>class="active"<% } %> ><a href="/admin/manage/list-users?sort=ip">IPs</a></th>
<th <% if (sort.includes("promptCount")) { %>class="active"<% } %> ><a href="/admin/manage/list-users?sort=promptCount">Prompts</a></th>
<th <% if (sort.includes("sumCost")) { %>class="active"<% } %> ><a href="/admin/manage/list-users?sort=sumCost">Usage</a></th>
<th>Type</th>
<th <% if (sort.includes("createdAt")) { %>class="active"<% } %> ><a href="/admin/manage/list-users?sort=createdAt">Created (UTC)</a></th>
<th <% if (sort.includes("lastUsedAt")) { %>class="active"<% } %> ><a href="/admin/manage/list-users?sort=lastUsedAt">Last Used (UTC)</a></th>
<th colspan="2">Banned?</th>
</tr>
</thead>
<tbody>
<% users.forEach(function(user){ %>
<tr>
<td>
<a href="/admin/manage/view-user/<%= user.token %>">
<code class="usertoken"><%= user.token %></code>
<% if (user.nickname) { %>
<span class="nickname" style="display: none"><%= user.nickname %></span>
<% } else { %>
<code class="nickname" style="display: none"><%= "..." + user.token.slice(-5) %></code>
<% } %>
</a>
</td>
<td><%= user.ip.length %></td>
<td><%= user.promptCount %></td>
<td><%= user.prettyUsage %></td>
<td><%= user.type %></td>
<td><%= user.createdAt %></td>
<td><%= user.lastUsedAt ?? "never" %></td>
<td class="actions">
<% if (user.disabledAt) { %>
<a title="Unban" href="#" class="unban" data-token="<%= user.token %>">🔄️</a>
<% } else { %>
<a title="Ban" href="#" class="ban" data-token="<%= user.token %>">🚫</a>
<% } %>
<td><%= user.disabledAt ? "Yes" : "No" %> <%= user.disabledReason ? `(${user.disabledReason})` : "" %></td>
</td>
</tr>
<% }); %>
</table>
<ul class="pagination">
<% if (page > 1) { %>
<li><a href="/admin/manage/list-users?sort=<%= sort %>&page=<%= page - 1 %>">«</a></li>
<% } %> <% for (var i = 1; i <= pageCount; i++) { %>
<li <% if (i === page) { %>class="active"<% } %>><a href="/admin/manage/list-users?sort=<%= sort %>&page=<%= i %>"><%= i %></a></li>
<% } %> <% if (page < pageCount) { %>
<li><a href="/admin/manage/list-users?sort=<%= sort %>&page=<%= page + 1 %>">»</a></li>
<% } %>
</ul>
<p>Showing <%= page * pageSize - pageSize + 1 %> to <%= users.length + page * pageSize - pageSize %> of <%= totalCount %> users.</p>
<%- include("partials/shared_pagination") %>
<% } %>
<script>
function toggleNicknames() {
const checked = document.getElementById("toggle-nicknames").checked;
const visibleSelector = checked ? ".nickname" : ".usertoken";
const hiddenSelector = checked ? ".usertoken" : ".nickname";
document.querySelectorAll(visibleSelector).forEach(function (el) {
el.style.display = "inline";
});
document.querySelectorAll(hiddenSelector).forEach(function (el) {
el.style.display = "none";
});
localStorage.setItem("showNicknames", checked);
}
const state = localStorage.getItem("showNicknames") === "true";
document.getElementById("toggle-nicknames").checked = state;
toggleNicknames();
</script>
<%- include("partials/admin-ban-xhr-script") %>
<%- include("partials/admin-footer") %>
|