Добавлен полноценный Pulse development workflow UI

Этот коммит содержится в:
Виктор
2026-05-11 23:14:36 +09:00
родитель f4c61cf8a5
Коммит b7114ed79a
+146 -68
Просмотреть файл
@@ -11,123 +11,201 @@
<aside class="sidebar">
<div class="logo">
<h1>DevConsole</h1>
<span>AI Development Runtime</span>
<span>Pulse Development Environment</span>
</div>
<nav>
<a href="#dashboard">Dashboard</a>
<a href="#prompts">Prompt Lab</a>
<a href="#settings">AI Settings</a>
<a href="#tests">Connection Tests</a>
<a href="#workspace">Workspace</a>
<a href="#android">Android Devices</a>
<a href="#build">Build & Install</a>
<a href="#prompts">AI Assistant</a>
<a href="#settings">Settings</a>
</nav>
</aside>
<main class="content">
<section class="card" id="dashboard">
<h2>System Status</h2>
<div id="systemStatus">Loading...</div>
<section class="card" id="workspace">
<h2>Pulse Workspace</h2>
<input type="text" id="repoUrl" placeholder="https://github.com/viktor138irk/Pulse">
<div class="button-row">
<button onclick="analyzeProject()">Analyze Project</button>
<button onclick="installDependencies()">Install Dependencies</button>
</div>
<pre id="projectResult"></pre>
</section>
<section class="card" id="android">
<h2>Android Device Manager</h2>
<div class="button-row">
<button onclick="loadDevices()">Refresh Devices</button>
</div>
<div id="devices"></div>
</section>
<section class="card" id="build">
<h2>APK Build & Install</h2>
<input type="text" id="workspacePath" placeholder="/var/lib/devconsole/projects/viktor138irk-Pulse">
<div class="button-row">
<button onclick="buildApk()">Build APK</button>
<button onclick="installApk()">Install APK</button>
</div>
<pre id="buildResult"></pre>
</section>
<section class="card" id="prompts">
<h2>Prompt Sandbox</h2>
<textarea id="promptInput" placeholder="Напиши промт для теста AI..."></textarea>
<button onclick="runPrompt()">Run Prompt</button>
<h2>AI Assistant</h2>
<textarea id="promptInput" placeholder="Explain Flutter error or generate code..."></textarea>
<button onclick="runPrompt()">Run AI Task</button>
<pre id="promptResult"></pre>
</section>
<section class="card" id="settings">
<h2>OpenAI Settings</h2>
<input type="password" id="apiKey" placeholder="OpenAI API Key">
<input type="text" id="model" value="gpt-5" placeholder="Model">
<button onclick="saveSettings()">Save Settings</button>
<div id="settingsResult"></div>
</section>
<section class="card" id="tests">
<h2>Connection Tests</h2>
<button onclick="testConnection()">Test OpenAI Connection</button>
<pre id="testResult"></pre>
<button onclick="saveSettings()">Save Settings</button>
<div id="settingsResult"></div>
</section>
</main>
</div>
<script>
async function loadStatus() {
const response = await fetch('/api/system/status');
const data = await response.json();
let selectedDevice = '';
document.getElementById('systemStatus').innerHTML = `
<div class="status-grid">
<div class="status-item">
<span>Project</span>
<strong>${data.project}</strong>
</div>
<div class="status-item">
<span>Version</span>
<strong>${data.version}</strong>
</div>
<div class="status-item">
<span>OpenAI</span>
<strong>${data.openai_configured ? 'Configured' : 'Not configured'}</strong>
</div>
<div class="status-item">
<span>Model</span>
<strong>${data.openai_model}</strong>
</div>
async function api(url, options = {}) {
const response = await fetch(url, options);
return await response.json();
}
async function analyzeProject() {
const repo_url = document.getElementById('repoUrl').value;
document.getElementById('projectResult').innerText = 'Analyzing repository...';
const data = await api('/api/projects/analyze', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ repo_url })
});
if (data.analysis?.workspace) {
document.getElementById('workspacePath').value = data.analysis.workspace;
}
document.getElementById('projectResult').innerText = JSON.stringify(data, null, 2);
}
async function installDependencies() {
const repo_url = document.getElementById('repoUrl').value;
document.getElementById('projectResult').innerText = 'Installing dependencies...';
const data = await api('/api/projects/install-dependencies', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ repo_url })
});
document.getElementById('projectResult').innerText = JSON.stringify(data, null, 2);
}
async function loadDevices() {
const data = await api('/api/android/devices', {
method: 'POST'
});
const lines = (data.stdout || '').split('\n');
const devices = lines.filter(line => line.includes('device') && !line.includes('List'));
const html = devices.map(device => {
const id = device.split(/\s+/)[0];
return `
<div class="status-item ${selectedDevice === id ? 'active-device' : ''}">
<strong>${id}</strong>
<button onclick="selectDevice('${id}')">Select</button>
</div>
`;
}).join('');
document.getElementById('devices').innerHTML = html || '<p>No devices connected</p>';
}
function selectDevice(id) {
selectedDevice = id;
loadDevices();
}
async function buildApk() {
const workspace = document.getElementById('workspacePath').value;
document.getElementById('buildResult').innerText = 'Building APK...';
const data = await api('/api/android/build', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ workspace })
});
document.getElementById('buildResult').innerText = JSON.stringify(data, null, 2);
}
async function installApk() {
const workspace = document.getElementById('workspacePath').value;
document.getElementById('buildResult').innerText = 'Installing APK...';
const data = await api('/api/android/install-latest', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ workspace, device: selectedDevice })
});
document.getElementById('buildResult').innerText = JSON.stringify(data, null, 2);
}
async function saveSettings() {
const api_key = document.getElementById('apiKey').value;
const model = document.getElementById('model').value;
const response = await fetch('/api/settings/openai', {
const data = await api('/api/settings/openai', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ api_key, model })
});
const data = await response.json();
document.getElementById('settingsResult').innerText = data.message || data.detail;
loadStatus();
}
async function runPrompt() {
const prompt = document.getElementById('promptInput').value;
document.getElementById('promptResult').innerText = 'Running...';
document.getElementById('promptResult').innerText = 'Running AI task...';
const response = await fetch('/api/prompts/test', {
const data = await api('/api/prompts/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ prompt, task_type: 'coding' })
});
const data = await response.json();
document.getElementById('promptResult').innerText = data.answer || data.detail;
}
async function testConnection() {
document.getElementById('testResult').innerText = 'Testing...';
const response = await fetch('/api/settings/openai/test', {
method: 'POST'
});
const data = await response.json();
document.getElementById('testResult').innerText = data.answer || data.detail;
}
loadStatus();
loadDevices();
</script>
</body>
</html>