From 8158dd265c3b4cf94cd2d7a670325c93ca20fdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Mon, 11 May 2026 23:31:51 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20runtime=20logs=20=D0=B8=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20Androi?= =?UTF-8?q?d=20=D1=83=D1=81=D1=82=D1=80=D0=BE=D0=B9=D1=81=D1=82=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/workspace.js | 63 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/frontend/workspace.js b/frontend/workspace.js index 6f2b82c..5f46c74 100644 --- a/frontend/workspace.js +++ b/frontend/workspace.js @@ -1,4 +1,19 @@ +function appendLog(message) { + const logs = document.getElementById('logs'); + + if (!logs) { + return; + } + + const time = new Date().toLocaleTimeString(); + + logs.innerText += `\n[${time}] ${message}`; + logs.scrollTop = logs.scrollHeight; +} + async function workspaceApi(url, payload = {}) { + appendLog(`API запрос: ${url}`); + const response = await fetch(url, { method: 'POST', headers: { @@ -13,6 +28,8 @@ async function workspaceApi(url, payload = {}) { async function loadWorkspaceTree() { const workspace = document.getElementById('workspacePath').value; + appendLog(`Загрузка workspace: ${workspace}`); + const data = await workspaceApi('/api/files/tree', { path: workspace }); @@ -47,6 +64,8 @@ function renderTree(tree, level = 0) { } async function openFile(path) { + appendLog(`Открытие файла: ${path}`); + const data = await workspaceApi('/api/files/read', { path }); @@ -59,12 +78,50 @@ async function saveCurrentFile() { const path = document.getElementById('editorPath').innerText; const content = document.getElementById('editor').value; + appendLog(`Сохранение файла: ${path}`); + const data = await workspaceApi('/api/files/save', { path, content }); - document.getElementById('editorStatus').innerText = data.success - ? 'Файл сохранен' - : 'Ошибка сохранения'; + appendLog(data.success ? 'Файл успешно сохранен' : 'Ошибка сохранения файла'); } + +async function loadDevices() { + appendLog('Обновление списка Android устройств'); + + const data = await workspaceApi('/api/android/devices'); + + const container = document.getElementById('devices'); + + if (!container) { + return; + } + + const lines = (data.stdout || '').split('\n'); + + const devices = lines.filter(line => + line.includes('device') && !line.includes('List') + ); + + if (devices.length === 0) { + container.innerHTML = 'Устройства не подключены'; + return; + } + + container.innerHTML = devices.map(device => { + const id = device.split(/\s+/)[0]; + + return ` +