From be9e165b4f761e668186c137599edc429be6dcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 28 Jul 2026 10:15:31 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.96:=20history=20UI=20=E2=80=94=20collapsib?= =?UTF-8?q?le=20table=20below=20instances,=20auto-refresh=20on=20finish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 2 +- site/static/app.js | 34 ++++++++++++++++++++++++++++++++++ site/templates/index.html | 6 ++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/site/app.py b/site/app.py index 6faff28..c0b300d 100644 --- a/site/app.py +++ b/site/app.py @@ -18,7 +18,7 @@ from routes.api import bp as api_bp from routes.api_test import bp as api_test_bp # Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI. -VERSION = "1.0.95" +VERSION = "1.0.96" app = Flask(__name__, template_folder="templates", static_folder="static") app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc") diff --git a/site/static/app.js b/site/static/app.js index ca329e7..e91f8dc 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -267,6 +267,7 @@ async function executeOp(params){ if(sd.status==='OK'){ await refreshInstances(); } + if(historyOpen) await loadHistory(); } },2000); }catch(e){ @@ -311,6 +312,39 @@ async function refreshInstances(){ document.getElementById('inst-list').innerHTML=html; } +// === История тестов === +let historyOpen=false; +async function toggleHistory(){ + const body=document.getElementById('history-body'); + historyOpen=!historyOpen; + body.style.display=historyOpen?'block':'none'; + if(historyOpen) await loadHistory(); +} +async function loadHistory(){ + const body=document.getElementById('history-body'); + if(!body||body.style.display==='none') return; + try{ + const r=await fetch('/api/history'); + const rows=await r.json(); + if(!rows||!rows.length){body.innerHTML='Нет записей'; return;} + let html=''; + html+=''; + rows.forEach(r=>{ + const time=r.created_at?r.created_at.replace('T',' ').substring(0,19):'?'; + const cls=r.status==='OK'?'badge-success':''; + html+=` + + + + + + `; + }); + html+='
ВремяОперацияИнстансСтатусДлит.
${time}${r.op_name||'?'}${r.display_name||r.instance_uid||'?'}${r.status||'?'}${r.duration_sec!=null?r.duration_sec.toFixed(1)+'s':'-'}
'; + body.innerHTML=html; + }catch(e){body.innerHTML='Ошибка загрузки';} +} + // === Панель логов (скрыта, показывается по кнопке) === let logPollTimer=null; function startLogPoll(){ diff --git a/site/templates/index.html b/site/templates/index.html index 87fac99..8055008 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -120,6 +120,12 @@ +
+
История (последние 50)
+ +