Files
DevConsole/frontend/runtime.html
T

34 строки
12 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DevConsole Runtime</title>
<style>
*{box-sizing:border-box}body{margin:0;background:#0f1115;color:#fff;font-family:Arial,sans-serif;overflow:hidden}.layout{display:flex;height:100vh;max-height:100vh}.sidebar{width:380px;background:#171a21;padding:20px;border-right:1px solid #2a2f3a;overflow:auto;display:flex;flex-direction:column;gap:16px}.workspace{flex:1;min-width:0;display:flex;flex-direction:column;height:100vh}.topbar{height:54px;flex:0 0 54px;padding:8px 10px;background:#171a21;border-bottom:1px solid #2a2f3a;display:flex;gap:10px}.workspace-body{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 360px;overflow:hidden}.runtime-panel,.errors-panel{min-height:0;display:flex;flex-direction:column;background:#0f1115}.errors-panel{border-left:1px solid #2a2f3a;background:#111318}.runtime-header,.errors-header{flex:0 0 auto;padding:14px 16px;background:#171a21;border-bottom:1px solid #2a2f3a;display:flex;justify-content:space-between;align-items:center;gap:12px}.logs-wrap{flex:1;min-height:0;display:flex;flex-direction:column}.logs,.errors-box{flex:1;min-height:0;background:#0b0d11;border-top:1px solid #2a2f3a;padding:14px;overflow-y:auto;font-family:monospace;font-size:12px;line-height:1.35;white-space:pre-wrap}.errors-box{background:#160d0d;color:#ffd4d4}.errors-actions{flex:0 0 auto;padding:10px;background:#171a21;border-top:1px solid #2a2f3a;display:flex;gap:8px;flex-wrap:wrap}.systems-panel{flex:0 0 92px;background:#111827;border-top:1px solid #2a2f3a;padding:8px 10px;overflow-x:auto;display:flex;gap:8px;align-items:stretch}.system-card{min-width:132px;background:#13161c;border:1px solid #2a2f3a;border-radius:10px;padding:8px;display:flex;flex-direction:column;gap:6px}.system-top,.project-top{display:flex;align-items:center;justify-content:space-between;gap:6px}.system-title{font-size:12px;font-weight:700}.system-dot{width:9px;height:9px;border-radius:999px;background:#6b7280}.system-dot.ok{background:#22c55e}.system-dot.bad{background:#ef4444}.system-dot.warn{background:#f59e0b}.system-sub{font-size:10px;color:#9ca3af;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.system-actions{display:flex;gap:6px}.system-actions button{padding:4px 7px;font-size:10px;border-radius:7px}button{background:#2563eb;color:#fff;border:none;padding:10px 14px;border-radius:8px;cursor:pointer}button:hover{background:#3b82f6}.danger{background:#991b1b}.danger:hover{background:#b91c1c}.muted{background:#374151}.muted:hover{background:#4b5563}.icon-btn{width:30px;height:30px;padding:0;border-radius:8px;background:#374151}.add-project-btn{width:32px;height:32px;padding:0;border-radius:10px;font-size:22px;line-height:1;background:#2563eb}.section-title{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}.section-title h3{margin:0}input,textarea{background:#0f1115;border:1px solid #2a2f3a;color:#fff;padding:10px;border-radius:8px;flex:1;width:100%}textarea{min-height:82px;resize:vertical;font-family:Arial,sans-serif}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.section{background:#13161c;border:1px solid #2a2f3a;border-radius:12px;padding:14px}.projects-list{max-height:420px;overflow:auto}.runtime-grid{display:flex;gap:10px;flex-wrap:wrap}.status-line{display:flex;align-items:center;gap:8px;font-size:13px;color:#d1d5db}.status-dot{width:10px;height:10px;border-radius:999px;background:#6b7280}.status-dot.running{background:#f59e0b;animation:pulse 1s infinite}.status-dot.done{background:#22c55e}.status-dot.error{background:#ef4444}.progress-wrap{display:none;margin-top:12px;background:#0f1115;border:1px solid #2a2f3a;border-radius:10px;overflow:hidden}.progress-bar{height:10px;width:0;background:#2563eb;transition:width .25s ease}.progress-label{font-size:12px;color:#d1d5db;margin-top:8px;line-height:1.4}.note{font-size:13px;color:#9ca3af;line-height:1.45}.project-card,.device-card{padding:10px;margin-bottom:10px;background:#1d2430;border:1px solid transparent;border-radius:10px;cursor:pointer}.project-card:hover,.device-card:hover{border-color:#3b82f6}.device-card.selected{background:#10233f;border-color:#60a5fa;box-shadow:0 0 0 1px rgba(96,165,250,.25)}.ota-badge{font-size:10px;color:#86efac;border:1px solid #166534;border-radius:999px;padding:2px 6px}.error-count{font-size:12px;color:#fecaca}.modal-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.65);align-items:center;justify-content:center;z-index:50}.modal{width:520px;max-width:calc(100vw - 32px);max-height:calc(100vh - 32px);overflow:auto;background:#171a21;border:1px solid #2a2f3a;border-radius:16px;padding:18px;box-shadow:0 20px 80px rgba(0,0,0,.45)}.modal.wide{width:760px}.modal h3{margin-top:0}.modal-row{display:flex;gap:10px;margin-top:10px}.auth-extra,.ota-extra{display:none;margin-top:10px}.checkline{display:flex;gap:8px;align-items:center;margin-top:10px;color:#d1d5db}.checkline input{width:auto;flex:0}@keyframes pulse{0%{opacity:.35}50%{opacity:1}100%{opacity:.35}}
</style>
</head>
<body>
<div class="layout">
<aside class="sidebar">
<div><h2>DevConsole</h2><p>GitHub-driven Runtime</p></div>
<div class="section"><div class="section-title"><h3>Проекты</h3><button class="add-project-btn" onclick="openAddProjectModal()" title="Добавить проект">+</button></div><div id="projectsList" class="projects-list">Загрузка проектов...</div></div>
<div class="section"><h3>Android устройства</h3><div id="devices">Поиск устройств...</div></div>
</aside>
<div class="workspace"><div class="topbar"><input type="text" id="workspacePath" placeholder="Workspace из GitHub import" readonly><input type="text" id="packageName" placeholder="Package name"><button onclick="installLatestApk()">Install APK</button><button onclick="restartCurrentApp()">Restart App</button><button class="danger" onclick="stopRuntimeCommand()">Stop</button></div><div class="workspace-body"><div class="runtime-panel"><div class="runtime-header"><div><strong>Runtime сценарии</strong><div class="note">Изменения делаем через GitHub commit/pull. Flutter output идёт live.</div><div class="status-line"><span id="runtimeStatusDot" class="status-dot"></span><span id="runtimeStatus">Ожидание</span></div><div class="progress-wrap" id="taskProgressWrap"><div class="progress-bar" id="taskProgressBar"></div></div><div class="progress-label" id="taskProgressLabel"></div></div><div class="runtime-grid" id="runtimeButtons"></div></div><div class="logs-wrap"><div class="logs" id="logs">DevConsole runtime initialized...</div><div class="systems-panel" id="systemsPanel"><div class="system-card"><div class="system-top"><span class="system-title">Системы</span><span class="system-dot warn"></span></div><div class="system-sub">Загрузка статусов...</div></div></div></div></div><div class="errors-panel"><div class="errors-header"><div><strong>Ошибки для передачи AI</strong><div id="errorCount" class="error-count">Ошибок пока нет</div></div></div><div class="errors-box" id="errorsBox">Здесь появятся ошибки из Flutter, Gradle, ADB, API и stderr.</div><div class="errors-actions"><button class="muted" onclick="copyErrorsForAI()">Скопировать</button><button class="danger" onclick="clearErrors()">Очистить</button></div></div></div></div>
</div>
<div class="modal-backdrop" id="addProjectModal"><div class="modal"><h3>Добавить проект</h3><input type="text" id="repoUrl" placeholder="Ссылка на GIT"><label class="checkline"><input type="checkbox" id="repoNeedsAuth" onchange="toggleAuthFields()"> Требуется аутентификация</label><div class="auth-extra" id="authFields"><input type="text" id="githubUsername" placeholder="Логин"><div style="height:10px"></div><input type="password" id="githubToken" placeholder="Ключ"></div><div class="progress-wrap" id="analysisProgressWrap"><div class="progress-bar" id="analysisProgressBar"></div></div><div class="progress-label" id="analysisProgressLabel"></div><div class="modal-row"><button onclick="analyzeProject()">Добавить</button><button class="muted" onclick="closeAddProjectModal()">Закрыть</button></div></div></div>
<div class="modal-backdrop" id="editProjectModal"><div class="modal wide"><h3 id="editProjectTitle">Настройки проекта</h3><input type="hidden" id="editWorkspace"><label class="checkline"><input type="checkbox" id="otaEnabled" onchange="toggleOtaFields()"> Включить OTA/SFTP публикацию после Flutter build/run</label><div class="ota-extra" id="otaFields"><div class="form-grid"><input id="otaHost" placeholder="SFTP host"><input id="otaPort" placeholder="SFTP port, например 22"><input id="otaUsername" placeholder="SFTP login"><input id="otaPassword" type="password" placeholder="SFTP password / оставить пустым чтобы не менять"><input id="otaRemotePath" placeholder="Remote path, например /www/pulse/apk"><input id="otaPublicBaseUrl" placeholder="Public base URL, например https://pulse.stackworks.ru/apk/"><input id="otaLatestJsonName" placeholder="latest.json"><input id="otaLatestApkName" placeholder="pulse-latest.apk"><input id="otaVersion" placeholder="version, например 0.8.1"><input id="otaBuild" placeholder="build, например 35"></div><div style="height:10px"></div><textarea id="otaNotes" placeholder="Заметки обновления, каждая строка отдельным пунктом"></textarea><div class="note" style="margin-top:8px">versioned_apk_url будет собран автоматически как pulse-version+build.apk.</div></div><div class="modal-row"><button onclick="saveProjectSettings()">Сохранить</button><button class="muted" onclick="closeEditProjectModal()">Закрыть</button></div></div></div>
<script src="/workspace.js"></script>
<script>
async function api(url,payload={},method='POST'){const r=await fetch(url,{method,headers:{'Content-Type':'application/json'},body:method==='GET'?undefined:JSON.stringify(payload)});return await r.json();}
function openAddProjectModal(){document.getElementById('addProjectModal').style.display='flex';}
function closeAddProjectModal(){document.getElementById('addProjectModal').style.display='none';}
function toggleAuthFields(){document.getElementById('authFields').style.display=document.getElementById('repoNeedsAuth').checked?'block':'none';}
function toggleOtaFields(){document.getElementById('otaFields').style.display=document.getElementById('otaEnabled').checked?'block':'none';}
function setAnalysisProgress(percent,message){const wrap=document.getElementById('analysisProgressWrap');const bar=document.getElementById('analysisProgressBar');const label=document.getElementById('analysisProgressLabel');if(wrap){wrap.style.display='block';}if(bar){bar.style.width=percent+'%';}if(label){label.innerText=percent+'% — '+message;}appendLog(percent+'% — '+message);}
async function analyzeProject(){const repo_url=document.getElementById('repoUrl').value.trim();if(!repo_url){appendLog('0% — Укажи Git URL');return;}if(document.getElementById('repoNeedsAuth').checked){await saveGitHubSettings();}setAnalysisProgress(5,'Проверяю Git URL');setAnalysisProgress(20,'Готовлю workspace');setAnalysisProgress(35,'Клонирую или обновляю репозиторий');const data=await api('/api/projects/analyze',{repo_url});if(data.detail){setAnalysisProgress(100,'Ошибка анализа: '+data.detail);return;}setAnalysisProgress(65,'Репозиторий получен, сканирую структуру');if(data.analysis?.detected_stack?.length){setAnalysisProgress(76,'Стек: '+data.analysis.detected_stack.join(', '));}else{setAnalysisProgress(76,'Стек не определён автоматически');}if(data.analysis?.workspace){setAnalysisProgress(88,'Workspace: '+data.analysis.workspace);document.getElementById('workspacePath').value=data.analysis.workspace;setAnalysisProgress(94,'Регистрирую проект');await registerCurrentProject(repo_url,data.analysis.workspace,data.analysis.detected_stack?.join(', ')||'unknown');}setAnalysisProgress(100,'Проект добавлен');closeAddProjectModal();}
async function buildApk(){await runRuntimeScenario('build');}
</script>
</body>
</html>