Files
app-autotest/site/templates/index.html
T
naeel 2133a1b2fe v1.2.9: Phase 1 — sidebar + views layout
index.html: full rewrite
- Sidebar (192px/72px, blue top border): Верстак/Обзор/История/Сценарии/Логи
- Views: workbench (service left rail + instances/params right), overview, history, scenarios, logs
- Token form moved to sidebar bottom
- All existing DOM ids preserved: inst-list, params-area, params-form, btn-test,
  test-status, create-btn-area, history-card, history-body, scenario-card, scenario-body
- Log panel adjusted: left 72px (sidebar width)
- Fonts increased: 12-14px

views.js (NEW): switchView(id) — show/hide views, auto-load content on open
2026-07-31 13:16:50 +04:00

186 lines
11 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') }}" />
<style>
.svc-item { cursor:pointer; padding:4px 8px; font-size:13px; border-radius:4px; }
.svc-item:hover, .svc-item.active { background:#dbeafe; font-weight:600; }
.inst-item { cursor:pointer; display:flex; align-items:center; gap:6px; padding:4px 8px; font-size:13px; border-radius:4px; }
.inst-item:hover, .inst-item.active { background:var(--brand-grey-light); }
.inst-ops { display:none; margin-left:16px; }
.inst-ops.open { display:flex; flex-wrap:wrap; gap:4px; padding:4px 0; }
.btn-sm { height:24px; font-size:11px; padding:0 8px; }
.op-btn { border-color:#d1d5db; color:#374151; background:#f8fafc; }
.op-btn:hover { background:#eef2f7; }
.op-btn-modify { background:#eef2ff; border-color:#c7d2fe; color:#3730a3; }
.op-btn-modify:hover { background:#e0e7ff; }
.op-btn-suspend { background:#fff7ed; border-color:#fed7aa; color:#9a3412; }
.op-btn-suspend:hover { background:#ffedd5; }
.op-btn-resume { background:#ecfeff; border-color:#a5f3fc; color:#155e75; }
.op-btn-resume:hover { background:#cffafe; }
.op-btn-delete { background:#fef2f2; border-color:#fecaca; color:#b91c1c; }
.op-btn-delete:hover { background:#fee2e2; }
.op-btn-redeploy { background:#f5f3ff; border-color:#ddd6fe; color:#6d28d9; }
.op-btn-redeploy:hover { background:#ede9fe; }
.param-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.param-row label { width:160px; font-size:11px; text-align:right; flex-shrink:0; }
.param-row label.req { font-weight:600; }
.param-row label.req-nodfl { font-weight:600; color:var(--destructive); }
.param-row input,.param-row select { flex:1; height:28px; font-size:12px; border:1px solid var(--brand-gray); border-radius:4px; padding:0 6px; }
#scenario-modal { display:none; position:fixed; top:0; left:0; right:0; bottom:0; z-index:10000; }
.modal-backdrop { position:absolute; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.5); }
.modal-content { position:relative; max-width:800px; margin:20px auto; background:#fff; border-radius:8px; box-shadow:0 4px 20px rgba(0,0,0,0.3); }
.workbench-layout { display:flex; gap:12px; }
.wb-left { width:260px; flex-shrink:0; }
.wb-right { flex:1; min-width:0; }
#inst-list { max-height:calc(100vh - 300px); overflow-y:auto; }
.token-row { display:flex; gap:4px; padding:8px 12px; }
.token-row input { flex:1; height:26px; font-size:11px; border:1px solid var(--brand-gray); border-radius:3px; padding:0 4px; background:var(--brand-grey-light); }
.token-row button { height:26px; font-size:10px; padding:0 6px; }
</style>
</head>
<body>
<nav class="sidebar">
<div class="sidebar-top">
<img src="{{ url_for('static', filename='logo.svg') }}" alt="Nubes" style="height:20px;" />
</div>
<div class="sidebar-nav">
<button class="sidebar-item active" data-view="workbench" onclick="switchView('workbench')"><span style="display:flex;align-items:center;gap:10px;">▶ Верстак</span></button>
<button class="sidebar-item" data-view="overview" onclick="switchView('overview')">📊 Обзор</button>
<button class="sidebar-item" data-view="history-view" onclick="switchView('history-view')">📋 История</button>
<button class="sidebar-item" data-view="scenarios-view" onclick="switchView('scenarios-view')">🧪 Сценарии</button>
<button class="sidebar-item" data-view="logs-view" onclick="switchView('logs-view')">📜 Логи</button>
</div>
<div class="sidebar-bottom">
<div style="padding:4px 12px;font-size:10px;color:var(--muted);">v{{ config.VERSION }} | {{ stand.upper() }}</div>
{% if token_info.email %}<div style="padding:0 12px 4px;font-size:10px;color:var(--muted);">{{ token_info.email }}</div>{% endif %}
<form method="post" class="token-row">
<input type="password" name="token" placeholder="env: {{ env_token_masked }}" value="{{ '' if not has_user_token else '••••••••' }}" />
<button type="submit" name="action" value="save" class="btn btn-sm">OK</button>
{% if has_user_token %}<button type="submit" name="action" value="clear" class="btn btn-sm" style="color:var(--destructive);"></button>{% endif %}
</form>
{% if error %}<div style="padding:4px 12px;font-size:10px;color:var(--destructive);">{{ error }}</div>{% endif %}
</div>
</nav>
<!-- VIEW: Верстак -->
<div class="view" id="view-workbench">
<div class="view-header">Верстак</div>
<div class="workbench-layout">
<div class="wb-left">
<div class="card">
<div class="card-header" style="font-size:13px;">Сервисы</div>
<div class="card-body" style="padding:4px;">
{% for svc in services %}{% if svc.svcId in config.service_ids %}<div class="svc-item {% if loop.first %}active{% endif %}" onclick="selectService({{ svc.svcId }})">{{ svc.svcId }}. {{ svc.svc }}</div>{% endif %}{% endfor %}
</div>
</div>
</div>
<div class="wb-right">
<div class="card">
<div class="card-header" style="font-size:13px;">Инстансы</div>
<div class="card-body" style="padding:4px;" id="inst-list">
<span style="color:var(--muted);font-size:12px;">Загрузка...</span>
</div>
</div>
<div id="params-area" style="display:none;padding:0 8px 8px;">
<div id="params-form"></div>
<div style="padding:4px 0;">
<button class="btn btn-primary btn-sm" id="btn-test" style="display:none;">Запустить</button>
<span id="test-status" style="font-size:12px;margin-left:8px;"></span>
</div>
</div>
<div id="create-btn-area" style="padding:0 8px 8px;">
<div class="inst-item" style="border-top:1px solid var(--brand-gray);padding-top:8px;margin-top:4px;" onclick="startCreate()">
<span style="flex:1;color:var(--brand-primary);cursor:pointer;font-size:13px;">+ Создать новый инстанс</span>
</div>
</div>
</div>
</div>
</div>
<!-- VIEW: Обзор -->
<div class="view hidden" id="view-overview">
<div class="view-header">Обзор</div>
{% if organization %}
<div class="card">
<div class="card-header">Организация</div>
<div class="card-body" style="padding:8px 12px;font-size:13px;">
{{ organization.displayName }}{% if client_id %} ({{ client_id }}){% endif %}<br>
<span class="badge badge-success" style="font-size:11px;">{{ organization.explainedStatus or "OK" }}</span>
</div>
</div>
{% endif %}
{% for svc_name, items in instance_groups.items() %}
<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'">{{ svc_name }} ({{ items|length }})</div>
<div class="card-body" style="padding:0;max-height:200px;overflow-y:auto;">
<table>
{% for i in items %}
<tr><td style="font-size:12px;padding:3px 10px;">{{ i.displayName }}<br><span style="color:var(--muted);font-size:10px;">{{ i.instanceUid }}</span></td><td><span class="badge badge-success" style="font-size:10px;">{{ i.explainedStatus or '?' }}</span></td></tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}
</div>
<!-- VIEW: История -->
<div class="view hidden" id="view-history-view">
<div class="view-header">История прогонов</div>
<div class="card" id="history-card">
<div class="card-header" style="cursor:pointer;" onclick="toggleHistory()">Последние 50 запусков</div>
<div class="card-body" style="padding:4px;max-height:calc(100vh - 200px);overflow-y:auto;" id="history-body">
<span style="color:var(--muted);font-size:12px;">Загрузка...</span>
</div>
</div>
</div>
<!-- VIEW: Сценарии -->
<div class="view hidden" id="view-scenarios-view">
<div class="view-header">Сценарии (автотесты)</div>
<div class="card" id="scenario-card">
<div class="card-body" style="padding:8px;" id="scenario-body">
<span style="color:var(--muted);font-size:12px;">Загрузка...</span>
</div>
</div>
</div>
<!-- VIEW: Логи -->
<div class="view hidden" id="view-logs-view">
<div class="view-header">Логи</div>
<div id="log-view-content" style="background:#1e1e1e;color:#d4d4d4;font:12px monospace;padding:10px;border-radius:6px;min-height:300px;max-height:calc(100vh - 200px);overflow-y:auto;">Откройте лог-панель кнопкой...</div>
</div>
<script>
window.APP = {
version: "{{ config.VERSION | tojson }}",
stand: "{{ stand | tojson }}",
hasUserToken: {{ has_user_token | tojson }},
firstServiceId: {{ (config.service_ids[0] if config.service_ids else 1) | tojson }}
};
</script>
<script src="{{ url_for('static', filename='js/icons.js') }}"></script>
<script src="{{ url_for('static', filename='js/snackbar.js') }}"></script>
<script src="{{ url_for('static', filename='js/utils.js') }}"></script>
<script src="{{ url_for('static', filename='js/views.js') }}"></script>
<script src="{{ url_for('static', filename='js/params-render.js') }}"></script>
<script src="{{ url_for('static', filename='js/instances.js') }}"></script>
<script src="{{ url_for('static', filename='js/operations.js') }}"></script>
<script src="{{ url_for('static', filename='js/history.js') }}"></script>
<script src="{{ url_for('static', filename='js/scenario-form.js') }}"></script>
<script src="{{ url_for('static', filename='js/scenario-create.js') }}"></script>
<script src="{{ url_for('static', filename='js/scenario-edit.js') }}"></script>
<script src="{{ url_for('static', filename='js/scenario-delete.js') }}"></script>
<script src="{{ url_for('static', filename='js/scenario-list.js') }}"></script>
<script src="{{ url_for('static', filename='app.js') }}"></script>
<div id="log-panel" style="display:none;position:fixed;bottom:0;left:72px;right:0;height:180px;background:#1e1e1e;color:#d4d4d4;font:12px monospace;overflow-y:auto;padding:8px 12px;border-top:2px solid #555;z-index:9999;"></div>
<button onclick="toggleLog()" title="Логи" style="position:fixed;bottom:4px;right:8px;z-index:10000;background:#1e1e1e;color:#888;border:1px solid #555;border-radius:3px;font:11px monospace;padding:3px 8px;cursor:pointer;">log</button>
</body>
</html>