File size: 8,292 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<template>
  <div class="modal-overlay" @click.self="$emit('close')">
    <div class="details-modal-content">
      <div class="modal-header">
        <div class="agent-info">
          <div class="agent-avatar" :style="{ backgroundColor: agent.color || '#6B7280' }">
            {{ agent.name?.charAt(0) || 'A' }}
          </div>
          <div>
            <h2 class="agent-name">{{ agent.name }}</h2>
            <p class="agent-type">{{ agent.type }} Agent</p>
          </div>
        </div>
        <button class="close-button" @click="$emit('close')">

        </button>
      </div>

      <div class="modal-body">
        <!-- Status Section -->
        <div class="section">
          <h3 class="section-title">Status</h3>
          <div class="status-info">
            <div class="status-item">
              <span class="status-label">Current Status:</span>
              <span 
                class="status-badge"
                :class="{
                  'bg-green-100 text-green-800': agent.status === 'active',
                  'bg-red-100 text-red-800': agent.status === 'inactive',
                  'bg-yellow-100 text-yellow-800': agent.status === 'starting'
                }"
              >
                {{ agent.status || 'Unknown' }}
              </span>
            </div>
            <div class="status-item">
              <span class="status-label">Created:</span>
              <span>{{ formatDate(agent.created_at) }}</span>
            </div>
            <div class="status-item">
              <span class="status-label">Last Active:</span>
              <span>{{ formatDate(agent.last_active || agent.created_at) }}</span>
            </div>
          </div>
        </div>

        <!-- Metrics Section -->
        <div class="section">
          <h3 class="section-title">Performance Metrics</h3>
          <div class="metrics-grid">
            <div class="metric-card">
              <div class="metric-value">{{ agent.metrics?.messages_processed || 0 }}</div>
              <div class="metric-label">Messages Processed</div>
            </div>
            <div class="metric-card">
              <div class="metric-value">{{ agent.metrics?.average_response_time?.toFixed(2) || '0.00' }}s</div>
              <div class="metric-label">Avg Response Time</div>
            </div>
            <div class="metric-card">
              <div class="metric-value">{{ agent.metrics?.success_rate || '100' }}%</div>
              <div class="metric-label">Success Rate</div>
            </div>
            <div class="metric-card">
              <div class="metric-value">{{ agent.metrics?.uptime || '0' }}h</div>
              <div class="metric-label">Uptime</div>
            </div>
          </div>
        </div>

        <!-- Configuration Section -->
        <div class="section">
          <h3 class="section-title">Configuration</h3>
          <div class="config-info">
            <div class="config-item">
              <span class="config-label">Name:</span>
              <input 
                v-model="editForm.name"
                class="config-input"
                :disabled="!editing"
              />
            </div>
            <div class="config-item">
              <span class="config-label">Type:</span>
              <select 
                v-model="editForm.type"
                class="config-input"
                :disabled="!editing"
              >
                <option value="coordinator">Coordinator</option>
                <option value="developer">Developer</option>
                <option value="analyst">Analyst</option>
                <option value="specialist">Specialist</option>
              </select>
            </div>
            <div class="config-item">
              <span class="config-label">Description:</span>
              <textarea 
                v-model="editForm.description"
                class="config-input resize-y"
                rows="3"
                :disabled="!editing"
              ></textarea>
            </div>
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <button class="secondary-button" @click="$emit('close')">
          Close
        </button>
        <button 
          v-if="!editing"
          class="primary-button"
          @click="startEdit"
        >
          Edit Agent
        </button>
        <div v-else class="edit-actions">
          <button class="cancel-button" @click="cancelEdit">
            Cancel
          </button>
          <button class="save-button" @click="saveChanges">
            Save Changes
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, reactive } from 'vue'

export default {
  name: 'AgentDetailsModal',
  props: {
    agent: {
      type: Object,
      required: true
    }
  },
  emits: ['close', 'update'],
  setup(props, { emit }) {
    const editing = ref(false)
    const editForm = reactive({
      name: props.agent.name,
      type: props.agent.type,
      description: props.agent.description || ''
    })

    const startEdit = () => {
      editing.value = true
    }

    const cancelEdit = () => {
      editing.value = false
      // Reset form
      editForm.name = props.agent.name
      editForm.type = props.agent.type
      editForm.description = props.agent.description || ''
    }

    const saveChanges = () => {
      const updatedAgent = {
        ...props.agent,
        name: editForm.name,
        type: editForm.type,
        description: editForm.description
      }
      emit('update', updatedAgent)
      editing.value = false
    }

    const formatDate = (dateString) => {
      if (!dateString) return 'Unknown'
      return new Date(dateString).toLocaleString('de-DE')
    }

    return {
      editing,
      editForm,
      startEdit,
      cancelEdit,
      saveChanges,
      formatDate
    }
  }
}
</script>

<style scoped>
.modal-overlay {
  @apply fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50;
}

.details-modal-content {
  @apply bg-white rounded-lg shadow-xl w-full max-w-4xl mx-4 max-h-screen flex flex-col;
}

.modal-header {
  @apply flex items-center justify-between p-6 border-b border-gray-200;
}

.agent-info {
  @apply flex items-center space-x-4;
}

.agent-avatar {
  @apply w-12 h-12 rounded-lg flex items-center justify-center text-white font-medium text-lg;
}

.agent-name {
  @apply text-xl font-semibold text-gray-900;
}

.agent-type {
  @apply text-sm text-gray-600 capitalize;
}

.close-button {
  @apply text-gray-400 hover:text-gray-600 text-xl font-bold w-8 h-8 flex items-center justify-center;
}

.modal-body {
  @apply flex-1 overflow-y-auto p-6 space-y-8;
}

.section {
  @apply space-y-4;
}

.section-title {
  @apply text-lg font-semibold text-gray-900 border-b border-gray-200 pb-2;
}

.status-info {
  @apply space-y-3;
}

.status-item {
  @apply flex items-center justify-between;
}

.status-label {
  @apply text-sm font-medium text-gray-700;
}

.status-badge {
  @apply px-2 py-1 text-xs font-medium rounded-full;
}

.metrics-grid {
  @apply grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4;
}

.metric-card {
  @apply bg-gray-50 rounded-lg p-4 text-center;
}

.metric-value {
  @apply text-2xl font-bold text-gray-900;
}

.metric-label {
  @apply text-sm text-gray-600 mt-1;
}

.config-info {
  @apply space-y-4;
}

.config-item {
  @apply space-y-2;
}

.config-label {
  @apply block text-sm font-medium text-gray-700;
}

.config-input {
  @apply w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed;
}

.modal-footer {
  @apply flex items-center justify-end space-x-3 p-6 border-t border-gray-200;
}

.edit-actions {
  @apply flex space-x-2;
}

.secondary-button {
  @apply px-4 py-2 border border-gray-300 text-gray-700 rounded-md hover:bg-gray-50 font-medium;
}

.primary-button {
  @apply px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 font-medium;
}

.cancel-button {
  @apply px-4 py-2 border border-gray-300 text-gray-700 rounded-md hover:bg-gray-50 font-medium;
}

.save-button {
  @apply px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 font-medium;
}
</style>