Spaces:
Sleeping
Sleeping
File size: 5,372 Bytes
4343907 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
<template>
<div class="agent-details">
<!-- Agent Details Header -->
<div class="details-header">
<button
@click="$router.push('/')"
class="saap-button-secondary mb-4"
>
β Back to Dashboard
</button>
<div v-if="agent" class="agent-header">
<div class="agent-avatar" :style="{ backgroundColor: agent.color }">
{{ agent.name.charAt(0) }}
</div>
<div>
<h1 class="saap-heading-2">{{ agent.name }}</h1>
<p class="saap-body text-saap-gray-600">{{ agent.description }}</p>
<div class="agent-status">
<span
class="status-badge"
:class="`status-${agent.status}`"
>
{{ agent.status }}
</span>
</div>
</div>
</div>
<!-- Agent not found -->
<div v-else class="empty-state">
<h2 class="saap-heading-3">Agent nicht gefunden</h2>
<p class="saap-body">Der angeforderte Agent existiert nicht.</p>
</div>
</div>
<!-- Agent Configuration -->
<div v-if="agent" class="agent-config saap-card p-6">
<h2 class="saap-heading-3 mb-4">Configuration</h2>
<div class="config-grid">
<div class="config-item">
<label class="config-label">Agent ID</label>
<span class="config-value saap-mono">{{ agent.id }}</span>
</div>
<div class="config-item">
<label class="config-label">Type</label>
<span class="config-value">{{ agent.type }}</span>
</div>
<div class="config-item">
<label class="config-label">Status</label>
<span class="config-value">{{ agent.status }}</span>
</div>
<div class="config-item">
<label class="config-label">Model</label>
<span class="config-value saap-mono">{{ agent.llm_config?.model || 'N/A' }}</span>
</div>
</div>
</div>
<!-- Agent Actions -->
<div v-if="agent" class="agent-actions saap-card p-6">
<h2 class="saap-heading-3 mb-4">Actions</h2>
<div class="actions-grid">
<button
v-if="agent.status === 'inactive'"
@click="startAgent"
class="saap-button-primary"
>
Start Agent
</button>
<button
v-if="agent.status === 'active'"
@click="stopAgent"
class="saap-button-secondary"
>
Stop Agent
</button>
<button
v-if="agent.status === 'active'"
@click="openChat"
class="saap-button-accent"
>
Chat with Agent
</button>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAgentStore } from '@/stores/agents'
const route = useRoute()
const router = useRouter()
const agentStore = useAgentStore()
const agentId = computed(() => route.params.id)
const agent = computed(() => {
const foundAgent = agentStore.agentById(agentId.value)
return foundAgent || null
})
const startAgent = async () => {
try {
await agentStore.startAgent(agent.value.id)
console.log(`β
Agent ${agent.value.name} started`)
} catch (error) {
console.error('β Failed to start agent:', error)
}
}
const stopAgent = async () => {
try {
await agentStore.stopAgent(agent.value.id)
console.log(`β
Agent ${agent.value.name} stopped`)
} catch (error) {
console.error('β Failed to stop agent:', error)
}
}
const openChat = () => {
router.push(`/agents/${agent.value.id}/chat`)
}
onMounted(async () => {
await agentStore.initialize()
// Redirect if agent doesn't exist
if (!agent.value) {
console.warn(`β οΈ Agent ${agentId.value} not found, redirecting to dashboard`)
setTimeout(() => {
router.push('/')
}, 2000)
}
})
</script>
<style scoped>
.agent-details {
@apply space-y-6 max-w-4xl mx-auto;
}
.details-header {
@apply space-y-4;
}
.agent-header {
@apply flex items-start space-x-4;
}
.agent-avatar {
@apply w-16 h-16 rounded-xl flex items-center justify-center;
@apply text-white font-bold text-xl flex-shrink-0;
}
.agent-status {
@apply mt-2;
}
.status-badge {
@apply inline-flex px-3 py-1 rounded-full text-xs font-medium;
}
.status-active {
@apply bg-saap-secondary-100 text-saap-secondary-800;
}
.status-inactive {
@apply bg-saap-gray-100 text-saap-gray-800;
}
.status-starting {
@apply bg-saap-accent-100 text-saap-accent-800;
}
.config-grid {
@apply grid grid-cols-1 md:grid-cols-2 gap-4;
}
.config-item {
@apply flex flex-col space-y-1;
}
.config-label {
@apply text-sm font-medium text-saap-gray-700;
}
.config-value {
@apply text-base text-saap-gray-900;
}
.actions-grid {
@apply flex flex-wrap gap-3;
}
.actions-grid button {
@apply flex-shrink-0;
}
.empty-state {
@apply text-center py-12 bg-saap-gray-50 rounded-lg;
}
.empty-state h2 {
@apply mb-2;
}
/* Responsive improvements */
@media (max-width: 640px) {
.agent-header {
@apply flex-col space-x-0 space-y-4 text-center;
}
.agent-avatar {
@apply mx-auto;
}
.config-grid {
@apply grid-cols-1;
}
.actions-grid {
@apply flex-col;
}
.actions-grid button {
@apply w-full;
}
}
</style> |