-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.vue
More file actions
166 lines (153 loc) · 5.68 KB
/
Copy pathTable.vue
File metadata and controls
166 lines (153 loc) · 5.68 KB
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
<script setup lang="ts">
const jobs = [
{ id: 'job-001', agent: 'crawler-alpha', status: 'running', runtime: 'node-v8', started: '2026-06-15 09:12', lease: '60s' },
{ id: 'job-002', agent: 'embedder-beta', status: 'completed', runtime: 'python-v3', started: '2026-06-15 08:45', lease: 'expired' },
{ id: 'job-003', agent: 'summarizer-v2', status: 'failed', runtime: 'node-v8', started: '2026-06-15 08:30', lease: 'n/a' },
{ id: 'job-004', agent: 'indexer-gamma', status: 'queued', runtime: 'wasm-v1', started: '2026-06-15 09:20', lease: '30s' },
{ id: 'job-005', agent: 'validator-x', status: 'running', runtime: 'python-v3', started: '2026-06-15 09:18', lease: '120s' },
]
const jobColumns = [
{ accessorKey: 'id', header: 'Job ID' },
{ accessorKey: 'agent', header: 'Agent' },
{ accessorKey: 'status', header: 'Status' },
{ accessorKey: 'runtime', header: 'Runtime' },
{ accessorKey: 'started', header: 'Started' },
{ accessorKey: 'lease', header: 'Lease TTL' },
]
const statusColor: Record<string, string> = {
running: 'text-success-500',
completed: 'text-info-500',
failed: 'text-error-500',
queued: 'text-warning-500',
}
const sessions = [
{ session: 'sess-9a3f', agent: 'crawler-alpha', events: 142, traces: 37, duration: '4m 12s' },
{ session: 'sess-b21c', agent: 'embedder-beta', events: 89, traces: 12, duration: '1m 55s' },
{ session: 'sess-c77d', agent: 'summarizer-v2', events: 5, traces: 2, duration: '0m 08s' },
]
const sessionColumns = [
{ accessorKey: 'session', header: 'Session' },
{ accessorKey: 'agent', header: 'Agent' },
{ accessorKey: 'events', header: 'Events' },
{ accessorKey: 'traces', header: 'Traces' },
{ accessorKey: 'duration', header: 'Duration' },
]
const rowSelection = ref<Record<string, boolean>>({})
const sorting = ref([])
const isLoading = ref(false)
function toggleLoading() {
isLoading.value = !isLoading.value
}
</script>
<template>
<div class="flex flex-col gap-8">
<GallerySection title="Basic — Job Queue">
<div class="w-full overflow-x-auto">
<UTable :data="jobs" :columns="jobColumns" />
</div>
</GallerySection>
<GallerySection title="Custom cell rendering — Status badges">
<div class="w-full overflow-x-auto">
<UTable :data="jobs" :columns="jobColumns">
<template #status-cell="{ row }">
<span :class="['font-medium capitalize', statusColor[row.original.status]]">
{{ row.original.status }}
</span>
</template>
<template #lease-cell="{ row }">
<UBadge
v-if="row.original.lease !== 'n/a' && row.original.lease !== 'expired'"
color="success"
variant="soft"
size="sm"
>
{{ row.original.lease }}
</UBadge>
<UBadge
v-else-if="row.original.lease === 'expired'"
color="warning"
variant="soft"
size="sm"
>
expired
</UBadge>
<span v-else class="text-[var(--ui-text-muted)]">n/a</span>
</template>
</UTable>
</div>
</GallerySection>
<GallerySection title="Row selection">
<div class="w-full overflow-x-auto">
<UTable
:data="sessions"
:columns="sessionColumns"
v-model:row-selection="rowSelection"
:row-selection-options="{ enableMultiRowSelection: true }"
/>
</div>
<p class="text-sm text-[var(--ui-text-muted)] mt-2">
Selected rows: {{ Object.keys(rowSelection).filter(k => rowSelection[k]).join(', ') || 'none' }}
</p>
</GallerySection>
<GallerySection title="Loading state">
<div class="w-full overflow-x-auto">
<UTable
:data="jobs"
:columns="jobColumns"
:loading="isLoading"
loading-color="primary"
/>
</div>
<UButton
class="mt-3"
:icon="isLoading ? 'i-material-symbols-stop-circle-outline' : 'i-material-symbols-refresh'"
:color="isLoading ? 'error' : 'primary'"
variant="soft"
@click="toggleLoading"
>
{{ isLoading ? 'Stop loading' : 'Simulate loading' }}
</UButton>
</GallerySection>
<GallerySection title="Empty state">
<div class="w-full overflow-x-auto">
<UTable
:data="[]"
:columns="jobColumns"
empty="No jobs found in the runtime queue."
/>
</div>
</GallerySection>
<GallerySection title="Sticky header">
<div class="w-full overflow-x-auto max-h-40 overflow-y-auto">
<UTable
:data="[...jobs, ...jobs]"
:columns="jobColumns"
sticky="header"
/>
</div>
</GallerySection>
<GallerySection title="Session traces — realistic usage">
<div class="w-full overflow-x-auto">
<UTable :data="sessions" :columns="sessionColumns">
<template #session-cell="{ row }">
<span class="font-mono text-xs text-[var(--ui-text-highlighted)]">
{{ row.original.session }}
</span>
</template>
<template #events-cell="{ row }">
<div class="flex items-center gap-1">
<UIcon name="i-material-symbols-bolt-outline" class="text-warning-500 size-4" />
{{ row.original.events }}
</div>
</template>
<template #traces-cell="{ row }">
<div class="flex items-center gap-1">
<UIcon name="i-material-symbols-timeline-outline" class="text-info-500 size-4" />
{{ row.original.traces }}
</div>
</template>
</UTable>
</div>
</GallerySection>
</div>
</template>