v0.1.31: админский UI /admin, юзерский UI без слова «тенант»
This commit is contained in:
@@ -45,6 +45,15 @@ func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler {
|
||||
// /metrics — Prometheus endpoint для Victoria Metrics scrape
|
||||
r.Handle("/metrics", promhttp.Handler()).Methods("GET")
|
||||
|
||||
// Админ-консоль — статика. Регистрируем ДО admin subrouter,
|
||||
// иначе PathPrefix("/admin") с bearer-auth перехватит GET /admin.
|
||||
r.HandleFunc("/admin", func(w http.ResponseWriter, req *http.Request) {
|
||||
ui.AdminHandler(models.Version).ServeHTTP(w, req)
|
||||
}).Methods("GET")
|
||||
r.HandleFunc("/admin/", func(w http.ResponseWriter, req *http.Request) {
|
||||
ui.AdminHandler(models.Version).ServeHTTP(w, req)
|
||||
}).Methods("GET")
|
||||
|
||||
// Admin API — Bearer token auth, регистрируется через AdminHandler
|
||||
adminHandler := admin.NewHandler(tenantStore, adminToken)
|
||||
adminHandler.RegisterRoutes(r)
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- app/ui/admin.html — админский UI shared-sqs (тенанты, лимиты). Только по admin-токену. -->
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>SQS Admin — Nubes</title>
|
||||
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
||||
<style>
|
||||
:root {
|
||||
--brand-primary: #2563eb;
|
||||
--brand-primary-dark: #1d4ed8;
|
||||
--brand-gray: #d1d5db;
|
||||
--brand-grey-light: #f3f4f6;
|
||||
--text-primary: #1a1a1a;
|
||||
--text-muted: #6b7280;
|
||||
--danger: #dc2626;
|
||||
--success: #16a34a;
|
||||
--warning: #d97706;
|
||||
}
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: system-ui, "Segoe UI", Roboto, sans-serif;
|
||||
font-size: 14px;
|
||||
color: var(--text-primary);
|
||||
background: #fafafa;
|
||||
line-height: 1.5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.topbar {
|
||||
height: 56px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 16px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid var(--brand-gray);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
.topbar .brand { font-weight: 600; }
|
||||
.topbar .muted { color: var(--text-muted); }
|
||||
.topbar .spacer { flex: 1; }
|
||||
.chip {
|
||||
font-family: ui-monospace, monospace;
|
||||
font-size: 12px;
|
||||
color: var(--brand-primary);
|
||||
background: #eff6ff;
|
||||
border: 1px solid #bfdbfe;
|
||||
border-radius: 999px;
|
||||
padding: 2px 10px;
|
||||
}
|
||||
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
|
||||
.card {
|
||||
background: #fff;
|
||||
border: 1px solid var(--brand-gray);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.card-header { background: var(--brand-grey-light); padding: 12px; font-weight: 600; }
|
||||
.card-body { padding: 16px; }
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.toolbar h2 { font-size: 20px; }
|
||||
.tbl-wrap { border: 1px solid var(--brand-gray); border-radius: 8px; overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
th {
|
||||
background: var(--brand-grey-light);
|
||||
text-align: left;
|
||||
text-transform: uppercase;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.3px;
|
||||
padding: 8px 10px;
|
||||
border-right: 1px solid var(--brand-gray);
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
td { padding: 8px 10px; border-right: 1px solid var(--brand-gray); border-bottom: 1px solid var(--brand-gray); }
|
||||
tr:last-child td { border-bottom: none; }
|
||||
td:last-child, th:last-child { border-right: none; }
|
||||
tr:hover td { background: rgba(243,244,246,0.5); }
|
||||
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
|
||||
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
||||
.badge-active { background: rgba(22,163,74,0.12); color: var(--success); }
|
||||
.badge-inactive { background: rgba(220,38,38,0.1); color: var(--danger); }
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 7px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--brand-gray);
|
||||
background: #fff;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.btn:hover { background: var(--brand-grey-light); }
|
||||
.btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
|
||||
.btn-primary:hover { background: var(--brand-primary-dark); }
|
||||
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
|
||||
.btn-danger:hover { background: rgba(220,38,38,0.08); }
|
||||
.btn-sm { padding: 4px 10px; font-size: 12px; }
|
||||
.form-group { margin-bottom: 14px; }
|
||||
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 9px 12px;
|
||||
background: #fff;
|
||||
border: 1px solid var(--brand-gray);
|
||||
border-radius: 8px;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
}
|
||||
.form-group input:focus { outline: none; border-color: var(--brand-primary); }
|
||||
.error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 8px 0; }
|
||||
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
|
||||
.login-box {
|
||||
background: #fff;
|
||||
border: 1px solid var(--brand-gray);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||
padding: 32px;
|
||||
width: 400px;
|
||||
max-width: 92vw;
|
||||
}
|
||||
.login-box img { height: 28px; display: block; margin: 0 auto 12px; }
|
||||
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 24px; }
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.modal {
|
||||
background: #fff;
|
||||
border: 1px solid var(--brand-gray);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
|
||||
padding: 28px;
|
||||
width: 480px;
|
||||
max-width: 92vw;
|
||||
max-height: 88vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.modal h2 { font-size: 20px; margin-bottom: 16px; }
|
||||
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
|
||||
.hidden { display: none !important; }
|
||||
.hint {
|
||||
font-size: 13px;
|
||||
color: #374151;
|
||||
background: var(--brand-grey-light);
|
||||
border: 1px solid var(--brand-gray);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.hint .warn { color: var(--warning); font-weight: 600; }
|
||||
.empty { text-align: center; color: var(--text-muted); padding: 28px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="login-page" class="login-page">
|
||||
<div class="login-box">
|
||||
<img src="/static/logo.svg" alt="Nubes">
|
||||
<h1>SQS Admin</h1>
|
||||
<div class="form-group">
|
||||
<label>Admin-токен</label>
|
||||
<input id="admin-token" type="password" placeholder="Bearer admin token">
|
||||
</div>
|
||||
<div id="login-error" class="error"></div>
|
||||
<button class="btn btn-primary" style="width:100%;justify-content:center" onclick="doLogin()">Войти</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="app" class="hidden">
|
||||
<div class="topbar">
|
||||
<img src="/static/logo.svg" height="18" alt="nubes">
|
||||
<span class="brand">SQS Admin</span>
|
||||
<span class="muted">· тенанты</span>
|
||||
<span class="spacer"></span>
|
||||
<span class="chip">{{VERSION}}</span>
|
||||
<button class="btn btn-sm" onclick="doLogout()">Выйти</button>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="toolbar" style="padding:14px 16px 0">
|
||||
<h2>Тенанты</h2>
|
||||
<div style="display:flex;gap:10px;align-items:center">
|
||||
<button class="btn btn-sm" onclick="loadTenants()">⟳ Обновить</button>
|
||||
<button class="btn btn-primary btn-sm" onclick="openCreateModal()">+ Создать</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="list-error" class="error"></div>
|
||||
<div class="tbl-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>ID</th>
|
||||
<th>Access Key</th>
|
||||
<th>Макс. очередей</th>
|
||||
<th>Статус</th>
|
||||
<th>Создан</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tenants-tbody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modal-create" class="modal-overlay hidden" onclick="if(event.target===this)closeCreateModal()">
|
||||
<div class="modal">
|
||||
<h2>Создать тенанта</h2>
|
||||
<div class="form-group">
|
||||
<label>Имя</label>
|
||||
<input id="ct-name" placeholder="service-name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Макс. очередей</label>
|
||||
<input id="ct-queues" type="number" value="10" min="1" max="1000">
|
||||
</div>
|
||||
<div id="ct-error" class="error"></div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-primary" onclick="createTenant()">Создать</button>
|
||||
<button class="btn" onclick="closeCreateModal()">Отмена</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modal-creds" class="modal-overlay hidden" onclick="if(event.target===this)closeCredsModal()">
|
||||
<div class="modal">
|
||||
<h2>Тенант создан</h2>
|
||||
<div class="hint">
|
||||
<p class="warn">⚠ Передайте эти ключи владельцу тенанта.</p>
|
||||
<p>Это креды для AWS CLI/SDK (подпись Signature V4).</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Access Key</label>
|
||||
<input id="creds-ak" readonly onclick="copyField(this)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Secret Key</label>
|
||||
<input id="creds-sk" readonly onclick="copyField(this)">
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-primary" onclick="closeCredsModal()">Готово</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let adminToken = localStorage.getItem('sqs_admin_token') || '';
|
||||
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s)
|
||||
.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')
|
||||
.replace(/"/g,'"').replace(/'/g,''');
|
||||
}
|
||||
|
||||
function fmtDate(iso) {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleDateString('ru-RU') + ' ' + d.toLocaleTimeString('ru-RU', {hour:'2-digit',minute:'2-digit'});
|
||||
}
|
||||
|
||||
function api(path, opts = {}) {
|
||||
return fetch(path, {
|
||||
...opts,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + adminToken,
|
||||
...(opts.headers || {})
|
||||
}
|
||||
}).then(r => {
|
||||
if (r.status === 401) {
|
||||
doLogout();
|
||||
throw new Error('Неверный или истёкший admin-токен');
|
||||
}
|
||||
if (!r.ok) {
|
||||
return r.json().catch(() => ({}))
|
||||
.then(d => { throw new Error(d.error || r.status + ' ' + r.statusText); });
|
||||
}
|
||||
if (r.status === 204) return null;
|
||||
return r.json();
|
||||
});
|
||||
}
|
||||
|
||||
function doLogin() {
|
||||
const t = document.getElementById('admin-token').value.trim();
|
||||
if (!t) return;
|
||||
adminToken = t;
|
||||
api('/admin/tenants')
|
||||
.then(() => {
|
||||
localStorage.setItem('sqs_admin_token', t);
|
||||
document.getElementById('login-page').classList.add('hidden');
|
||||
document.getElementById('app').classList.remove('hidden');
|
||||
loadTenants();
|
||||
})
|
||||
.catch(err => {
|
||||
adminToken = '';
|
||||
document.getElementById('login-error').textContent = 'Ошибка: ' + err.message;
|
||||
});
|
||||
}
|
||||
|
||||
function doLogout() {
|
||||
adminToken = '';
|
||||
localStorage.removeItem('sqs_admin_token');
|
||||
document.getElementById('app').classList.add('hidden');
|
||||
document.getElementById('login-page').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function loadTenants() {
|
||||
document.getElementById('list-error').textContent = '';
|
||||
api('/admin/tenants')
|
||||
.then(list => renderTenants(list || []))
|
||||
.catch(err => { document.getElementById('list-error').textContent = 'Ошибка: ' + err.message; });
|
||||
}
|
||||
|
||||
function renderTenants(list) {
|
||||
const tbody = document.getElementById('tenants-tbody');
|
||||
tbody.innerHTML = (list || []).map(t => `
|
||||
<tr>
|
||||
<td><strong>${esc(t.name)}</strong>${t.id === (window._lastCreated || '') ? '' : ''}</td>
|
||||
<td class="mono">${esc(t.id)}</td>
|
||||
<td class="mono">${esc(t.access_key)}</td>
|
||||
<td>${t.max_queues}</td>
|
||||
<td>${t.active
|
||||
? '<span class="badge badge-active">active</span>'
|
||||
: '<span class="badge badge-inactive">inactive</span>'}</td>
|
||||
<td>${fmtDate(t.created_at)}</td>
|
||||
<td><button class="btn btn-danger btn-sm" onclick="deleteTenant('${esc(t.id)}','${esc(t.name)}')">Удалить</button></td>
|
||||
</tr>
|
||||
`).join('') || '<tr><td colspan="7" class="empty">Тенантов нет</td></tr>';
|
||||
}
|
||||
|
||||
function openCreateModal() {
|
||||
document.getElementById('ct-name').value = '';
|
||||
document.getElementById('ct-queues').value = '10';
|
||||
document.getElementById('ct-error').textContent = '';
|
||||
document.getElementById('modal-create').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeCreateModal() {
|
||||
document.getElementById('modal-create').classList.add('hidden');
|
||||
}
|
||||
|
||||
function createTenant() {
|
||||
const name = document.getElementById('ct-name').value.trim();
|
||||
const maxQ = parseInt(document.getElementById('ct-queues').value) || 10;
|
||||
if (!name) {
|
||||
document.getElementById('ct-error').textContent = 'Укажите имя';
|
||||
return;
|
||||
}
|
||||
api('/admin/tenants', { method: 'POST', body: JSON.stringify({ name: name, max_queues: maxQ }) })
|
||||
.then(data => {
|
||||
closeCreateModal();
|
||||
document.getElementById('creds-ak').value = data.access_key || '';
|
||||
document.getElementById('creds-sk').value = data.secret_key || '';
|
||||
document.getElementById('modal-creds').classList.remove('hidden');
|
||||
loadTenants();
|
||||
})
|
||||
.catch(err => { document.getElementById('ct-error').textContent = 'Ошибка: ' + err.message; });
|
||||
}
|
||||
|
||||
function closeCredsModal() {
|
||||
document.getElementById('modal-creds').classList.add('hidden');
|
||||
}
|
||||
|
||||
function deleteTenant(id, name) {
|
||||
if (!confirm('Удалить тенанта "' + name + '"?\nВсе его очереди и сообщения будут удалены.')) return;
|
||||
api('/admin/tenants/' + id, { method: 'DELETE' })
|
||||
.then(() => loadTenants())
|
||||
.catch(err => alert('Ошибка: ' + err.message));
|
||||
}
|
||||
|
||||
function copyField(el) {
|
||||
el.select();
|
||||
navigator.clipboard && navigator.clipboard.writeText(el.value);
|
||||
}
|
||||
|
||||
// init
|
||||
if (adminToken) {
|
||||
document.getElementById('login-page').classList.add('hidden');
|
||||
document.getElementById('app').classList.remove('hidden');
|
||||
loadTenants();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+15
-1
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed index.html info.html static
|
||||
//go:embed index.html info.html admin.html static
|
||||
var content embed.FS
|
||||
|
||||
// Handler — возвращает http.Handler, раздающий встроенный index.html
|
||||
@@ -32,6 +32,20 @@ func InfoHandler(version string) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// AdminHandler — админская консоль (GET /admin) с подстановкой версии
|
||||
func AdminHandler(version string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
body, err := content.ReadFile("admin.html")
|
||||
if err != nil {
|
||||
http.Error(w, "admin page unavailable", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
html := strings.ReplaceAll(string(body), "{{VERSION}}", version)
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
_, _ = w.Write([]byte(html))
|
||||
})
|
||||
}
|
||||
|
||||
// StaticHandler — раздаёт /static/* (логотип, favicon) для публичных страниц
|
||||
func StaticHandler() http.Handler {
|
||||
sub, err := fs.Sub(content, "static")
|
||||
|
||||
+9
-13
@@ -374,17 +374,17 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }
|
||||
<button class="btn btn-primary" style="width:100%" onclick="doLogin()">Войти</button>
|
||||
<p style="font-size:12px;color:var(--text-secondary);margin-top:16px">
|
||||
Для демо используйте token: demo-ui-shared-sqs-ngcloud-2026.<br>
|
||||
Для личного tenant-а используйте API token из панели Nubes.
|
||||
Для личного аккаунта используйте API token из панели Nubes.
|
||||
</p>
|
||||
<div style="margin-top:24px;text-align:left;font-size:12px;color:var(--text-secondary);border-top:1px solid var(--border);padding-top:16px;line-height:1.7">
|
||||
<div style="font-weight:700;color:var(--text-primary);margin-bottom:6px;letter-spacing:0.5px">Информация о сервисе</div>
|
||||
<div>Endpoint: <span style="color:var(--accent);font-family:monospace">https://sqs.containerk8s.dev.nubes.ru</span></div>
|
||||
<div>Health: <span style="font-family:monospace">GET /health</span> · Метрики: <span style="font-family:monospace">GET /metrics</span></div>
|
||||
<div>SQS API: <span style="font-family:monospace">POST /</span> (AWS Signature V4, регион <span style="font-family:monospace">us-east-1</span>)</div>
|
||||
<div>Admin API: <span style="font-family:monospace">POST /admin/tenants</span> (Bearer token)</div>
|
||||
<div>Админ-консоль: <a href="/admin">/admin</a> (вход по admin-токену)</div>
|
||||
<div>Realm: <span style="font-family:monospace">iot-naeel</span> · Persistence: Managed Redis</div>
|
||||
<div>Версия: <span id="svc-version" style="font-family:monospace">—</span></div>
|
||||
<div>Образ: <span style="font-family:monospace">naeel/shared-sqs:v0.1.29</span></div>
|
||||
<div>Образ: <span style="font-family:monospace">naeel/shared-sqs:v0.1.31</span></div>
|
||||
<div style="margin-top:8px;color:var(--warning)">Статус: тестирование</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -413,7 +413,7 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }
|
||||
<!-- ===== CREATE TENANT MODAL ===== -->
|
||||
<div id="modal-create" class="modal-overlay hidden" onclick="if(event.target===this)closeModal()">
|
||||
<div class="modal">
|
||||
<h2>Создать тенанта</h2>
|
||||
<h2>Создать аккаунт</h2>
|
||||
<div class="form-group">
|
||||
<label for="ct-name">Имя</label>
|
||||
<input id="ct-name" placeholder="my-service">
|
||||
@@ -435,7 +435,7 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }
|
||||
<div class="modal">
|
||||
<h2>Credentials</h2>
|
||||
<div class="creds-hint">
|
||||
<p class="warn">⚠ Сохраните ключи — это креды вашего тенанта для AWS CLI/SDK.</p>
|
||||
<p class="warn">⚠ Сохраните ключи — это креды вашего аккаунта для AWS CLI/SDK.</p>
|
||||
<p><strong>Зачем:</strong> приложения подключаются к SQS API по протоколу AWS (подпись Signature V4). Токен входа в консоль для этого не подходит.</p>
|
||||
<p><strong>Что делать:</strong> укажите ключи одним из двух способов:</p>
|
||||
<p class="creds-sub">Способ 1 — переменные окружения:</p>
|
||||
@@ -660,10 +660,6 @@ function renderDashboard(health, tenants) {
|
||||
const el = document.getElementById('view-dashboard');
|
||||
el.innerHTML = `
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">${health.tenant_count || 0}</div>
|
||||
<div class="stat-label">Тенанты</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">${health.queue_count || 0}</div>
|
||||
<div class="stat-label">Очереди</div>
|
||||
@@ -683,7 +679,7 @@ function renderDashboard(health, tenants) {
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="toolbar">
|
||||
<h2>Мой tenant</h2>
|
||||
<h2>Мой аккаунт</h2>
|
||||
<div style="display:flex;gap:12px;align-items:center">
|
||||
<div class="auto-refresh">
|
||||
<span>⟳ 10с</span>
|
||||
@@ -711,7 +707,7 @@ function renderDashboard(health, tenants) {
|
||||
<td style="font-size:12px;color:var(--text-secondary)">${fmtDate(t.created_at)}</td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
${(!tenants || tenants.length === 0) ? '<tr><td colspan="4" style="text-align:center;color:var(--text-secondary);padding:32px">Tenant не найден</td></tr>' : ''}
|
||||
${(!tenants || tenants.length === 0) ? '<tr><td colspan="4" style="text-align:center;color:var(--text-secondary);padding:32px">Аккаунт не найден</td></tr>' : ''}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -746,7 +742,7 @@ function renderTenant(tenant, queues) {
|
||||
const totalMsgs = (queues || []).reduce((s, q) => s + q.messages + q.not_visible, 0);
|
||||
el.innerHTML = `
|
||||
<div class="breadcrumb">
|
||||
<a href="#" onclick="event.preventDefault();showDashboard()">Мой tenant</a>
|
||||
<a href="#" onclick="event.preventDefault();showDashboard()">Мой аккаунт</a>
|
||||
<span>›</span>
|
||||
${esc(tenant.name)}
|
||||
</div>
|
||||
@@ -875,7 +871,7 @@ function showCredentials() {
|
||||
|
||||
// deleteTenant — DELETE /tenants/{id} с подтверждением
|
||||
function deleteTenant(id, name) {
|
||||
if (!confirm('Удалить тенанта "' + name + '"?\nВсе его очереди будут удалены.')) return;
|
||||
if (!confirm('Удалить аккаунт "' + name + '"?\nВсе очереди будут удалены.')) return;
|
||||
api('/tenants/' + id, { method: 'DELETE' })
|
||||
.then(() => loadDashboard())
|
||||
.catch(err => alert('Ошибка удаления: ' + err.message));
|
||||
|
||||
Reference in New Issue
Block a user