feat: open provider and sandbox forms in dialogs

This commit is contained in:
vhaudiquet committed 2026-11-28 01:36:29 +01:00
1 parent bd3aed67b4
commit 5237a477d7
1 file changed
+58 -15
+58 -15
View File
@@ -13,8 +13,9 @@ import type {
TestSandboxResponse,
} from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import BaseDialog from '~/components/BaseDialog.vue'
useHead({ title: 'Settings · rhema together' })
useHead({ title: 'Settings · Rhema Together' })
const api = useApi()
@@ -47,6 +48,8 @@ const deletingTarget = ref<string | null>(null)
const deleteBusy = ref(false)
const rowError = ref('')
const providerDialog = ref(false)
const sandboxDialog = ref(false)
const testingTarget = ref<string | null>(null)
const testResults = ref<Record<string, TestSandboxResponse>>({})
const copiedKey = ref<string | null>(null)
@@ -71,6 +74,28 @@ async function loadLists() {
onMounted(loadLists)
function openProviderDialog() {
providerError.value = ''
providerDialog.value = true
}
function closeProviderDialog() {
providerDialog.value = false
providerKey.value = ''
providerError.value = ''
}
function openSandboxDialog() {
sandboxError.value = ''
sandboxDialog.value = true
}
function closeSandboxDialog() {
sandboxDialog.value = false
sandboxKey.value = ''
sandboxError.value = ''
}
async function addProvider() {
if (providerBusy.value) return
providerBusy.value = true
@@ -89,6 +114,7 @@ async function addProvider() {
providerBaseUrl.value = ''
providerKey.value = ''
await loadLists()
providerDialog.value = false
} catch (err) {
providerError.value = apiErrorMessage(err)
} finally {
@@ -117,6 +143,7 @@ async function addSandbox() {
sandboxRoot.value = '/root'
sandboxKey.value = ''
await loadLists()
sandboxDialog.value = false
} catch (err) {
sandboxError.value = apiErrorMessage(err)
} finally {
@@ -193,10 +220,14 @@ async function copyKey(target: SandboxTarget) {
<section class="section">
<div class="section-head">
<h2 class="section-title">Providers</h2>
<button type="button" class="btn btn-sm" @click="openProviderDialog">
<Plus :size="14" aria-hidden="true" />
Add provider
</button>
</div>
<p class="hint">A provider holds the model backend and key. Rooms spend from the provider their owner picks.</p>
<div v-if="!loading && providers.length === 0" class="empty">No providers yet. Add one below.</div>
<div v-if="!loading && providers.length === 0" class="empty">No providers yet. Use Add provider to connect one.</div>
<div v-else class="list">
<div v-for="provider in providers" :key="provider.id" class="settings-row">
@@ -233,13 +264,17 @@ async function copyKey(target: SandboxTarget) {
</div>
</div>
<div class="form-panel">
<h3 class="panel-title">Add provider</h3>
<BaseDialog
v-if="providerDialog"
title="Add provider"
description="The key stays sealed on the server and is never shown again."
@close="closeProviderDialog"
>
<form class="form" @submit.prevent="addProvider">
<div class="form-grid">
<div class="field">
<label class="field-label" for="provider-name">Name</label>
<input id="provider-name" v-model="providerName" class="input" type="text" maxlength="60" required>
<input id="provider-name" v-model="providerName" class="input" type="text" maxlength="60" autofocus required>
</div>
<div class="field">
<label class="field-label" for="provider-kind">Kind</label>
@@ -287,23 +322,27 @@ async function copyKey(target: SandboxTarget) {
<p v-if="providerError" class="form-error" role="alert">{{ providerError }}</p>
<div>
<div class="dialog-actions">
<button type="button" class="btn" :disabled="providerBusy" @click="closeProviderDialog">Cancel</button>
<button type="submit" class="btn btn-primary" :disabled="providerBusy">
<Plus :size="16" aria-hidden="true" />
{{ providerBusy ? 'Adding' : 'Add provider' }}
</button>
</div>
</form>
</div>
</BaseDialog>
</section>
<section class="section">
<div class="section-head">
<h2 class="section-title">Sandboxes</h2>
<button type="button" class="btn btn-sm" @click="openSandboxDialog">
<Plus :size="14" aria-hidden="true" />
Add sandbox
</button>
</div>
<p class="hint">A sandbox is an ssh machine the room works on. The public key belongs in its authorized_keys file.</p>
<div v-if="!loading && targets.length === 0" class="empty">No sandboxes yet. Add one below.</div>
<div v-if="!loading && targets.length === 0" class="empty">No sandboxes yet. Use Add sandbox to connect one.</div>
<div v-else class="list">
<div v-for="target in targets" :key="target.id" class="settings-row">
@@ -366,13 +405,17 @@ async function copyKey(target: SandboxTarget) {
</div>
</div>
<div class="form-panel">
<h3 class="panel-title">Add sandbox</h3>
<BaseDialog
v-if="sandboxDialog"
title="Add sandbox"
description="The room runs commands on this machine with the matching private key."
@close="closeSandboxDialog"
>
<form class="form" @submit.prevent="addSandbox">
<div class="form-grid">
<div class="field">
<label class="field-label" for="sandbox-name">Name</label>
<input id="sandbox-name" v-model="sandboxName" class="input" type="text" maxlength="60" required>
<input id="sandbox-name" v-model="sandboxName" class="input" type="text" maxlength="60" autofocus required>
</div>
<div class="field">
<label class="field-label" for="sandbox-host">Host</label>
@@ -411,14 +454,14 @@ async function copyKey(target: SandboxTarget) {
<p v-if="sandboxError" class="form-error" role="alert">{{ sandboxError }}</p>
<div>
<div class="dialog-actions">
<button type="button" class="btn" :disabled="sandboxBusy" @click="closeSandboxDialog">Cancel</button>
<button type="submit" class="btn btn-primary" :disabled="sandboxBusy">
<Plus :size="16" aria-hidden="true" />
{{ sandboxBusy ? 'Adding' : 'Add sandbox' }}
</button>
</div>
</form>
</div>
</BaseDialog>
</section>
</div>
</template>