feat: the workspace at /workspace; Настройки show the assistant's model as set, key included, and PostgreSQL's fields only when chosen, its two buttons on one line; pages come in softly
This commit is contained in:
1 parent
352b016384
commit
6db78399ac
10 files changed
+48
-24
No files matched your search
@@ -225,7 +225,7 @@
|
||||
if (act && act.term && !act.ssh && act.agent.id === m.id) return act;
|
||||
let t = ws.panes().find(p => p.term && !p.ssh && p.agent.id === m.id);
|
||||
if (!t) {
|
||||
if (document.querySelector('main#app').dataset.view !== 'terminal') App.go('/terminal');
|
||||
if (document.querySelector('main#app').dataset.view !== 'terminal') App.go('/workspace');
|
||||
ws.open('term', {id: m.id, name: m.name, host: m.hostname, user: m.user});
|
||||
t = ws.panes().find(p => p.term && !p.ssh && p.agent.id === m.id);
|
||||
for (let i = 0; i < 40 && t && t.state !== 'ok'; i++) await sleep(250);
|
||||
|
||||
@@ -904,3 +904,17 @@ body.ai-dragging .ai-fab, body.ai-dragging .ai-box { transition:none; }
|
||||
.ai-form-in textarea { min-height:40px; }
|
||||
.ai-send { min-height:40px; max-height:40px; min-width:40px; max-width:40px; line-height:1; border-radius:10px; }
|
||||
.ai-form-in textarea { border-radius:10px; }
|
||||
/* Настройки: the key with its eye; PostgreSQL's fields only when chosen. */
|
||||
.ai-form .keybox { display:flex; gap:6px; align-items:center; }
|
||||
.ai-form .keybox input { flex:1; }
|
||||
.ai-form .keybox .btn.sq { width:38px; height:38px; flex:none; }
|
||||
.db-form:not(.pg) .pg-fields { display:none; }
|
||||
.db-form .pg-fields { display:grid; gap:10px; }
|
||||
.db-form .frow2 { display:flex; gap:10px; }
|
||||
.db-form .frow2 label:first-child { flex:1; }
|
||||
.db-form .frow2 .port { width:120px; }
|
||||
.db-actions { margin-top:12px; }
|
||||
.db-actions form { margin:0; }
|
||||
/* Moving between Машины, WorkSpace and Настройки: the page comes in softly. */
|
||||
main#app > .view:not([hidden]) { animation:view-in .22s ease both; }
|
||||
@keyframes view-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
|
||||
@@ -7,7 +7,7 @@
|
||||
// unmounted - its timers, requests and listeners dropped - when it goes.
|
||||
(function () {
|
||||
'use strict';
|
||||
const views = {'/': 'machines', '/terminal': 'terminal', '/settings': 'settings'};
|
||||
const views = {'/': 'machines', '/workspace': 'terminal', '/terminal': 'terminal', '/settings': 'settings'};
|
||||
const modules = {};
|
||||
const mounted = new Map(); // area -> {mod, scope}
|
||||
const $ = s => document.querySelector(s);
|
||||
@@ -120,6 +120,8 @@
|
||||
|
||||
// start mounts what the server drew, once every script has registered.
|
||||
function start() {
|
||||
// The old address of the workspace shows as the new one.
|
||||
if (location.pathname === '/terminal') { history.replaceState({}, '', '/workspace' + location.search); shown = '/workspace' + location.search; }
|
||||
document.querySelectorAll('main#app > .view').forEach(mount);
|
||||
show({dashboard: 'machines', settings: 'settings'}[$('main#app').dataset.view] || 'terminal');
|
||||
// /agents/{id}/terminal or /files: that pane, at once.
|
||||
|
||||
@@ -754,7 +754,7 @@
|
||||
// open opens a pane of kind on agent in a new tab and shows the view.
|
||||
function open(kind, agent, opts) {
|
||||
const t = openPane(kind, agent, opts);
|
||||
if (location.pathname !== '/terminal' && window.App) App.go('/terminal');
|
||||
if (location.pathname !== '/workspace' && window.App) App.go('/workspace');
|
||||
return t;
|
||||
}
|
||||
const in_ = (el, x, y) => { const r = el.getBoundingClientRect(); return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom; };
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="brand"><a class="home" href="/" title="К списку машин">LPRA</a> · <span id="brandtitle">Удалённый доступ</span></div>
|
||||
<nav>
|
||||
<a href="/" data-nav="machines">Машины</a>
|
||||
<a href="/terminal" data-nav="terminal">WorkSpace</a>
|
||||
<a href="/workspace" data-nav="terminal">WorkSpace</a>
|
||||
{{if .IsAdmin}}<a href="/settings" data-nav="settings">Настройки</a>{{end}}
|
||||
<span id="status" class="muted"></span>
|
||||
<button type="button" class="btn ghost icon acct-btn" id="acct" title="Аккаунт" aria-label="Аккаунт"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg></button>
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<p class="muted">Сейчас: <b>{{if eq .DBNow "postgres"}}PostgreSQL{{else}}SQLite{{end}}</b>.
|
||||
{{if ne .DBNow .DBChosen.Type}}<span class="err" style="display:inline">Выбрана {{if eq .DBChosen.Type "postgres"}}PostgreSQL{{else}}SQLite{{end}} - перезапустите сервер, чтобы перейти.</span>{{end}}
|
||||
При первом запуске на пустой PostgreSQL всё копируется из SQLite-файла (он остаётся как есть).</p>
|
||||
<form method="post" action="/settings/db" class="ai-form db-form{{if eq .DBChosen.Type "postgres"}} pg{{end}}">
|
||||
<form method="post" action="/settings/db" id="dbform" class="ai-form db-form{{if eq .DBChosen.Type "postgres"}} pg{{end}}">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<label>Хранить в<select name="db_type" onchange="this.form.classList.toggle('pg', this.value === 'postgres')">
|
||||
<option value="sqlite"{{if ne .DBChosen.Type "postgres"}} selected{{end}}>SQLite (файл рядом с сервером)</option>
|
||||
@@ -141,19 +141,20 @@
|
||||
<option value="verify-full"{{if eq $m "verify-full"}} selected{{end}}>verify-full</option>
|
||||
</select></label>
|
||||
</div>
|
||||
<button type="submit">Проверить и сохранить</button>
|
||||
</form>
|
||||
<form method="post" action="/settings/db/restart" data-confirm="Перезапустить сервер? Терминалы и передачи прервутся, страница переподключится сама." data-danger style="margin-top:10px">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<button type="submit" class="btn ghost">Перезапустить сервер</button>
|
||||
</form>
|
||||
<div class="row db-actions">
|
||||
<button type="submit" form="dbform">Проверить и сохранить</button>
|
||||
<form method="post" action="/settings/db/restart" data-confirm="Перезапустить сервер? Терминалы и передачи прервутся, страница переподключится сама." data-danger>
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<button type="submit" class="btn ghost">Перезапустить сервер</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="ai">
|
||||
<h2>ИИ-ассистент</h2>
|
||||
<p class="muted">Чат в правом нижнем углу панели: видит вкладки и активный терминал, предлагает команды, которые
|
||||
пользователь выполняет одним нажатием. Каждый включает его себе сам в профиле. Ключ хранится на сервере
|
||||
и в браузер не уходит.</p>
|
||||
пользователь выполняет одним нажатием. Каждый включает его себе сам в профиле. Ключ хранится на сервере: его видят только администраторы здесь, в чат он не попадает.</p>
|
||||
<form method="post" action="/settings/ai" class="ai-form">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<label>Тип API<select name="ai_type">
|
||||
@@ -163,9 +164,9 @@
|
||||
</select></label>
|
||||
<label>Адрес<input type="url" name="ai_url" value="{{.AI.URL}}" placeholder="https://api.openai.com/v1"></label>
|
||||
<label>Модель<input type="text" name="ai_model" value="{{.AI.Model}}" placeholder="для OpenAI и Anthropic"></label>
|
||||
<label>Ключ<input type="password" name="ai_key" placeholder="{{if .AI.Key}}задан - пусто, чтобы оставить{{else}}не задан{{end}}" autocomplete="off"></label>
|
||||
{{if .AI.Key}}<label class="row" style="gap:8px"><input type="checkbox" name="ai_key_clear" value="1" style="width:auto"> убрать ключ</label>{{end}}
|
||||
<button type="submit">Сохранить</button>
|
||||
<label>Ключ<span class="keybox"><input type="password" name="ai_key" value="{{.AI.Key}}" placeholder="не задан" autocomplete="off" spellcheck="false">
|
||||
<button type="button" class="btn ghost small icon sq" title="Показать" aria-label="Показать ключ" onclick="var i=this.previousElementSibling;i.type=i.type==='password'?'text':'password'"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg></button></span></label>
|
||||
<div><button type="submit">Сохранить</button></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user