78 lines
3.7 KiB
Plaintext
78 lines
3.7 KiB
Plaintext
<!DOCTYPE html>
|
|
<html><head><meta charset="utf-8"><title>V2 IP WhiteList</title>
|
|
<style>
|
|
body{font-family:sans-serif;max-width:960px;margin:20px auto;color:#222}
|
|
table{width:100%;border-collapse:collapse;margin:10px 0}
|
|
th,td{border:1px solid #ccc;padding:6px;text-align:left}
|
|
th{background:#f5f5f5}
|
|
.bar{display:flex;justify-content:space-between;align-items:center;background:#eee;padding:10px;margin-bottom:10px}
|
|
button,input,select{padding:4px 8px}
|
|
.add-form{background:#f0f8ff;padding:10px;margin:10px 0}
|
|
</style></head><body>
|
|
<div class="bar">
|
|
<span><strong>V2 IP WhiteList</strong> <small>v<%= version %></small></span>
|
|
<span>
|
|
<% if (typeof canAdmin !== 'undefined' && canAdmin) { %>
|
|
<form method="POST" action="/v2/toggle-admin" style="display:inline">
|
|
<button style="font-size:.8rem;padding:.2rem .6rem;border:1px solid #ccc;border-radius:4px;background:<%= adminMode ? '#2563eb' : '#fff' %>;color:<%= adminMode ? '#fff' : '#333' %>;cursor:pointer;">
|
|
<%= adminMode ? 'Выйти из админки' : 'Администратор' %>
|
|
</button>
|
|
</form>
|
|
<% } %>
|
|
<%= user.email %>
|
|
</span>
|
|
<span>
|
|
<form method="GET" action="/v2/app" style="display:inline">
|
|
<select name="switchTo" onchange="this.form.submit()">
|
|
<% companies.forEach(function(c) { %>
|
|
<option value="<%= c.client_id %>" <%= c.client_id === activeClientId ? 'selected' : '' %>><%= c.company_name || c.client_id %> (<%= c.client_id %>)</option>
|
|
<% }) %>
|
|
</select>
|
|
</form>
|
|
<a href="/v2/logout">Выйти</a>
|
|
</span>
|
|
</div>
|
|
<script>
|
|
const p=new URLSearchParams(location.search);
|
|
if(p.get('msg')){document.body.insertAdjacentHTML('afterbegin','<div style="background:#4caf50;color:#fff;padding:8px">'+p.get('msg')+'</div>');history.replaceState(null,'','/v2/app')}
|
|
if(p.get('error')){document.body.insertAdjacentHTML('afterbegin','<div style="background:#f44336;color:#fff;padding:8px">'+p.get('error')+'</div>');history.replaceState(null,'','/v2/app')}
|
|
</script>
|
|
<p>Записей: <strong><%= used %></strong> из <%= limit %></p>
|
|
<div class="add-form">
|
|
<form method="POST" action="/v2/app/add">
|
|
<input name="cidr" placeholder="x.x.x.x/xx" size="18" required>
|
|
<input name="comment" placeholder="комментарий" size="30">
|
|
<button>Добавить</button>
|
|
</form>
|
|
</div>
|
|
<table>
|
|
<tr><th>CIDR</th><th>Комментарий</th><th>Кто</th><th>Когда</th><th></th></tr>
|
|
<% if (entries.length === 0) { %>
|
|
<tr><td colspan="5">Нет записей</td></tr>
|
|
<% } %>
|
|
<% entries.forEach(function(e) { %>
|
|
<tr style="<%= e.deleted_at ? 'text-decoration:line-through;opacity:0.5' : '' %>">
|
|
<td><%= e.value_cidr %></td>
|
|
<td><%= e.comment || '' %></td>
|
|
<td><%= e.created_by %></td>
|
|
<td><%= new Date(e.created_at).toLocaleString('ru') %></td>
|
|
<td>
|
|
<% if (e.deleted_at) { %>
|
|
<span style="color:#888">удалено</span>
|
|
<% } else { %>
|
|
<form method="POST" action="/v2/app/edit/<%= e.id %>" style="display:inline">
|
|
<input name="cidr" value="<%= e.value_cidr %>" size="18">
|
|
<input name="comment" value="<%= e.comment || '' %>" size="20">
|
|
<button>изменить</button>
|
|
</form>
|
|
<form method="POST" action="/v2/app/delete/<%= e.id %>" style="display:inline">
|
|
<button onclick="return confirm('Удалить?')">удалить</button>
|
|
</form>
|
|
<% } %>
|
|
</td>
|
|
</tr>
|
|
<% }) %>
|
|
</table>
|
|
<p><a href="/v2/app?deleted=<%= includeDeleted ? '0' : '1' %>"><%= includeDeleted ? 'Скрыть удалённые' : 'Показать удалённые' %></a></p>
|
|
</body></html>
|