kin: KIN-108-frontend_dev

This commit is contained in:
Gros Frumos 2026-03-18 07:57:15 +02:00
parent 8b409fd7db
commit 353416ead1
16 changed files with 799 additions and 212 deletions

View file

@ -1,7 +1,10 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { api, type Project, type ObsidianSyncResult, type ProjectLink } from '../api'
const { t } = useI18n()
const projects = ref<Project[]>([])
const vaultPaths = ref<Record<string, string>>({})
const deployCommands = ref<Record<string, string>>({})
@ -71,9 +74,9 @@ async function saveDeployConfig(projectId: string) {
deploy_restart_cmd: deployRestartCmds.value[projectId],
deploy_command: deployCommands.value[projectId],
})
saveDeployConfigStatus.value[projectId] = 'Saved'
saveDeployConfigStatus.value[projectId] = t('common.saved')
} catch (e: unknown) {
saveDeployConfigStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
saveDeployConfigStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingDeployConfig.value[projectId] = false
}
@ -84,9 +87,9 @@ async function saveVaultPath(projectId: string) {
saveStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { obsidian_vault_path: vaultPaths.value[projectId] })
saveStatus.value[projectId] = 'Saved'
saveStatus.value[projectId] = t('common.saved')
} catch (e: unknown) {
saveStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
saveStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
} finally {
saving.value[projectId] = false
}
@ -97,9 +100,9 @@ async function saveTestCommand(projectId: string) {
saveTestStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { test_command: testCommands.value[projectId] })
saveTestStatus.value[projectId] = 'Saved'
saveTestStatus.value[projectId] = t('common.saved')
} catch (e: unknown) {
saveTestStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
saveTestStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingTest.value[projectId] = false
}
@ -111,10 +114,10 @@ async function toggleAutoTest(projectId: string) {
saveAutoTestStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { auto_test_enabled: autoTestEnabled.value[projectId] })
saveAutoTestStatus.value[projectId] = 'Saved'
saveAutoTestStatus.value[projectId] = t('common.saved')
} catch (e: unknown) {
autoTestEnabled.value[projectId] = !autoTestEnabled.value[projectId]
saveAutoTestStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
saveAutoTestStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingAutoTest.value[projectId] = false
}
@ -126,10 +129,10 @@ async function toggleWorktrees(projectId: string) {
saveWorktreesStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { worktrees_enabled: worktreesEnabled.value[projectId] })
saveWorktreesStatus.value[projectId] = 'Saved'
saveWorktreesStatus.value[projectId] = t('common.saved')
} catch (e: unknown) {
worktreesEnabled.value[projectId] = !worktreesEnabled.value[projectId]
saveWorktreesStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
saveWorktreesStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingWorktrees.value[projectId] = false
}
@ -162,7 +165,7 @@ async function loadLinks(projectId: string) {
async function addLink(projectId: string) {
const form = linkForms.value[projectId]
if (!form.to_project) { linkError.value[projectId] = '&#x412;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442;'; return }
if (!form.to_project) { linkError.value[projectId] = t('settings.select_project_error'); return }
linkSaving.value[projectId] = true
linkError.value[projectId] = ''
try {
@ -183,7 +186,7 @@ async function addLink(projectId: string) {
}
async function deleteLink(projectId: string, linkId: number) {
if (!confirm('&#x423;&#x434;&#x430;&#x43B;&#x438;&#x442;&#x44C; &#x441;&#x432;&#x44F;&#x437;&#x44C;?')) return
if (!confirm(t('settings.delete_link_confirm'))) return
try {
await api.deleteProjectLink(linkId)
await loadLinks(projectId)
@ -195,7 +198,7 @@ async function deleteLink(projectId: string, linkId: number) {
<template>
<div>
<h1 class="text-xl font-semibold text-gray-100 mb-6">Settings</h1>
<h1 class="text-xl font-semibold text-gray-100 mb-6">{{ t('settings.title') }}</h1>
<div v-if="error" class="text-red-400 mb-4">{{ error }}</div>
@ -206,7 +209,7 @@ async function deleteLink(projectId: string, linkId: number) {
</div>
<div class="mb-3">
<label class="block text-xs text-gray-400 mb-1">Obsidian Vault Path</label>
<label class="block text-xs text-gray-400 mb-1">{{ t('settings.obsidian_vault_path') }}</label>
<input
v-model="vaultPaths[project.id]"
type="text"
@ -216,14 +219,14 @@ async function deleteLink(projectId: string, linkId: number) {
</div>
<div class="mb-3">
<label class="block text-xs text-gray-400 mb-1">Test Command</label>
<label class="block text-xs text-gray-400 mb-1">{{ t('settings.test_command') }}</label>
<input
v-model="testCommands[project.id]"
type="text"
placeholder="make test"
class="w-full bg-gray-900 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
/>
<p class="text-xs text-gray-600 mt-1">&#x41A;&#x43E;&#x43C;&#x430;&#x43D;&#x434;&#x430; &#x437;&#x430;&#x43F;&#x443;&#x441;&#x43A;&#x430; &#x442;&#x435;&#x441;&#x442;&#x43E;&#x432;, &#x432;&#x44B;&#x43F;&#x43E;&#x43B;&#x43D;&#x44F;&#x435;&#x442;&#x441;&#x44F; &#x447;&#x435;&#x440;&#x435;&#x437; shell &#x432; &#x434;&#x438;&#x440;&#x435;&#x43A;&#x442;&#x43E;&#x440;&#x438;&#x438; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442;&#x430;.</p>
<p class="text-xs text-gray-600 mt-1">{{ t('settings.test_command_hint') }}</p>
</div>
<div class="flex items-center gap-3 flex-wrap mb-3">
@ -232,7 +235,7 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="savingTest[project.id]"
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
>
{{ savingTest[project.id] ? 'Saving&#x2026;' : 'Save Test' }}
{{ savingTest[project.id] ? t('settings.saving_test') : t('settings.save_test') }}
</button>
<span v-if="saveTestStatus[project.id]" class="text-xs" :class="saveTestStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveTestStatus[project.id] }}
@ -241,9 +244,9 @@ async function deleteLink(projectId: string, linkId: number) {
<!-- Deploy Config -->
<div class="mb-2 pt-2 border-t border-gray-800">
<p class="text-xs font-semibold text-gray-400 mb-2">Deploy Config</p>
<p class="text-xs font-semibold text-gray-400 mb-2">{{ t('settings.deploy_config') }}</p>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Server host</label>
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.server_host') }}</label>
<input
v-model="deployHosts[project.id]"
type="text"
@ -252,7 +255,7 @@ async function deleteLink(projectId: string, linkId: number) {
/>
</div>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Project path on server</label>
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.project_path_on_server') }}</label>
<input
v-model="deployPaths[project.id]"
type="text"
@ -261,12 +264,12 @@ async function deleteLink(projectId: string, linkId: number) {
/>
</div>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Runtime</label>
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.runtime') }}</label>
<select
v-model="deployRuntimes[project.id]"
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-300 focus:outline-none focus:border-gray-500"
>
<option value="">&#x2014; &#x432;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; runtime &#x2014;</option>
<option value="">{{ t('settings.select_runtime') }}</option>
<option value="docker">docker</option>
<option value="node">node</option>
<option value="python">python</option>
@ -274,7 +277,7 @@ async function deleteLink(projectId: string, linkId: number) {
</select>
</div>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Restart command (optional override)</label>
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.restart_command') }}</label>
<input
v-model="deployRestartCmds[project.id]"
type="text"
@ -283,7 +286,7 @@ async function deleteLink(projectId: string, linkId: number) {
/>
</div>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Fallback command (legacy, used when runtime not set)</label>
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.fallback_command') }}</label>
<input
v-model="deployCommands[project.id]"
type="text"
@ -297,7 +300,7 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="savingDeployConfig[project.id]"
class="px-3 py-1.5 text-sm bg-teal-900/50 text-teal-400 border border-teal-800 rounded hover:bg-teal-900 disabled:opacity-50"
>
{{ savingDeployConfig[project.id] ? 'Saving&#x2026;' : 'Save Deploy Config' }}
{{ savingDeployConfig[project.id] ? t('settings.saving_deploy') : t('settings.save_deploy_config') }}
</button>
<span v-if="saveDeployConfigStatus[project.id]" class="text-xs" :class="saveDeployConfigStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveDeployConfigStatus[project.id] }}
@ -308,28 +311,28 @@ async function deleteLink(projectId: string, linkId: number) {
<!-- Project Links -->
<div class="mb-2 pt-2 border-t border-gray-800">
<div class="flex items-center justify-between mb-2">
<p class="text-xs font-semibold text-gray-400">Project Links</p>
<p class="text-xs font-semibold text-gray-400">{{ t('settings.project_links') }}</p>
<button
@click="showAddLinkForm[project.id] = !showAddLinkForm[project.id]"
class="px-2 py-0.5 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700"
>
+ Add Link
{{ t('settings.add_link') }}
</button>
</div>
<p v-if="linksLoading[project.id]" class="text-xs text-gray-500">&#x417;&#x430;&#x433;&#x440;&#x443;&#x437;&#x43A;&#x430;...</p>
<p v-if="linksLoading[project.id]" class="text-xs text-gray-500">{{ t('settings.links_loading') }}</p>
<p v-else-if="linkError[project.id]" class="text-xs text-red-400">{{ linkError[project.id] }}</p>
<div v-else-if="!projectLinksMap[project.id]?.length" class="text-xs text-gray-600">&#x41D;&#x435;&#x442; &#x441;&#x432;&#x44F;&#x437;&#x435;&#x439;</div>
<div v-else-if="!projectLinksMap[project.id]?.length" class="text-xs text-gray-600">{{ t('settings.no_links') }}</div>
<div v-else class="space-y-1 mb-2">
<div v-for="link in projectLinksMap[project.id]" :key="link.id"
class="flex items-center gap-2 px-2 py-1 bg-gray-900 border border-gray-800 rounded text-xs">
<span class="text-gray-500 font-mono">{{ link.from_project }}</span>
<span class="text-gray-600">&#x2192;</span>
<span class="text-gray-600"></span>
<span class="text-gray-500 font-mono">{{ link.to_project }}</span>
<span class="px-1 bg-indigo-900/30 text-indigo-400 border border-indigo-800 rounded">{{ link.type }}</span>
<span v-if="link.description" class="text-gray-600">{{ link.description }}</span>
<button @click="deleteLink(project.id, link.id)"
class="ml-auto text-red-500 hover:text-red-400 bg-transparent border-none cursor-pointer text-xs shrink-0">
&#x2715;
</button>
</div>
</div>
@ -342,8 +345,8 @@ async function deleteLink(projectId: string, linkId: number) {
<label class="block text-[10px] text-gray-500 mb-0.5">To project</label>
<select v-model="linkForms[project.id].to_project" required
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300">
<option value="">&#x2014; &#x432;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442; &#x2014;</option>
<option v-for="p in allProjectList.filter(p => p.id !== project.id)" :key="p.id" :value="p.id">{{ p.id }} &#x2014; {{ p.name }}</option>
<option value="">{{ t('settings.select_project') }}</option>
<option v-for="p in allProjectList.filter(p => p.id !== project.id)" :key="p.id" :value="p.id">{{ p.id }} {{ p.name }}</option>
</select>
</div>
<div>
@ -363,11 +366,11 @@ async function deleteLink(projectId: string, linkId: number) {
<div class="flex gap-2">
<button type="submit" :disabled="linkSaving[project.id]"
class="px-3 py-1 text-xs bg-blue-900/50 text-blue-400 border border-blue-800 rounded hover:bg-blue-900 disabled:opacity-50">
{{ linkSaving[project.id] ? 'Saving...' : 'Add' }}
{{ linkSaving[project.id] ? t('settings.saving_link') : t('common.add') }}
</button>
<button type="button" @click="showAddLinkForm[project.id] = false; linkError[project.id] = ''"
class="px-3 py-1 text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer">
&#x41E;&#x442;&#x43C;&#x435;&#x43D;&#x430;
{{ t('settings.cancel_link') }}
</button>
</div>
</form>
@ -382,8 +385,8 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="savingAutoTest[project.id]"
class="w-4 h-4 rounded border-gray-600 bg-gray-800 accent-blue-500 cursor-pointer disabled:opacity-50"
/>
<span class="text-sm text-gray-300">Auto-test</span>
<span class="text-xs text-gray-500">&#x2014; &#x437;&#x430;&#x43F;&#x443;&#x441;&#x43A;&#x430;&#x442;&#x44C; &#x442;&#x435;&#x441;&#x442;&#x44B; &#x430;&#x432;&#x442;&#x43E;&#x43C;&#x430;&#x442;&#x438;&#x447;&#x435;&#x441;&#x43A;&#x438; &#x43F;&#x43E;&#x441;&#x43B;&#x435; pipeline</span>
<span class="text-sm text-gray-300">{{ t('settings.auto_test') }}</span>
<span class="text-xs text-gray-500">{{ t('settings.auto_test_hint') }}</span>
</label>
<span v-if="saveAutoTestStatus[project.id]" class="text-xs" :class="saveAutoTestStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveAutoTestStatus[project.id] }}
@ -399,8 +402,8 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="savingWorktrees[project.id]"
class="w-4 h-4 rounded border-gray-600 bg-gray-800 accent-blue-500 cursor-pointer disabled:opacity-50"
/>
<span class="text-sm text-gray-300">Worktrees</span>
<span class="text-xs text-gray-500"> агенты запускаются в изолированных git worktrees</span>
<span class="text-sm text-gray-300">{{ t('settings.worktrees') }}</span>
<span class="text-xs text-gray-500">{{ t('settings.worktrees_hint') }}</span>
</label>
<span v-if="saveWorktreesStatus[project.id]" class="text-xs" :class="saveWorktreesStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveWorktreesStatus[project.id] }}
@ -413,7 +416,7 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="saving[project.id]"
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
>
{{ saving[project.id] ? 'Saving&#x2026;' : 'Save Vault' }}
{{ saving[project.id] ? t('settings.saving_vault') : t('settings.save_vault') }}
</button>
<button
@ -421,7 +424,7 @@ async function deleteLink(projectId: string, linkId: number) {
:disabled="syncing[project.id] || !vaultPaths[project.id]"
class="px-3 py-1.5 text-sm bg-indigo-700 hover:bg-indigo-600 text-white rounded disabled:opacity-50"
>
{{ syncing[project.id] ? 'Syncing&#x2026;' : 'Sync Obsidian' }}
{{ syncing[project.id] ? t('settings.syncing') : t('settings.sync_obsidian') }}
</button>
<span v-if="saveStatus[project.id]" class="text-xs" :class="saveStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">