feat: logs modal + ESC close + /functions/:name/logs endpoint (v1.3.61)

This commit is contained in:
“Naeel”
2026-05-07 20:51:02 +04:00
parent a9bd2e93c7
commit 9b0089e15a
8 changed files with 136 additions and 5 deletions
+14 -2
View File
@@ -102,7 +102,7 @@
<div class="nubes">NUBES</div>
<div class="product">FISSION CONSOLE</div>
</div>
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.60</div>
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.61</div>
</div>
<div class="row" style="margin:0;">
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
@@ -384,6 +384,18 @@
</div>
</div>
<div id="logs-modal" class="modal">
<div class="panel" style="width:700px; max-width:95vw;">
<h3 id="logs-title">Логи функции</h3>
<textarea id="logs-output" readonly
style="width:100%; height:340px; font-family:monospace; font-size:12px; background:var(--bg-alt); color:var(--text-primary); border:1px solid var(--border); border-radius:6px; padding:10px; resize:vertical; white-space:pre;"></textarea>
<div class="actions">
<button class="btn ghost" onclick="closeLogs()">Закрыть</button>
<button class="btn ghost" onclick="refreshLogs()">Обновить</button>
</div>
</div>
</div>
<div id="help-modal" class="modal">
<div class="panel">
<h3>Help</h3>
@@ -462,7 +474,7 @@
</div>
<div class="actions" style="justify-content:space-between; align-items:center;">
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.60</span>
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.61</span>
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
</div>
</div>
+1
View File
@@ -51,6 +51,7 @@ async function reloadAll() {
var actions = tfBadge +
'<button class="btn ghost" onclick="openEdit(\'' + h(name) + '\')">Ред.</button> ' +
'<button class="btn ghost" onclick="openInvoke(\'' + h(name) + '\')">Вызов</button> ' +
'<button class="btn ghost" onclick="openLogs(\'' + h(name) + '\')">Логи</button> ' +
'<button class="btn danger" onclick="removeFn(\'' + h(name) + '\')">Удалить</button>';
return '<tr>' +
'<td class="mono">' + h(name) + '</td>' +
+44 -1
View File
@@ -46,7 +46,20 @@ function makeDraggable(modalId) {
// Инициализация после загрузки DOM
document.addEventListener('DOMContentLoaded', function() {
['create-code-modal', 'create-archive-modal', 'edit-modal', 'help-modal', 'invoke-modal'].forEach(makeDraggable);
['create-code-modal', 'create-archive-modal', 'edit-modal', 'help-modal', 'invoke-modal', 'logs-modal'].forEach(makeDraggable);
// ESC закрывает активное модальное окно
document.addEventListener('keydown', function(e) {
if (e.key !== 'Escape') return;
var modals = ['create-code-modal', 'create-archive-modal', 'edit-modal', 'help-modal', 'invoke-modal', 'logs-modal'];
for (var i = 0; i < modals.length; i++) {
var el = document.getElementById(modals[i]);
if (el && el.classList.contains('open')) {
el.classList.remove('open');
break;
}
}
});
});
// showModalError — показывает ошибку внутри модалки.
@@ -136,3 +149,33 @@ async function submitInvoke() {
btn.disabled = false;
}
}
// openLogs — открывает модалку с логами функции.
async function openLogs(name) {
S.currentLogs = name;
document.getElementById('logs-title').textContent = 'Логи: ' + name;
document.getElementById('logs-output').value = 'Загрузка...';
document.getElementById('logs-modal').classList.add('open');
await _fetchLogs(name);
}
function closeLogs() {
document.getElementById('logs-modal').classList.remove('open');
S.currentLogs = null;
}
async function refreshLogs() {
if (S.currentLogs) await _fetchLogs(S.currentLogs);
}
async function _fetchLogs(name) {
var out = document.getElementById('logs-output');
try {
var data = await getJSON(API_BASE + '/functions/' + encodeURIComponent(name) + '/logs');
out.value = data.logs || '(нет логов)';
// прокручиваем вниз
out.scrollTop = out.scrollHeight;
} catch (e) {
out.value = 'Ошибка загрузки логов: ' + e.message;
}
}