qarpeo 0.1.18 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -96
- package/dist/chunks/auth-schema.mjs +3 -1
- package/dist/chunks/wrangler.mjs +22 -3
- package/dist/cli/index.mjs +448 -221
- package/dist/fate/index.d.ts +29 -22
- package/dist/fate/index.mjs +1 -3
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +103 -82
- package/dist/runtime/ai.d.ts +2 -2
- package/dist/runtime/app/components/BlobImage.vue +119 -107
- package/dist/runtime/app/components/CMSBlocks.vue +104 -93
- package/dist/runtime/app/components/CMSContent.vue +24 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +83 -80
- package/dist/runtime/app/components/FileUpload.vue +200 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
- package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/composables/ai.d.ts +22 -22
- package/dist/runtime/app/composables/ai.mjs +3 -7
- package/dist/runtime/app/composables/analytics.mjs +1 -1
- package/dist/runtime/app/composables/api-tokens.mjs +1 -1
- package/dist/runtime/app/composables/auth.d.ts +6 -7
- package/dist/runtime/app/composables/auth.mjs +6 -3
- package/dist/runtime/app/composables/chat.mjs +3 -7
- package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
- package/dist/runtime/app/composables/cms-preview.mjs +1 -1
- package/dist/runtime/app/composables/cms.d.ts +3 -5
- package/dist/runtime/app/composables/cms.mjs +2 -2
- package/dist/runtime/app/composables/docs-version.d.ts +8 -7
- package/dist/runtime/app/composables/docs-version.mjs +3 -3
- package/dist/runtime/app/composables/impersonation.mjs +1 -1
- package/dist/runtime/app/composables/notifications.d.ts +5 -5
- package/dist/runtime/app/composables/notifications.mjs +4 -5
- package/dist/runtime/app/composables/organization.mjs +1 -1
- package/dist/runtime/app/composables/passkey.mjs +1 -1
- package/dist/runtime/app/composables/passwordless.mjs +1 -1
- package/dist/runtime/app/composables/payments.d.ts +2 -1
- package/dist/runtime/app/composables/payments.mjs +1 -1
- package/dist/runtime/app/composables/realtime.d.ts +13 -13
- package/dist/runtime/app/composables/realtime.mjs +2 -2
- package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
- package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
- package/dist/runtime/app/composables/site.mjs +1 -1
- package/dist/runtime/app/composables/storage.d.ts +151 -11
- package/dist/runtime/app/composables/storage.mjs +291 -33
- package/dist/runtime/app/composables/turnstile.mjs +1 -1
- package/dist/runtime/app/composables/two-factor.mjs +1 -1
- package/dist/runtime/app/pages/devtools/agents.vue +716 -716
- package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
- package/dist/runtime/app/pages/devtools/auth.vue +381 -350
- package/dist/runtime/app/pages/devtools/blob.vue +743 -744
- package/dist/runtime/app/pages/devtools/db.vue +545 -545
- package/dist/runtime/app/pages/devtools/domains.vue +771 -771
- package/dist/runtime/app/pages/devtools/kv.vue +827 -828
- package/dist/runtime/app/pages/devtools/logs.vue +649 -653
- package/dist/runtime/app/pages/devtools/mail.vue +388 -388
- package/dist/runtime/app/pages/devtools/overview.vue +391 -389
- package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
- package/dist/runtime/app/pages/devtools/security.vue +20 -5
- package/dist/runtime/app/pages/devtools/settings.vue +559 -559
- package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
- package/dist/runtime/app/pages/devtools.vue +176 -176
- package/dist/runtime/app/plugins/seo.mjs +1 -1
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
- package/dist/runtime/app/public/sw-notifications.mjs +47 -52
- package/dist/runtime/blob.mjs +11 -4
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.mjs +12 -2
- package/dist/runtime/cache.d.ts +2 -1
- package/dist/runtime/kv.mjs +4 -1
- package/dist/runtime/providers/qarpeo.d.ts +3 -3
- package/dist/runtime/server/durable-objects/agent.mjs +1 -1
- package/dist/runtime/server/durable-objects/room.d.ts +2 -2
- package/dist/runtime/server/durable-objects/room.mjs +5 -5
- package/dist/runtime/server/middleware/devtools.mjs +6 -2
- package/dist/runtime/server/plugins/cms.d.ts +4 -2
- package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
- package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
- package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
- package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/handler.mjs +6 -1
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
- package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
- package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
- package/dist/runtime/server/routes/fate.mjs +5 -8
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
- package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
- package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
- package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
- package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
- package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
- package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
- package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
- package/dist/runtime/server/utils/ai.d.ts +9 -9
- package/dist/runtime/server/utils/ai.mjs +3 -3
- package/dist/runtime/server/utils/auth.d.ts +12 -16
- package/dist/runtime/server/utils/auth.mjs +15 -9
- package/dist/runtime/server/utils/bots.mjs +21 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
- package/dist/runtime/server/utils/browser-utils.mjs +14 -4
- package/dist/runtime/server/utils/cache.d.ts +5 -5
- package/dist/runtime/server/utils/cms/common.d.ts +26 -0
- package/dist/runtime/server/utils/cms/common.mjs +68 -0
- package/dist/runtime/server/utils/cms/git.d.ts +24 -0
- package/dist/runtime/server/utils/cms/git.mjs +240 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
- package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
- package/dist/runtime/server/utils/cms/path.d.ts +51 -0
- package/dist/runtime/server/utils/cms/path.mjs +127 -0
- package/dist/runtime/server/utils/cms/search.d.ts +22 -0
- package/dist/runtime/server/utils/cms/search.mjs +221 -0
- package/dist/runtime/server/utils/cms-events.d.ts +1 -1
- package/dist/runtime/server/utils/cms-events.mjs +2 -2
- package/dist/runtime/server/utils/cms-filter.mjs +2 -2
- package/dist/runtime/server/utils/cms.d.ts +17 -149
- package/dist/runtime/server/utils/cms.mjs +52 -761
- package/dist/runtime/server/utils/config.d.ts +5 -4
- package/dist/runtime/server/utils/domains.mjs +7 -4
- package/dist/runtime/server/utils/email-templates.d.ts +10 -7
- package/dist/runtime/server/utils/email-templates.mjs +20 -5
- package/dist/runtime/server/utils/feed.d.ts +2 -2
- package/dist/runtime/server/utils/feed.mjs +3 -1
- package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
- package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
- package/dist/runtime/server/utils/mail.d.ts +7 -8
- package/dist/runtime/server/utils/mail.mjs +17 -12
- package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
- package/dist/runtime/server/utils/notifications.d.ts +9 -23
- package/dist/runtime/server/utils/organization.mjs +4 -12
- package/dist/runtime/server/utils/passwordless.mjs +1 -1
- package/dist/runtime/server/utils/payments.d.ts +2 -6
- package/dist/runtime/server/utils/payments.mjs +1 -1
- package/dist/runtime/server/utils/queue.d.ts +21 -31
- package/dist/runtime/server/utils/rag.d.ts +4 -4
- package/dist/runtime/server/utils/rag.mjs +8 -8
- package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
- package/dist/runtime/server/utils/realtime.d.ts +26 -28
- package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
- package/dist/runtime/server/utils/security-store.d.ts +2 -2
- package/dist/runtime/server/utils/session.d.ts +9 -11
- package/dist/runtime/server/utils/sso.d.ts +9 -15
- package/dist/runtime/server/utils/sso.mjs +4 -8
- package/dist/runtime/server/utils/storage.d.ts +19 -2
- package/dist/runtime/server/utils/storage.mjs +36 -7
- package/dist/runtime/server/utils/tenant.mjs +3 -1
- package/dist/runtime/server/utils/turnstile.d.ts +3 -5
- package/dist/runtime/server/utils/vapid.d.ts +5 -8
- package/dist/runtime/server/utils/vapid.mjs +26 -13
- package/dist/runtime/service.d.ts +13 -13
- package/dist/runtime/service.mjs +4 -2
- package/dist/runtime/test-utils.d.ts +20 -30
- package/dist/runtime/test-utils.mjs +5 -4
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +82 -82
- package/dist/runtime/types/index.d.ts +2 -2
- package/dist/runtime/types/r2.d.ts +5 -0
- package/dist/runtime/types/service.d.ts +11 -18
- package/dist/types.d.ts +100 -107
- package/dist/utils/auth-schema.d.ts +2 -2
- package/dist/utils/cms-sources.d.ts +3 -3
- package/dist/utils/local-db.d.ts +3 -3
- package/dist/utils/notifications-schema.d.ts +1 -3
- package/dist/utils/pkg.d.ts +7 -0
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/tasks.d.ts +3 -2
- package/package.json +11 -8
|
@@ -1,653 +1,649 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, onMounted, onUnmounted, ref } from "vue"
|
|
3
|
-
|
|
4
|
-
interface LogEntry {
|
|
5
|
-
id: string
|
|
6
|
-
timestamp: string
|
|
7
|
-
level: "info" | "warn" | "error"
|
|
8
|
-
source: string
|
|
9
|
-
message: string
|
|
10
|
-
durationMs?: number
|
|
11
|
-
status?: number
|
|
12
|
-
details?: Record<string, any>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const logs = ref<LogEntry[]>([])
|
|
16
|
-
const logsLoading = ref(false)
|
|
17
|
-
const initialLoading = ref(true)
|
|
18
|
-
const logLevel = ref<"all" | "info" | "warn" | "error">("all")
|
|
19
|
-
const logSearch = ref<string>("")
|
|
20
|
-
const selectedSource = ref<string>("all")
|
|
21
|
-
const isLive = ref(true)
|
|
22
|
-
const autoScroll = ref(true)
|
|
23
|
-
const expandedLogId = ref<string | null>(null)
|
|
24
|
-
const logContainerRef = ref<HTMLElement | null>(null)
|
|
25
|
-
|
|
26
|
-
let pollTimer: any = null
|
|
27
|
-
|
|
28
|
-
function fmtTime(iso?: string) {
|
|
29
|
-
if (!iso) return "—"
|
|
30
|
-
const d = new Date(iso)
|
|
31
|
-
return d.toLocaleTimeString([], {
|
|
32
|
-
hour: "2-digit",
|
|
33
|
-
minute: "2-digit",
|
|
34
|
-
second: "2-digit",
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function fmtFullDate(iso?: string) {
|
|
39
|
-
if (!iso) return "—"
|
|
40
|
-
return new Date(iso).toLocaleString()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getLogLevelBadgeColor(level?: string): "error" | "warning" | "neutral" {
|
|
44
|
-
if (level === "error") return "error"
|
|
45
|
-
if (level === "warn") return "warning"
|
|
46
|
-
return "neutral"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getStatusBadgeColor(status?: number): "success" | "warning" | "error" | "neutral" {
|
|
50
|
-
if (!status) return "neutral"
|
|
51
|
-
if (status >= 200 && status < 300) return "success"
|
|
52
|
-
if (status >= 400 && status < 500) return "warning"
|
|
53
|
-
if (status >= 500) return "error"
|
|
54
|
-
return "neutral"
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const availableSources = computed(() => {
|
|
58
|
-
const set = new Set<string>()
|
|
59
|
-
for (const l of logs.value) {
|
|
60
|
-
if (l.source) set.add(l.source)
|
|
61
|
-
}
|
|
62
|
-
return ["all", ...Array.from(set)]
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const counts = computed(() => {
|
|
66
|
-
const res = { all: logs.value.length, info: 0, warn: 0, error: 0 }
|
|
67
|
-
for (const l of logs.value) {
|
|
68
|
-
if (l.level === "info") res.info++
|
|
69
|
-
if (l.level === "warn") res.warn++
|
|
70
|
-
if (l.level === "error") res.error++
|
|
71
|
-
}
|
|
72
|
-
return res
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const filteredLogs = computed(() => {
|
|
76
|
-
let list = logs.value
|
|
77
|
-
|
|
78
|
-
if (logLevel.value !== "all") {
|
|
79
|
-
list = list.filter((l) => l.level === logLevel.value)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (selectedSource.value !== "all") {
|
|
83
|
-
list = list.filter((l) => l.source === selectedSource.value)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (logSearch.value.trim()) {
|
|
87
|
-
const q = logSearch.value.toLowerCase()
|
|
88
|
-
list = list.filter(
|
|
89
|
-
(l) =>
|
|
90
|
-
l.message.toLowerCase().includes(q) ||
|
|
91
|
-
l.source.toLowerCase().includes(q) ||
|
|
92
|
-
String(l.status || "").includes(q),
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return list
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
function scrollToBottom() {
|
|
100
|
-
if (!autoScroll.value) return
|
|
101
|
-
nextTick(() => {
|
|
102
|
-
if (logContainerRef.value) {
|
|
103
|
-
logContainerRef.value.scrollTop = logContainerRef.value.scrollHeight
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function loadLogs(isInitial = false) {
|
|
109
|
-
if (isInitial) logsLoading.value = true
|
|
110
|
-
try {
|
|
111
|
-
const data = await $fetch<any>("/_qarpeo/api/logs").catch(() => ({
|
|
112
|
-
logs: [],
|
|
113
|
-
}))
|
|
114
|
-
const fetched: LogEntry[] = data.logs || []
|
|
115
|
-
if (fetched.length > 0) {
|
|
116
|
-
if (logs.value.length === 0) {
|
|
117
|
-
logs.value = fetched
|
|
118
|
-
scrollToBottom()
|
|
119
|
-
} else {
|
|
120
|
-
const existingIds = new Set(logs.value.map((l) => l.id))
|
|
121
|
-
const newItems = fetched.filter((l) => !existingIds.has(l.id))
|
|
122
|
-
if (newItems.length > 0) {
|
|
123
|
-
logs.value = [...logs.value, ...newItems]
|
|
124
|
-
scrollToBottom()
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
} finally {
|
|
129
|
-
if (isInitial) logsLoading.value = false
|
|
130
|
-
initialLoading.value = false
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function startPolling() {
|
|
135
|
-
stopPolling()
|
|
136
|
-
pollTimer = setInterval(() => {
|
|
137
|
-
if (isLive.value) {
|
|
138
|
-
loadLogs(false)
|
|
139
|
-
}
|
|
140
|
-
}, 2500)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function stopPolling() {
|
|
144
|
-
if (pollTimer) {
|
|
145
|
-
clearInterval(pollTimer)
|
|
146
|
-
pollTimer = null
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function toggleLive() {
|
|
151
|
-
isLive.value = !isLive.value
|
|
152
|
-
if (isLive.value) {
|
|
153
|
-
startPolling()
|
|
154
|
-
} else {
|
|
155
|
-
stopPolling()
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function toggleAutoScroll() {
|
|
160
|
-
autoScroll.value = !autoScroll.value
|
|
161
|
-
if (autoScroll.value) {
|
|
162
|
-
scrollToBottom()
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function clearLogs() {
|
|
167
|
-
logs.value = []
|
|
168
|
-
expandedLogId.value = null
|
|
169
|
-
await $fetch("/_qarpeo/api/logs", { method: "DELETE" }).catch(() => {})
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function copyAllLogs() {
|
|
173
|
-
const text = filteredLogs.value
|
|
174
|
-
.map(
|
|
175
|
-
(l) =>
|
|
176
|
-
`[${l.timestamp}] [${l.level.toUpperCase()}] [${l.source}] ${l.message} ${
|
|
177
|
-
l.durationMs ? `(${l.durationMs}ms)` : ""
|
|
178
|
-
}`,
|
|
179
|
-
)
|
|
180
|
-
.join("\n")
|
|
181
|
-
if (typeof navigator !== "undefined") {
|
|
182
|
-
navigator.clipboard?.writeText(text)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function copyEntry(log: LogEntry) {
|
|
187
|
-
const text = `[${log.timestamp}] [${log.level.toUpperCase()}] [${log.source}] ${log.message}`
|
|
188
|
-
if (typeof navigator !== "undefined") {
|
|
189
|
-
navigator.clipboard?.writeText(text)
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function toggleExpand(id: string) {
|
|
194
|
-
expandedLogId.value = expandedLogId.value === id ? null : id
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async function emitTestLog() {
|
|
198
|
-
const sources = ["qarpeo:router", "qarpeo:d1", "qarpeo:kv", "qarpeo:auth", "qarpeo:blob"]
|
|
199
|
-
const levels: Array<"info" | "warn" | "error"> = ["info", "info", "warn", "error"]
|
|
200
|
-
const randomSource = sources[Math.floor(Math.random() * sources.length)]
|
|
201
|
-
const randomLevel = levels[Math.floor(Math.random() * levels.length)]
|
|
202
|
-
|
|
203
|
-
const sampleMessages: Record<string, string[]> = {
|
|
204
|
-
"qarpeo:router": [
|
|
205
|
-
"GET /api/user - 200 OK (Edge Cache HIT)",
|
|
206
|
-
"POST /api/auth/login - 200 OK (Session Issued)",
|
|
207
|
-
"GET /images/banner.webp - 304 Not Modified",
|
|
208
|
-
],
|
|
209
|
-
"qarpeo:d1": [
|
|
210
|
-
"Executed prepared statement: SELECT * FROM users WHERE active = 1 LIMIT 50",
|
|
211
|
-
"D1 transaction committed in 4.2ms",
|
|
212
|
-
],
|
|
213
|
-
"qarpeo:kv": [
|
|
214
|
-
"KV Namespace get: key=cache:page_home (HIT)",
|
|
215
|
-
"KV Namespace put: key=rate_limit:ip_102 ttl=60",
|
|
216
|
-
],
|
|
217
|
-
"qarpeo:auth": [
|
|
218
|
-
"WebAuthn Passkey verification completed successfully",
|
|
219
|
-
"Issued JWT session token for user usr_4982",
|
|
220
|
-
],
|
|
221
|
-
"qarpeo:blob": [
|
|
222
|
-
"R2 object uploaded: uploads/photo.jpg (128 KB)",
|
|
223
|
-
"Presigned upload ticket generated for key: avatar.png",
|
|
224
|
-
],
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const msgs = sampleMessages[randomSource] || ["Standard edge runtime operation"]
|
|
228
|
-
const randomMsg = msgs[Math.floor(Math.random() * msgs.length)]
|
|
229
|
-
const durationMs = +(Math.random() * 8 + 0.5).toFixed(1)
|
|
230
|
-
const status = randomLevel === "error" ? 500 : randomLevel === "warn" ? 429 : 200
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const res = await $fetch<any>("/_qarpeo/api/logs", {
|
|
234
|
-
method: "POST",
|
|
235
|
-
body: {
|
|
236
|
-
level: randomLevel,
|
|
237
|
-
source: randomSource,
|
|
238
|
-
message: randomMsg,
|
|
239
|
-
durationMs,
|
|
240
|
-
status,
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
if (res?.log) {
|
|
244
|
-
logs.value.push(res.log)
|
|
245
|
-
scrollToBottom()
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
} catch {}
|
|
249
|
-
|
|
250
|
-
const newLog: LogEntry = {
|
|
251
|
-
id: `log_${Date.now()}_${Math.random().toString(36).substring(2, 6)}`,
|
|
252
|
-
timestamp: new Date().toISOString(),
|
|
253
|
-
level: randomLevel,
|
|
254
|
-
source: randomSource,
|
|
255
|
-
message: randomMsg,
|
|
256
|
-
durationMs,
|
|
257
|
-
status,
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
logs.value.push(newLog)
|
|
261
|
-
scrollToBottom()
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
onMounted(() => {
|
|
265
|
-
loadLogs(true)
|
|
266
|
-
if (isLive.value) {
|
|
267
|
-
startPolling()
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
onUnmounted(() => {
|
|
272
|
-
stopPolling()
|
|
273
|
-
})
|
|
274
|
-
</script>
|
|
275
|
-
|
|
276
|
-
<template>
|
|
277
|
-
<UDashboardPanel id="devtools-logs" :ui="{ body: 'p-0 sm:p-0' }">
|
|
278
|
-
<template #header>
|
|
279
|
-
<UDashboardNavbar>
|
|
280
|
-
<template #title>
|
|
281
|
-
<div class="flex items-center gap-2.5">
|
|
282
|
-
<div class="relative flex items-center justify-center">
|
|
283
|
-
<UIcon name="i-lucide-terminal" class="w-4 h-4 text-primary" />
|
|
284
|
-
<span
|
|
285
|
-
class="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full"
|
|
286
|
-
:class="isLive ? 'bg-success animate-pulse' : 'bg-muted'"
|
|
287
|
-
></span>
|
|
288
|
-
</div>
|
|
289
|
-
<span class="font-bold text-sm text-highlighted">Tail Logs</span>
|
|
290
|
-
<UBadge size="xs" :color="isLive ? 'success' : 'neutral'" variant="subtle">
|
|
291
|
-
{{ isLive ? "Live" : "Paused" }}
|
|
292
|
-
</UBadge>
|
|
293
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
294
|
-
{{ filteredLogs.length }}
|
|
295
|
-
</UBadge>
|
|
296
|
-
</div>
|
|
297
|
-
</template>
|
|
298
|
-
|
|
299
|
-
<template #right>
|
|
300
|
-
<div class="flex items-center gap-1.5">
|
|
301
|
-
<!-- Live Tail Toggle -->
|
|
302
|
-
<UButton
|
|
303
|
-
:label="isLive ? 'Live Tail' : 'Paused'"
|
|
304
|
-
:icon="isLive ? 'i-lucide-pause' : 'i-lucide-play'"
|
|
305
|
-
size="xs"
|
|
306
|
-
:color="isLive ? 'success' : 'neutral'"
|
|
307
|
-
:variant="isLive ? 'subtle' : 'ghost'"
|
|
308
|
-
title="Toggle Live Polling"
|
|
309
|
-
@click="toggleLive"
|
|
310
|
-
/>
|
|
311
|
-
|
|
312
|
-
<!-- Auto Scroll Toggle -->
|
|
313
|
-
<UButton
|
|
314
|
-
icon="i-lucide-arrow-down-to-line"
|
|
315
|
-
size="xs"
|
|
316
|
-
:color="autoScroll ? 'primary' : 'neutral'"
|
|
317
|
-
:variant="autoScroll ? 'subtle' : 'ghost'"
|
|
318
|
-
title="Auto-scroll to latest"
|
|
319
|
-
@click="toggleAutoScroll"
|
|
320
|
-
/>
|
|
321
|
-
|
|
322
|
-
<!-- Emit Test Log -->
|
|
323
|
-
<UButton
|
|
324
|
-
icon="i-lucide-plus"
|
|
325
|
-
size="xs"
|
|
326
|
-
color="neutral"
|
|
327
|
-
variant="ghost"
|
|
328
|
-
title="Simulate / Emit test log"
|
|
329
|
-
@click="emitTestLog"
|
|
330
|
-
/>
|
|
331
|
-
|
|
332
|
-
<!-- Copy All -->
|
|
333
|
-
<UButton
|
|
334
|
-
icon="i-lucide-copy"
|
|
335
|
-
size="xs"
|
|
336
|
-
color="neutral"
|
|
337
|
-
variant="ghost"
|
|
338
|
-
title="Copy visible logs"
|
|
339
|
-
@click="copyAllLogs"
|
|
340
|
-
/>
|
|
341
|
-
|
|
342
|
-
<!-- Clear -->
|
|
343
|
-
<UButton
|
|
344
|
-
icon="i-lucide-trash"
|
|
345
|
-
size="xs"
|
|
346
|
-
color="neutral"
|
|
347
|
-
variant="ghost"
|
|
348
|
-
title="Clear logs"
|
|
349
|
-
@click="clearLogs"
|
|
350
|
-
/>
|
|
351
|
-
|
|
352
|
-
<!-- Refresh -->
|
|
353
|
-
<UButton
|
|
354
|
-
icon="i-lucide-refresh-cw"
|
|
355
|
-
size="xs"
|
|
356
|
-
color="neutral"
|
|
357
|
-
variant="ghost"
|
|
358
|
-
title="Refresh logs"
|
|
359
|
-
:loading="logsLoading"
|
|
360
|
-
@click="loadLogs(true)"
|
|
361
|
-
/>
|
|
362
|
-
</div>
|
|
363
|
-
</template>
|
|
364
|
-
</UDashboardNavbar>
|
|
365
|
-
|
|
366
|
-
<!-- Filter Toolbar -->
|
|
367
|
-
<UDashboardToolbar>
|
|
368
|
-
<div class="flex items-center justify-between w-full flex-wrap gap-2 py-1">
|
|
369
|
-
<!-- Log Level Filter Segmented Buttons -->
|
|
370
|
-
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
371
|
-
<UButton
|
|
372
|
-
label="All"
|
|
373
|
-
size="xs"
|
|
374
|
-
:color="logLevel === 'all' ? 'primary' : 'neutral'"
|
|
375
|
-
:variant="logLevel === 'all' ? 'subtle' : 'ghost'"
|
|
376
|
-
@click="logLevel = 'all'"
|
|
377
|
-
>
|
|
378
|
-
<template #trailing>
|
|
379
|
-
<UBadge
|
|
380
|
-
size="xs"
|
|
381
|
-
:color="logLevel === 'all' ? 'primary' : 'neutral'"
|
|
382
|
-
variant="subtle"
|
|
383
|
-
>
|
|
384
|
-
{{ counts.all }}
|
|
385
|
-
</UBadge>
|
|
386
|
-
</template>
|
|
387
|
-
</UButton>
|
|
388
|
-
|
|
389
|
-
<UButton
|
|
390
|
-
label="Info"
|
|
391
|
-
size="xs"
|
|
392
|
-
:color="logLevel === 'info' ? 'primary' : 'neutral'"
|
|
393
|
-
:variant="logLevel === 'info' ? 'subtle' : 'ghost'"
|
|
394
|
-
@click="logLevel = 'info'"
|
|
395
|
-
>
|
|
396
|
-
<template #trailing>
|
|
397
|
-
<UBadge
|
|
398
|
-
size="xs"
|
|
399
|
-
:color="logLevel === 'info' ? 'primary' : 'neutral'"
|
|
400
|
-
variant="subtle"
|
|
401
|
-
>
|
|
402
|
-
{{ counts.info }}
|
|
403
|
-
</UBadge>
|
|
404
|
-
</template>
|
|
405
|
-
</UButton>
|
|
406
|
-
|
|
407
|
-
<UButton
|
|
408
|
-
label="Warn"
|
|
409
|
-
size="xs"
|
|
410
|
-
:color="logLevel === 'warn' ? 'warning' : 'neutral'"
|
|
411
|
-
:variant="logLevel === 'warn' ? 'subtle' : 'ghost'"
|
|
412
|
-
@click="logLevel = 'warn'"
|
|
413
|
-
>
|
|
414
|
-
<template #trailing>
|
|
415
|
-
<UBadge
|
|
416
|
-
size="xs"
|
|
417
|
-
:color="logLevel === 'warn' ? 'warning' : 'neutral'"
|
|
418
|
-
variant="subtle"
|
|
419
|
-
>
|
|
420
|
-
{{ counts.warn }}
|
|
421
|
-
</UBadge>
|
|
422
|
-
</template>
|
|
423
|
-
</UButton>
|
|
424
|
-
|
|
425
|
-
<UButton
|
|
426
|
-
label="Error"
|
|
427
|
-
size="xs"
|
|
428
|
-
:color="logLevel === 'error' ? 'error' : 'neutral'"
|
|
429
|
-
:variant="logLevel === 'error' ? 'subtle' : 'ghost'"
|
|
430
|
-
@click="logLevel = 'error'"
|
|
431
|
-
>
|
|
432
|
-
<template #trailing>
|
|
433
|
-
<UBadge
|
|
434
|
-
size="xs"
|
|
435
|
-
:color="logLevel === 'error' ? 'error' : 'neutral'"
|
|
436
|
-
variant="subtle"
|
|
437
|
-
>
|
|
438
|
-
{{ counts.error }}
|
|
439
|
-
</UBadge>
|
|
440
|
-
</template>
|
|
441
|
-
</UButton>
|
|
442
|
-
</div>
|
|
443
|
-
|
|
444
|
-
<!-- Search & Source Filter -->
|
|
445
|
-
<div class="flex items-center gap-2 flex-1 max-w-lg">
|
|
446
|
-
<USelect
|
|
447
|
-
v-model="selectedSource"
|
|
448
|
-
:items="availableSources"
|
|
449
|
-
size="xs"
|
|
450
|
-
class="w-36 shrink-0"
|
|
451
|
-
/>
|
|
452
|
-
<UInput
|
|
453
|
-
v-model="logSearch"
|
|
454
|
-
icon="i-lucide-search"
|
|
455
|
-
placeholder="Search log messages, sources, status codes…"
|
|
456
|
-
class="w-full"
|
|
457
|
-
/>
|
|
458
|
-
</div>
|
|
459
|
-
</div>
|
|
460
|
-
</UDashboardToolbar>
|
|
461
|
-
</template>
|
|
462
|
-
|
|
463
|
-
<template #body>
|
|
464
|
-
<div class="flex flex-col h-full overflow-hidden p-4 space-y-2">
|
|
465
|
-
<!-- Terminal Logs Window -->
|
|
466
|
-
<div
|
|
467
|
-
ref="logContainerRef"
|
|
468
|
-
class="flex-1 min-h-0 bg-slate-950 text-slate-100 border border-slate-800 rounded-lg p-3 overflow-y-auto font-mono text-xs select-text shadow-inner space-y-1"
|
|
469
|
-
>
|
|
470
|
-
<!-- Skeleton: Initial Loading -->
|
|
471
|
-
<template v-if="initialLoading">
|
|
472
|
-
<div
|
|
473
|
-
v-for="i in 12"
|
|
474
|
-
:key="`skel-${i}`"
|
|
475
|
-
class="flex items-center gap-2.5 py-1 px-1.5 animate-pulse"
|
|
476
|
-
>
|
|
477
|
-
<!-- chevron placeholder -->
|
|
478
|
-
<div class="w-3.5 h-3.5 rounded bg-slate-800 shrink-0" />
|
|
479
|
-
<!-- timestamp -->
|
|
480
|
-
<div class="w-14 h-3 rounded bg-slate-800 shrink-0" />
|
|
481
|
-
<!-- level badge -->
|
|
482
|
-
<div class="w-10 h-4 rounded bg-slate-800 shrink-0" />
|
|
483
|
-
<!-- source tag -->
|
|
484
|
-
<div class="w-24 h-3 rounded bg-slate-800 shrink-0" />
|
|
485
|
-
<!-- message bar (varying widths) -->
|
|
486
|
-
<div
|
|
487
|
-
class="h-3 rounded bg-slate-800 flex-1"
|
|
488
|
-
:style="{ width: `${40 + ((i * 13) % 50)}%` }"
|
|
489
|
-
/>
|
|
490
|
-
<!-- duration -->
|
|
491
|
-
<div class="w-8 h-3 rounded bg-slate-800 shrink-0" />
|
|
492
|
-
</div>
|
|
493
|
-
</template>
|
|
494
|
-
<div
|
|
495
|
-
v-if="!initialLoading"
|
|
496
|
-
v-for="log in filteredLogs"
|
|
497
|
-
:key="log.id"
|
|
498
|
-
class="group rounded transition-colors"
|
|
499
|
-
:class="
|
|
500
|
-
expandedLogId === log.id
|
|
501
|
-
? 'bg-slate-900 border border-slate-800 p-2 my-1'
|
|
502
|
-
: 'hover:bg-slate-900/70 py-1 px-1.5'
|
|
503
|
-
"
|
|
504
|
-
>
|
|
505
|
-
<!-- Log Main Line -->
|
|
506
|
-
<div class="flex items-start gap-2.5 leading-relaxed">
|
|
507
|
-
<!-- Expand toggle -->
|
|
508
|
-
<UButton
|
|
509
|
-
type="button"
|
|
510
|
-
:icon="
|
|
511
|
-
expandedLogId === log.id ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'
|
|
512
|
-
"
|
|
513
|
-
color="neutral"
|
|
514
|
-
variant="ghost"
|
|
515
|
-
size="xs"
|
|
516
|
-
title="Toggle details"
|
|
517
|
-
class="text-slate-500 hover:text-slate-300 mt-0.5 shrink-0"
|
|
518
|
-
@click="toggleExpand(log.id)"
|
|
519
|
-
/>
|
|
520
|
-
|
|
521
|
-
<!-- Timestamp -->
|
|
522
|
-
<span
|
|
523
|
-
class="text-slate-400 text-[11px] whitespace-nowrap select-none"
|
|
524
|
-
:title="fmtFullDate(log.timestamp)"
|
|
525
|
-
>
|
|
526
|
-
{{ fmtTime(log.timestamp) }}
|
|
527
|
-
</span>
|
|
528
|
-
|
|
529
|
-
<!-- Level Badge -->
|
|
530
|
-
<UBadge
|
|
531
|
-
size="xs"
|
|
532
|
-
:color="getLogLevelBadgeColor(log.level)"
|
|
533
|
-
variant="subtle"
|
|
534
|
-
class="uppercase text-[9px] px-1.5 py-0 select-none shrink-0"
|
|
535
|
-
>
|
|
536
|
-
{{ log.level }}
|
|
537
|
-
</UBadge>
|
|
538
|
-
|
|
539
|
-
<!-- Source Tag -->
|
|
540
|
-
<span class="text-sky-400 font-semibold shrink-0 select-none"
|
|
541
|
-
>[{{ log.source }}]</span
|
|
542
|
-
>
|
|
543
|
-
|
|
544
|
-
<!-- Status Code Badge (if present) -->
|
|
545
|
-
<UBadge
|
|
546
|
-
v-if="log.status"
|
|
547
|
-
size="xs"
|
|
548
|
-
:color="getStatusBadgeColor(log.status)"
|
|
549
|
-
variant="subtle"
|
|
550
|
-
class="font-mono text-[10px] px-1 py-0 select-none shrink-0"
|
|
551
|
-
>
|
|
552
|
-
{{ log.status }}
|
|
553
|
-
</UBadge>
|
|
554
|
-
|
|
555
|
-
<!-- Message -->
|
|
556
|
-
<span class="text-slate-200 flex-1 break-words">{{ log.message }}</span>
|
|
557
|
-
|
|
558
|
-
<!-- Duration -->
|
|
559
|
-
<span
|
|
560
|
-
v-if="log.durationMs"
|
|
561
|
-
class="text-slate-400 text-[11px] select-none shrink-0 whitespace-nowrap"
|
|
562
|
-
>
|
|
563
|
-
{{ log.durationMs }}ms
|
|
564
|
-
</span>
|
|
565
|
-
|
|
566
|
-
<!-- Hover Copy Button -->
|
|
567
|
-
<UButton
|
|
568
|
-
type="button"
|
|
569
|
-
icon="i-lucide-copy"
|
|
570
|
-
color="neutral"
|
|
571
|
-
variant="ghost"
|
|
572
|
-
size="xs"
|
|
573
|
-
title="Copy log entry"
|
|
574
|
-
class="opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-slate-200 shrink-0"
|
|
575
|
-
@click="copyEntry(log)"
|
|
576
|
-
/>
|
|
577
|
-
</div>
|
|
578
|
-
|
|
579
|
-
<!-- Expanded Details Drawer -->
|
|
580
|
-
<div
|
|
581
|
-
v-if="expandedLogId === log.id"
|
|
582
|
-
class="mt-2 pt-2 border-t border-slate-800 text-[11px] text-slate-300 space-y-2 pl-6"
|
|
583
|
-
>
|
|
584
|
-
<div class="grid grid-cols-2 md:grid-cols-4 gap-2 text-slate-400">
|
|
585
|
-
<div>
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
</div>
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
<span
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
</div>
|
|
651
|
-
</template>
|
|
652
|
-
</UDashboardPanel>
|
|
653
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onMounted, onUnmounted, ref } from "vue"
|
|
3
|
+
|
|
4
|
+
interface LogEntry {
|
|
5
|
+
id: string
|
|
6
|
+
timestamp: string
|
|
7
|
+
level: "info" | "warn" | "error"
|
|
8
|
+
source: string
|
|
9
|
+
message: string
|
|
10
|
+
durationMs?: number
|
|
11
|
+
status?: number
|
|
12
|
+
details?: Record<string, any>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const logs = ref<LogEntry[]>([])
|
|
16
|
+
const logsLoading = ref(false)
|
|
17
|
+
const initialLoading = ref(true)
|
|
18
|
+
const logLevel = ref<"all" | "info" | "warn" | "error">("all")
|
|
19
|
+
const logSearch = ref<string>("")
|
|
20
|
+
const selectedSource = ref<string>("all")
|
|
21
|
+
const isLive = ref(true)
|
|
22
|
+
const autoScroll = ref(true)
|
|
23
|
+
const expandedLogId = ref<string | null>(null)
|
|
24
|
+
const logContainerRef = ref<HTMLElement | null>(null)
|
|
25
|
+
|
|
26
|
+
let pollTimer: any = null
|
|
27
|
+
|
|
28
|
+
function fmtTime(iso?: string) {
|
|
29
|
+
if (!iso) return "—"
|
|
30
|
+
const d = new Date(iso)
|
|
31
|
+
return d.toLocaleTimeString([], {
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit",
|
|
34
|
+
second: "2-digit",
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function fmtFullDate(iso?: string) {
|
|
39
|
+
if (!iso) return "—"
|
|
40
|
+
return new Date(iso).toLocaleString()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getLogLevelBadgeColor(level?: string): "error" | "warning" | "neutral" {
|
|
44
|
+
if (level === "error") return "error"
|
|
45
|
+
if (level === "warn") return "warning"
|
|
46
|
+
return "neutral"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getStatusBadgeColor(status?: number): "success" | "warning" | "error" | "neutral" {
|
|
50
|
+
if (!status) return "neutral"
|
|
51
|
+
if (status >= 200 && status < 300) return "success"
|
|
52
|
+
if (status >= 400 && status < 500) return "warning"
|
|
53
|
+
if (status >= 500) return "error"
|
|
54
|
+
return "neutral"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const availableSources = computed(() => {
|
|
58
|
+
const set = new Set<string>()
|
|
59
|
+
for (const l of logs.value) {
|
|
60
|
+
if (l.source) set.add(l.source)
|
|
61
|
+
}
|
|
62
|
+
return ["all", ...Array.from(set)]
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const counts = computed(() => {
|
|
66
|
+
const res = { all: logs.value.length, info: 0, warn: 0, error: 0 }
|
|
67
|
+
for (const l of logs.value) {
|
|
68
|
+
if (l.level === "info") res.info++
|
|
69
|
+
if (l.level === "warn") res.warn++
|
|
70
|
+
if (l.level === "error") res.error++
|
|
71
|
+
}
|
|
72
|
+
return res
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const filteredLogs = computed(() => {
|
|
76
|
+
let list = logs.value
|
|
77
|
+
|
|
78
|
+
if (logLevel.value !== "all") {
|
|
79
|
+
list = list.filter((l) => l.level === logLevel.value)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (selectedSource.value !== "all") {
|
|
83
|
+
list = list.filter((l) => l.source === selectedSource.value)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (logSearch.value.trim()) {
|
|
87
|
+
const q = logSearch.value.toLowerCase()
|
|
88
|
+
list = list.filter(
|
|
89
|
+
(l) =>
|
|
90
|
+
l.message.toLowerCase().includes(q) ||
|
|
91
|
+
l.source.toLowerCase().includes(q) ||
|
|
92
|
+
String(l.status || "").includes(q),
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return list
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
function scrollToBottom() {
|
|
100
|
+
if (!autoScroll.value) return
|
|
101
|
+
nextTick(() => {
|
|
102
|
+
if (logContainerRef.value) {
|
|
103
|
+
logContainerRef.value.scrollTop = logContainerRef.value.scrollHeight
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function loadLogs(isInitial = false) {
|
|
109
|
+
if (isInitial) logsLoading.value = true
|
|
110
|
+
try {
|
|
111
|
+
const data = await $fetch<any>("/_qarpeo/api/logs").catch(() => ({
|
|
112
|
+
logs: [],
|
|
113
|
+
}))
|
|
114
|
+
const fetched: LogEntry[] = data.logs || []
|
|
115
|
+
if (fetched.length > 0) {
|
|
116
|
+
if (logs.value.length === 0) {
|
|
117
|
+
logs.value = fetched
|
|
118
|
+
scrollToBottom()
|
|
119
|
+
} else {
|
|
120
|
+
const existingIds = new Set(logs.value.map((l) => l.id))
|
|
121
|
+
const newItems = fetched.filter((l) => !existingIds.has(l.id))
|
|
122
|
+
if (newItems.length > 0) {
|
|
123
|
+
logs.value = [...logs.value, ...newItems]
|
|
124
|
+
scrollToBottom()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} finally {
|
|
129
|
+
if (isInitial) logsLoading.value = false
|
|
130
|
+
initialLoading.value = false
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function startPolling() {
|
|
135
|
+
stopPolling()
|
|
136
|
+
pollTimer = setInterval(() => {
|
|
137
|
+
if (isLive.value) {
|
|
138
|
+
loadLogs(false)
|
|
139
|
+
}
|
|
140
|
+
}, 2500)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function stopPolling() {
|
|
144
|
+
if (pollTimer) {
|
|
145
|
+
clearInterval(pollTimer)
|
|
146
|
+
pollTimer = null
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function toggleLive() {
|
|
151
|
+
isLive.value = !isLive.value
|
|
152
|
+
if (isLive.value) {
|
|
153
|
+
startPolling()
|
|
154
|
+
} else {
|
|
155
|
+
stopPolling()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function toggleAutoScroll() {
|
|
160
|
+
autoScroll.value = !autoScroll.value
|
|
161
|
+
if (autoScroll.value) {
|
|
162
|
+
scrollToBottom()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function clearLogs() {
|
|
167
|
+
logs.value = []
|
|
168
|
+
expandedLogId.value = null
|
|
169
|
+
await $fetch("/_qarpeo/api/logs", { method: "DELETE" }).catch(() => {})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function copyAllLogs() {
|
|
173
|
+
const text = filteredLogs.value
|
|
174
|
+
.map(
|
|
175
|
+
(l) =>
|
|
176
|
+
`[${l.timestamp}] [${l.level.toUpperCase()}] [${l.source}] ${l.message} ${
|
|
177
|
+
l.durationMs ? `(${l.durationMs}ms)` : ""
|
|
178
|
+
}`,
|
|
179
|
+
)
|
|
180
|
+
.join("\n")
|
|
181
|
+
if (typeof navigator !== "undefined") {
|
|
182
|
+
navigator.clipboard?.writeText(text)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function copyEntry(log: LogEntry) {
|
|
187
|
+
const text = `[${log.timestamp}] [${log.level.toUpperCase()}] [${log.source}] ${log.message}`
|
|
188
|
+
if (typeof navigator !== "undefined") {
|
|
189
|
+
navigator.clipboard?.writeText(text)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function toggleExpand(id: string) {
|
|
194
|
+
expandedLogId.value = expandedLogId.value === id ? null : id
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function emitTestLog() {
|
|
198
|
+
const sources = ["qarpeo:router", "qarpeo:d1", "qarpeo:kv", "qarpeo:auth", "qarpeo:blob"]
|
|
199
|
+
const levels: Array<"info" | "warn" | "error"> = ["info", "info", "warn", "error"]
|
|
200
|
+
const randomSource = sources[Math.floor(Math.random() * sources.length)]
|
|
201
|
+
const randomLevel = levels[Math.floor(Math.random() * levels.length)]
|
|
202
|
+
|
|
203
|
+
const sampleMessages: Record<string, string[]> = {
|
|
204
|
+
"qarpeo:router": [
|
|
205
|
+
"GET /api/user - 200 OK (Edge Cache HIT)",
|
|
206
|
+
"POST /api/auth/login - 200 OK (Session Issued)",
|
|
207
|
+
"GET /images/banner.webp - 304 Not Modified",
|
|
208
|
+
],
|
|
209
|
+
"qarpeo:d1": [
|
|
210
|
+
"Executed prepared statement: SELECT * FROM users WHERE active = 1 LIMIT 50",
|
|
211
|
+
"D1 transaction committed in 4.2ms",
|
|
212
|
+
],
|
|
213
|
+
"qarpeo:kv": [
|
|
214
|
+
"KV Namespace get: key=cache:page_home (HIT)",
|
|
215
|
+
"KV Namespace put: key=rate_limit:ip_102 ttl=60",
|
|
216
|
+
],
|
|
217
|
+
"qarpeo:auth": [
|
|
218
|
+
"WebAuthn Passkey verification completed successfully",
|
|
219
|
+
"Issued JWT session token for user usr_4982",
|
|
220
|
+
],
|
|
221
|
+
"qarpeo:blob": [
|
|
222
|
+
"R2 object uploaded: uploads/photo.jpg (128 KB)",
|
|
223
|
+
"Presigned upload ticket generated for key: avatar.png",
|
|
224
|
+
],
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const msgs = sampleMessages[randomSource] || ["Standard edge runtime operation"]
|
|
228
|
+
const randomMsg = msgs[Math.floor(Math.random() * msgs.length)]
|
|
229
|
+
const durationMs = +(Math.random() * 8 + 0.5).toFixed(1)
|
|
230
|
+
const status = randomLevel === "error" ? 500 : randomLevel === "warn" ? 429 : 200
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
const res = await $fetch<any>("/_qarpeo/api/logs", {
|
|
234
|
+
method: "POST",
|
|
235
|
+
body: {
|
|
236
|
+
level: randomLevel,
|
|
237
|
+
source: randomSource,
|
|
238
|
+
message: randomMsg,
|
|
239
|
+
durationMs,
|
|
240
|
+
status,
|
|
241
|
+
},
|
|
242
|
+
})
|
|
243
|
+
if (res?.log) {
|
|
244
|
+
logs.value.push(res.log)
|
|
245
|
+
scrollToBottom()
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
} catch {}
|
|
249
|
+
|
|
250
|
+
const newLog: LogEntry = {
|
|
251
|
+
id: `log_${Date.now()}_${Math.random().toString(36).substring(2, 6)}`,
|
|
252
|
+
timestamp: new Date().toISOString(),
|
|
253
|
+
level: randomLevel,
|
|
254
|
+
source: randomSource,
|
|
255
|
+
message: randomMsg,
|
|
256
|
+
durationMs,
|
|
257
|
+
status,
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
logs.value.push(newLog)
|
|
261
|
+
scrollToBottom()
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
onMounted(() => {
|
|
265
|
+
loadLogs(true)
|
|
266
|
+
if (isLive.value) {
|
|
267
|
+
startPolling()
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
onUnmounted(() => {
|
|
272
|
+
stopPolling()
|
|
273
|
+
})
|
|
274
|
+
</script>
|
|
275
|
+
|
|
276
|
+
<template>
|
|
277
|
+
<UDashboardPanel id="devtools-logs" :ui="{ body: 'p-0 sm:p-0' }">
|
|
278
|
+
<template #header>
|
|
279
|
+
<UDashboardNavbar>
|
|
280
|
+
<template #title>
|
|
281
|
+
<div class="flex items-center gap-2.5">
|
|
282
|
+
<div class="relative flex items-center justify-center">
|
|
283
|
+
<UIcon name="i-lucide-terminal" class="w-4 h-4 text-primary" />
|
|
284
|
+
<span
|
|
285
|
+
class="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full"
|
|
286
|
+
:class="isLive ? 'bg-success animate-pulse' : 'bg-muted'"
|
|
287
|
+
></span>
|
|
288
|
+
</div>
|
|
289
|
+
<span class="font-bold text-sm text-highlighted">Tail Logs</span>
|
|
290
|
+
<UBadge size="xs" :color="isLive ? 'success' : 'neutral'" variant="subtle">
|
|
291
|
+
{{ isLive ? "Live" : "Paused" }}
|
|
292
|
+
</UBadge>
|
|
293
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
294
|
+
{{ filteredLogs.length }}
|
|
295
|
+
</UBadge>
|
|
296
|
+
</div>
|
|
297
|
+
</template>
|
|
298
|
+
|
|
299
|
+
<template #right>
|
|
300
|
+
<div class="flex items-center gap-1.5">
|
|
301
|
+
<!-- Live Tail Toggle -->
|
|
302
|
+
<UButton
|
|
303
|
+
:label="isLive ? 'Live Tail' : 'Paused'"
|
|
304
|
+
:icon="isLive ? 'i-lucide-pause' : 'i-lucide-play'"
|
|
305
|
+
size="xs"
|
|
306
|
+
:color="isLive ? 'success' : 'neutral'"
|
|
307
|
+
:variant="isLive ? 'subtle' : 'ghost'"
|
|
308
|
+
title="Toggle Live Polling"
|
|
309
|
+
@click="toggleLive"
|
|
310
|
+
/>
|
|
311
|
+
|
|
312
|
+
<!-- Auto Scroll Toggle -->
|
|
313
|
+
<UButton
|
|
314
|
+
icon="i-lucide-arrow-down-to-line"
|
|
315
|
+
size="xs"
|
|
316
|
+
:color="autoScroll ? 'primary' : 'neutral'"
|
|
317
|
+
:variant="autoScroll ? 'subtle' : 'ghost'"
|
|
318
|
+
title="Auto-scroll to latest"
|
|
319
|
+
@click="toggleAutoScroll"
|
|
320
|
+
/>
|
|
321
|
+
|
|
322
|
+
<!-- Emit Test Log -->
|
|
323
|
+
<UButton
|
|
324
|
+
icon="i-lucide-plus"
|
|
325
|
+
size="xs"
|
|
326
|
+
color="neutral"
|
|
327
|
+
variant="ghost"
|
|
328
|
+
title="Simulate / Emit test log"
|
|
329
|
+
@click="emitTestLog"
|
|
330
|
+
/>
|
|
331
|
+
|
|
332
|
+
<!-- Copy All -->
|
|
333
|
+
<UButton
|
|
334
|
+
icon="i-lucide-copy"
|
|
335
|
+
size="xs"
|
|
336
|
+
color="neutral"
|
|
337
|
+
variant="ghost"
|
|
338
|
+
title="Copy visible logs"
|
|
339
|
+
@click="copyAllLogs"
|
|
340
|
+
/>
|
|
341
|
+
|
|
342
|
+
<!-- Clear -->
|
|
343
|
+
<UButton
|
|
344
|
+
icon="i-lucide-trash"
|
|
345
|
+
size="xs"
|
|
346
|
+
color="neutral"
|
|
347
|
+
variant="ghost"
|
|
348
|
+
title="Clear logs"
|
|
349
|
+
@click="clearLogs"
|
|
350
|
+
/>
|
|
351
|
+
|
|
352
|
+
<!-- Refresh -->
|
|
353
|
+
<UButton
|
|
354
|
+
icon="i-lucide-refresh-cw"
|
|
355
|
+
size="xs"
|
|
356
|
+
color="neutral"
|
|
357
|
+
variant="ghost"
|
|
358
|
+
title="Refresh logs"
|
|
359
|
+
:loading="logsLoading"
|
|
360
|
+
@click="loadLogs(true)"
|
|
361
|
+
/>
|
|
362
|
+
</div>
|
|
363
|
+
</template>
|
|
364
|
+
</UDashboardNavbar>
|
|
365
|
+
|
|
366
|
+
<!-- Filter Toolbar -->
|
|
367
|
+
<UDashboardToolbar>
|
|
368
|
+
<div class="flex items-center justify-between w-full flex-wrap gap-2 py-1">
|
|
369
|
+
<!-- Log Level Filter Segmented Buttons -->
|
|
370
|
+
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
371
|
+
<UButton
|
|
372
|
+
label="All"
|
|
373
|
+
size="xs"
|
|
374
|
+
:color="logLevel === 'all' ? 'primary' : 'neutral'"
|
|
375
|
+
:variant="logLevel === 'all' ? 'subtle' : 'ghost'"
|
|
376
|
+
@click="logLevel = 'all'"
|
|
377
|
+
>
|
|
378
|
+
<template #trailing>
|
|
379
|
+
<UBadge
|
|
380
|
+
size="xs"
|
|
381
|
+
:color="logLevel === 'all' ? 'primary' : 'neutral'"
|
|
382
|
+
variant="subtle"
|
|
383
|
+
>
|
|
384
|
+
{{ counts.all }}
|
|
385
|
+
</UBadge>
|
|
386
|
+
</template>
|
|
387
|
+
</UButton>
|
|
388
|
+
|
|
389
|
+
<UButton
|
|
390
|
+
label="Info"
|
|
391
|
+
size="xs"
|
|
392
|
+
:color="logLevel === 'info' ? 'primary' : 'neutral'"
|
|
393
|
+
:variant="logLevel === 'info' ? 'subtle' : 'ghost'"
|
|
394
|
+
@click="logLevel = 'info'"
|
|
395
|
+
>
|
|
396
|
+
<template #trailing>
|
|
397
|
+
<UBadge
|
|
398
|
+
size="xs"
|
|
399
|
+
:color="logLevel === 'info' ? 'primary' : 'neutral'"
|
|
400
|
+
variant="subtle"
|
|
401
|
+
>
|
|
402
|
+
{{ counts.info }}
|
|
403
|
+
</UBadge>
|
|
404
|
+
</template>
|
|
405
|
+
</UButton>
|
|
406
|
+
|
|
407
|
+
<UButton
|
|
408
|
+
label="Warn"
|
|
409
|
+
size="xs"
|
|
410
|
+
:color="logLevel === 'warn' ? 'warning' : 'neutral'"
|
|
411
|
+
:variant="logLevel === 'warn' ? 'subtle' : 'ghost'"
|
|
412
|
+
@click="logLevel = 'warn'"
|
|
413
|
+
>
|
|
414
|
+
<template #trailing>
|
|
415
|
+
<UBadge
|
|
416
|
+
size="xs"
|
|
417
|
+
:color="logLevel === 'warn' ? 'warning' : 'neutral'"
|
|
418
|
+
variant="subtle"
|
|
419
|
+
>
|
|
420
|
+
{{ counts.warn }}
|
|
421
|
+
</UBadge>
|
|
422
|
+
</template>
|
|
423
|
+
</UButton>
|
|
424
|
+
|
|
425
|
+
<UButton
|
|
426
|
+
label="Error"
|
|
427
|
+
size="xs"
|
|
428
|
+
:color="logLevel === 'error' ? 'error' : 'neutral'"
|
|
429
|
+
:variant="logLevel === 'error' ? 'subtle' : 'ghost'"
|
|
430
|
+
@click="logLevel = 'error'"
|
|
431
|
+
>
|
|
432
|
+
<template #trailing>
|
|
433
|
+
<UBadge
|
|
434
|
+
size="xs"
|
|
435
|
+
:color="logLevel === 'error' ? 'error' : 'neutral'"
|
|
436
|
+
variant="subtle"
|
|
437
|
+
>
|
|
438
|
+
{{ counts.error }}
|
|
439
|
+
</UBadge>
|
|
440
|
+
</template>
|
|
441
|
+
</UButton>
|
|
442
|
+
</div>
|
|
443
|
+
|
|
444
|
+
<!-- Search & Source Filter -->
|
|
445
|
+
<div class="flex items-center gap-2 flex-1 max-w-lg">
|
|
446
|
+
<USelect
|
|
447
|
+
v-model="selectedSource"
|
|
448
|
+
:items="availableSources"
|
|
449
|
+
size="xs"
|
|
450
|
+
class="w-36 shrink-0"
|
|
451
|
+
/>
|
|
452
|
+
<UInput
|
|
453
|
+
v-model="logSearch"
|
|
454
|
+
icon="i-lucide-search"
|
|
455
|
+
placeholder="Search log messages, sources, status codes…"
|
|
456
|
+
class="w-full"
|
|
457
|
+
/>
|
|
458
|
+
</div>
|
|
459
|
+
</div>
|
|
460
|
+
</UDashboardToolbar>
|
|
461
|
+
</template>
|
|
462
|
+
|
|
463
|
+
<template #body>
|
|
464
|
+
<div class="flex flex-col h-full overflow-hidden p-4 space-y-2">
|
|
465
|
+
<!-- Terminal Logs Window -->
|
|
466
|
+
<div
|
|
467
|
+
ref="logContainerRef"
|
|
468
|
+
class="flex-1 min-h-0 bg-slate-950 text-slate-100 border border-slate-800 rounded-lg p-3 overflow-y-auto font-mono text-xs select-text shadow-inner space-y-1"
|
|
469
|
+
>
|
|
470
|
+
<!-- Skeleton: Initial Loading -->
|
|
471
|
+
<template v-if="initialLoading">
|
|
472
|
+
<div
|
|
473
|
+
v-for="i in 12"
|
|
474
|
+
:key="`skel-${i}`"
|
|
475
|
+
class="flex items-center gap-2.5 py-1 px-1.5 animate-pulse"
|
|
476
|
+
>
|
|
477
|
+
<!-- chevron placeholder -->
|
|
478
|
+
<div class="w-3.5 h-3.5 rounded bg-slate-800 shrink-0" />
|
|
479
|
+
<!-- timestamp -->
|
|
480
|
+
<div class="w-14 h-3 rounded bg-slate-800 shrink-0" />
|
|
481
|
+
<!-- level badge -->
|
|
482
|
+
<div class="w-10 h-4 rounded bg-slate-800 shrink-0" />
|
|
483
|
+
<!-- source tag -->
|
|
484
|
+
<div class="w-24 h-3 rounded bg-slate-800 shrink-0" />
|
|
485
|
+
<!-- message bar (varying widths) -->
|
|
486
|
+
<div
|
|
487
|
+
class="h-3 rounded bg-slate-800 flex-1"
|
|
488
|
+
:style="{ width: `${40 + ((i * 13) % 50)}%` }"
|
|
489
|
+
/>
|
|
490
|
+
<!-- duration -->
|
|
491
|
+
<div class="w-8 h-3 rounded bg-slate-800 shrink-0" />
|
|
492
|
+
</div>
|
|
493
|
+
</template>
|
|
494
|
+
<div
|
|
495
|
+
v-if="!initialLoading"
|
|
496
|
+
v-for="log in filteredLogs"
|
|
497
|
+
:key="log.id"
|
|
498
|
+
class="group rounded transition-colors"
|
|
499
|
+
:class="
|
|
500
|
+
expandedLogId === log.id
|
|
501
|
+
? 'bg-slate-900 border border-slate-800 p-2 my-1'
|
|
502
|
+
: 'hover:bg-slate-900/70 py-1 px-1.5'
|
|
503
|
+
"
|
|
504
|
+
>
|
|
505
|
+
<!-- Log Main Line -->
|
|
506
|
+
<div class="flex items-start gap-2.5 leading-relaxed">
|
|
507
|
+
<!-- Expand toggle -->
|
|
508
|
+
<UButton
|
|
509
|
+
type="button"
|
|
510
|
+
:icon="
|
|
511
|
+
expandedLogId === log.id ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'
|
|
512
|
+
"
|
|
513
|
+
color="neutral"
|
|
514
|
+
variant="ghost"
|
|
515
|
+
size="xs"
|
|
516
|
+
title="Toggle details"
|
|
517
|
+
class="text-slate-500 hover:text-slate-300 mt-0.5 shrink-0"
|
|
518
|
+
@click="toggleExpand(log.id)"
|
|
519
|
+
/>
|
|
520
|
+
|
|
521
|
+
<!-- Timestamp -->
|
|
522
|
+
<span
|
|
523
|
+
class="text-slate-400 text-[11px] whitespace-nowrap select-none"
|
|
524
|
+
:title="fmtFullDate(log.timestamp)"
|
|
525
|
+
>
|
|
526
|
+
{{ fmtTime(log.timestamp) }}
|
|
527
|
+
</span>
|
|
528
|
+
|
|
529
|
+
<!-- Level Badge -->
|
|
530
|
+
<UBadge
|
|
531
|
+
size="xs"
|
|
532
|
+
:color="getLogLevelBadgeColor(log.level)"
|
|
533
|
+
variant="subtle"
|
|
534
|
+
class="uppercase text-[9px] px-1.5 py-0 select-none shrink-0"
|
|
535
|
+
>
|
|
536
|
+
{{ log.level }}
|
|
537
|
+
</UBadge>
|
|
538
|
+
|
|
539
|
+
<!-- Source Tag -->
|
|
540
|
+
<span class="text-sky-400 font-semibold shrink-0 select-none"
|
|
541
|
+
>[{{ log.source }}]</span
|
|
542
|
+
>
|
|
543
|
+
|
|
544
|
+
<!-- Status Code Badge (if present) -->
|
|
545
|
+
<UBadge
|
|
546
|
+
v-if="log.status"
|
|
547
|
+
size="xs"
|
|
548
|
+
:color="getStatusBadgeColor(log.status)"
|
|
549
|
+
variant="subtle"
|
|
550
|
+
class="font-mono text-[10px] px-1 py-0 select-none shrink-0"
|
|
551
|
+
>
|
|
552
|
+
{{ log.status }}
|
|
553
|
+
</UBadge>
|
|
554
|
+
|
|
555
|
+
<!-- Message -->
|
|
556
|
+
<span class="text-slate-200 flex-1 break-words">{{ log.message }}</span>
|
|
557
|
+
|
|
558
|
+
<!-- Duration -->
|
|
559
|
+
<span
|
|
560
|
+
v-if="log.durationMs"
|
|
561
|
+
class="text-slate-400 text-[11px] select-none shrink-0 whitespace-nowrap"
|
|
562
|
+
>
|
|
563
|
+
{{ log.durationMs }}ms
|
|
564
|
+
</span>
|
|
565
|
+
|
|
566
|
+
<!-- Hover Copy Button -->
|
|
567
|
+
<UButton
|
|
568
|
+
type="button"
|
|
569
|
+
icon="i-lucide-copy"
|
|
570
|
+
color="neutral"
|
|
571
|
+
variant="ghost"
|
|
572
|
+
size="xs"
|
|
573
|
+
title="Copy log entry"
|
|
574
|
+
class="opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-slate-200 shrink-0"
|
|
575
|
+
@click="copyEntry(log)"
|
|
576
|
+
/>
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
<!-- Expanded Details Drawer -->
|
|
580
|
+
<div
|
|
581
|
+
v-if="expandedLogId === log.id"
|
|
582
|
+
class="mt-2 pt-2 border-t border-slate-800 text-[11px] text-slate-300 space-y-2 pl-6"
|
|
583
|
+
>
|
|
584
|
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-2 text-slate-400">
|
|
585
|
+
<div>ID: <span class="text-slate-200">{{ log.id }}</span></div>
|
|
586
|
+
<div>
|
|
587
|
+
Time:
|
|
588
|
+
<span class="text-slate-200">{{ fmtFullDate(log.timestamp) }}</span>
|
|
589
|
+
</div>
|
|
590
|
+
<div>Source: <span class="text-sky-400">{{ log.source }}</span></div>
|
|
591
|
+
<div>
|
|
592
|
+
Duration:
|
|
593
|
+
<span class="text-slate-200">{{ log.durationMs ?? 0 }} ms</span>
|
|
594
|
+
</div>
|
|
595
|
+
</div>
|
|
596
|
+
|
|
597
|
+
<div>
|
|
598
|
+
<div class="text-slate-400 mb-1">Raw JSON:</div>
|
|
599
|
+
<pre
|
|
600
|
+
class="bg-slate-950 p-2.5 rounded border border-slate-800 text-[11px] text-slate-300 overflow-x-auto whitespace-pre-wrap break-all"
|
|
601
|
+
>{{ JSON.stringify(log, null, 2) }}</pre>
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
</div>
|
|
605
|
+
|
|
606
|
+
<!-- Empty State -->
|
|
607
|
+
<div
|
|
608
|
+
v-if="!initialLoading && !filteredLogs.length && !logsLoading"
|
|
609
|
+
class="text-center py-16 text-slate-400 text-xs space-y-3"
|
|
610
|
+
>
|
|
611
|
+
<UIcon name="i-lucide-terminal" class="w-8 h-8 opacity-40 mx-auto" />
|
|
612
|
+
<div>No logs found matching current filter.</div>
|
|
613
|
+
<UButton
|
|
614
|
+
label="Simulate Log Event"
|
|
615
|
+
icon="i-lucide-plus"
|
|
616
|
+
size="xs"
|
|
617
|
+
color="neutral"
|
|
618
|
+
variant="subtle"
|
|
619
|
+
@click="emitTestLog"
|
|
620
|
+
/>
|
|
621
|
+
</div>
|
|
622
|
+
</div>
|
|
623
|
+
|
|
624
|
+
<!-- Terminal Status Bar -->
|
|
625
|
+
<div
|
|
626
|
+
class="flex items-center justify-between px-3 py-1.5 bg-muted/40 border border-default rounded text-[11px] text-muted font-mono"
|
|
627
|
+
>
|
|
628
|
+
<div class="flex items-center gap-4">
|
|
629
|
+
<span class="flex items-center gap-1.5">
|
|
630
|
+
<span
|
|
631
|
+
class="w-1.5 h-1.5 rounded-full"
|
|
632
|
+
:class="isLive ? 'bg-success' : 'bg-muted'"
|
|
633
|
+
></span>
|
|
634
|
+
{{ isLive ? "Live Stream: Active" : "Live Stream: Paused" }}
|
|
635
|
+
</span>
|
|
636
|
+
<span>Total: {{ logs.length }}</span>
|
|
637
|
+
<span class="text-error">Errors: {{ counts.error }}</span>
|
|
638
|
+
<span class="text-warning">Warnings: {{ counts.warn }}</span>
|
|
639
|
+
</div>
|
|
640
|
+
|
|
641
|
+
<div class="flex items-center gap-3">
|
|
642
|
+
<span>Auto-Scroll: {{ autoScroll ? "ON" : "OFF" }}</span>
|
|
643
|
+
<span>Polling: 2.5s</span>
|
|
644
|
+
</div>
|
|
645
|
+
</div>
|
|
646
|
+
</div>
|
|
647
|
+
</template>
|
|
648
|
+
</UDashboardPanel>
|
|
649
|
+
</template>
|