Files
app-autotest/site/templates/index.html
T

150 lines
6.8 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title>Autotest</title>
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='favicon.svg') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
<script src="https://unpkg.com/lucide@latest"></script>
<style>
.layout { display:flex; gap:16px; max-width:1200px; margin:16px auto; padding:0 16px; }
.left { width:380px; flex-shrink:0; }
.right { flex:1; min-width:0; }
.svc-row { cursor:pointer; }
.inst-row { cursor:default; }
</style>
</head>
<body>
<form method="post" style="max-width:1200px;margin:16px auto 0;padding:0 16px;display:flex;align-items:center;gap:8px;">
<input type="password" name="token" placeholder="env: {{ env_token_masked }}" value="{{ '' if not has_user_token else '••••••••' }}" style="height:28px;width:200px;font-size:12px;border:1px solid var(--brand-gray);border-radius:4px;padding:0 6px;" />
<button type="submit" name="action" value="save" class="btn" style="height:28px;font-size:12px;padding:0 8px;">OK</button>
{% if has_user_token %}
<button type="submit" name="action" value="clear" class="btn btn-danger" style="height:28px;font-size:12px;padding:0 8px;">Выйти</button>
{% endif %}
{% if error %}<span style="color:var(--destructive);font-size:12px;">{{ error }}</span>{% endif %}
</form>
<div class="layout">
<!-- ЛЕВАЯ КОЛОНКА -->
<div class="left">
{% if organization %}
<div class="card">
<div class="card-header">Организация</div>
<div class="card-body" style="font-size:12px;">
<table>
<tr><td style="color:var(--muted);">Имя</td><td>{{ organization.displayName }}</td></tr>
<tr><td style="color:var(--muted);">UID</td><td style="font-family:monospace;font-size:11px;">{{ organization.instanceUid }}</td></tr>
<tr><td style="color:var(--muted);">Статус</td><td><span class="badge badge-success">{{ organization.explainedStatus or "OK" }}</span></td></tr>
</table>
</div>
</div>
{% endif %}
{% if instances %}
<div class="card" style="margin-top:8px;">
<div class="card-header" style="cursor:pointer;" onclick="this.nextElementSibling.style.display=this.nextElementSibling.style.display==='none'?'block':'none'">
Инстансы ({{ instances|length }})
</div>
<div class="card-body" style="padding:0;max-height:300px;overflow-y:auto;">
<table>
{% for i in instances %}
<tr class="inst-row">
<td style="font-size:12px;">{{ i.displayName }}</td>
<td style="font-size:11px;color:var(--muted);">{{ i.svc }}</td>
<td><span class="badge badge-success" style="font-size:10px;">{{ i.explainedStatus or "?" }}</span></td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
</div>
<!-- ПРАВАЯ КОЛОНКА -->
<div class="right">
{% if services %}
<div class="card">
<div class="card-header" style="cursor:pointer;" onclick="document.getElementById('svc-table').style.display=document.getElementById('svc-table').style.display==='none'?'':'none'">
Сервисы ({{ services|length }})
</div>
<div id="svc-table" style="display:none;">
<div class="card-body" style="padding:0;max-height:60vh;overflow-y:auto;">
<table>
<thead>
<tr>
<th style="width:50px;">#</th>
<th>Сервис</th>
<th style="width:70px;">Опер.</th>
</tr>
</thead>
<tbody>
{% for s in services %}
<tr class="svc-row" data-svc-id="{{ s.svcId }}">
<td>{{ s.svcId }}</td>
<td style="font-size:12px;">{{ s.svc }}{% if s.svcExtendedName %} <span style="color:var(--muted);">— {{ s.svcExtendedName }}</span>{% endif %}</td>
<td style="text-align:center;"><span class="ops-count" id="ops-{{ s.svcId }}">?</span></td>
</tr>
<tr class="ops-detail" id="detail-{{ s.svcId }}" style="display:none;">
<td colspan="3" style="padding:4px 10px;background:var(--brand-grey-light);"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>
</div>
<script>
const opsCache = {};
document.querySelectorAll('.svc-row').forEach(row => {
row.addEventListener('click', async () => {
const svcId = row.dataset.svcId;
const detail = document.getElementById('detail-' + svcId);
if (detail.style.display === 'table-row') {
detail.style.display = 'none';
row.style.background = '';
return;
}
document.querySelectorAll('.ops-detail').forEach(d => d.style.display = 'none');
document.querySelectorAll('.svc-row').forEach(r => r.style.background = '');
row.style.background = 'var(--brand-grey-light)';
detail.style.display = 'table-row';
if (opsCache[svcId]) {
fillDetail(svcId, opsCache[svcId]);
return;
}
detail.cells[0].innerHTML = '<span style=\"color:var(--muted);font-size:12px;\">Загрузка...</span>';
try {
const r = await fetch('/api/operations/' + svcId);
const d = await r.json();
opsCache[svcId] = d;
fillDetail(svcId, d);
} catch(e) {
detail.cells[0].innerHTML = '<span style=\"color:var(--destructive);font-size:12px;\">Ошибка</span>';
}
});
});
function fillDetail(svcId, data) {
const detail = document.getElementById('detail-' + svcId);
if (data.error) {
detail.cells[0].innerHTML = '<span style=\"color:var(--destructive);font-size:12px;\">' + data.error + '</span>';
return;
}
const ops = data.operations || [];
document.getElementById('ops-' + svcId).textContent = ops.length;
detail.cells[0].innerHTML = ops.map(o =>
'<span class=\"badge\" style=\"margin:2px;font-size:11px;\">' + o.operation + '</span>'
).join('') || '<span style=\"color:var(--muted);font-size:12px;\">Нет операций</span>';
}
</script>
</body>
</html>