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,744 +1,743 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
3
|
-
import { computed, onMounted, ref, watch } from "vue"
|
|
4
|
-
|
|
5
|
-
const route = useRoute()
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
data: blobData,
|
|
9
|
-
status: blobStatus,
|
|
10
|
-
pending: blobPending,
|
|
11
|
-
execute: executeLoadBlob,
|
|
12
|
-
} = useFetch<any>("/_qarpeo/api/blob/files", {
|
|
13
|
-
immediate: false,
|
|
14
|
-
lazy: true,
|
|
15
|
-
default: () => ({ files: [] }),
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const blobLoading = computed(
|
|
19
|
-
() => blobPending.value || blobStatus.value === "idle" || blobStatus.value === "pending",
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const blobFiles = computed(() => blobData.value?.files || [])
|
|
23
|
-
const blobSearch = ref("")
|
|
24
|
-
const filterType = ref<"all" | "images" | "documents" | "other">("all")
|
|
25
|
-
const fileInputRef = ref<HTMLInputElement | null>(null)
|
|
26
|
-
const uploadingBlob = ref(false)
|
|
27
|
-
const deletingBlob = ref(false)
|
|
28
|
-
const showDeleteBlobModal = ref(false)
|
|
29
|
-
const isDragging = ref(false)
|
|
30
|
-
const copiedUrl = ref(false)
|
|
31
|
-
const copiedKey = ref(false)
|
|
32
|
-
|
|
33
|
-
const textContent = ref<string | null>(null)
|
|
34
|
-
const textLoading = ref(false)
|
|
35
|
-
const failedImages = ref<Record<string, boolean>>({})
|
|
36
|
-
|
|
37
|
-
function onImageError(key: string) {
|
|
38
|
-
failedImages.value[key] = true
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// selectedKey is derived from / synced to the ?key= query param
|
|
42
|
-
const selectedKey = computed({
|
|
43
|
-
get: () => (route.query.key as string) || null,
|
|
44
|
-
set: (key: string | null) => {
|
|
45
|
-
navigateTo({ query: { ...route.query, key: key ?? undefined } })
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const selectedBlob = computed(
|
|
50
|
-
() => blobFiles.value.find((f) => f.key === selectedKey.value) || null,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
const isSlideoverOpen = computed({
|
|
54
|
-
get: () => Boolean(selectedBlob.value),
|
|
55
|
-
set: (val: boolean) => {
|
|
56
|
-
if (!val) {
|
|
57
|
-
selectedKey.value = null
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
function fmtBytes(bytes: number) {
|
|
63
|
-
if (!bytes) return "0 B"
|
|
64
|
-
if (bytes < 1024) return `${bytes} B`
|
|
65
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
|
|
66
|
-
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function fmtDate(iso?: string) {
|
|
70
|
-
if (!iso) return "—"
|
|
71
|
-
return new Date(iso).toLocaleDateString()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function fmtFullDate(iso?: string) {
|
|
75
|
-
if (!iso) return "—"
|
|
76
|
-
return new Date(iso).toLocaleString()
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function getBlobIcon(contentType?: string): string {
|
|
80
|
-
if (contentType?.startsWith("image/")) return "i-lucide-image"
|
|
81
|
-
if (contentType?.startsWith("audio/")) return "i-lucide-music"
|
|
82
|
-
if (contentType?.startsWith("video/")) return "i-lucide-video"
|
|
83
|
-
if (
|
|
84
|
-
contentType?.includes("pdf") ||
|
|
85
|
-
contentType?.includes("document") ||
|
|
86
|
-
contentType?.includes("sheet")
|
|
87
|
-
) {
|
|
88
|
-
return "i-lucide-file-text"
|
|
89
|
-
}
|
|
90
|
-
if (
|
|
91
|
-
contentType?.includes("json") ||
|
|
92
|
-
contentType?.includes("javascript") ||
|
|
93
|
-
contentType?.includes("text/")
|
|
94
|
-
) {
|
|
95
|
-
return "i-lucide-file-code"
|
|
96
|
-
}
|
|
97
|
-
return "i-lucide-file"
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function isImage(ct?: string) {
|
|
101
|
-
return Boolean(ct?.startsWith("image/"))
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function isAudio(ct?: string) {
|
|
105
|
-
return Boolean(ct?.startsWith("audio/"))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function isVideo(ct?: string) {
|
|
109
|
-
return Boolean(ct?.startsWith("video/"))
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function isTextOrJson(ct?: string) {
|
|
113
|
-
if (!ct) return false
|
|
114
|
-
return ct.startsWith("text/") || ct.includes("json") || ct.includes("javascript")
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const counts = computed(() => {
|
|
118
|
-
let images = 0
|
|
119
|
-
let docs = 0
|
|
120
|
-
let other = 0
|
|
121
|
-
for (const f of blobFiles.value) {
|
|
122
|
-
if (isImage(f.contentType)) {
|
|
123
|
-
images++
|
|
124
|
-
} else if (
|
|
125
|
-
f.contentType?.includes("pdf") ||
|
|
126
|
-
f.contentType?.includes("text/") ||
|
|
127
|
-
f.contentType?.includes("json")
|
|
128
|
-
) {
|
|
129
|
-
docs++
|
|
130
|
-
} else {
|
|
131
|
-
other++
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return { all: blobFiles.value.length, images, docs, other }
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
const filteredFiles = computed(() => {
|
|
138
|
-
let list = blobFiles.value
|
|
139
|
-
|
|
140
|
-
if (filterType.value === "images") {
|
|
141
|
-
list = list.filter((f) => isImage(f.contentType))
|
|
142
|
-
} else if (filterType.value === "documents") {
|
|
143
|
-
list = list.filter(
|
|
144
|
-
(f) =>
|
|
145
|
-
!isImage(f.contentType) &&
|
|
146
|
-
(f.contentType?.includes("pdf") ||
|
|
147
|
-
f.contentType?.includes("text/") ||
|
|
148
|
-
f.contentType?.includes("json")),
|
|
149
|
-
)
|
|
150
|
-
} else if (filterType.value === "other") {
|
|
151
|
-
list = list.filter(
|
|
152
|
-
(f) =>
|
|
153
|
-
!isImage(f.contentType) &&
|
|
154
|
-
!f.contentType?.includes("pdf") &&
|
|
155
|
-
!f.contentType?.includes("text/") &&
|
|
156
|
-
!f.contentType?.includes("json"),
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (blobSearch.value.trim()) {
|
|
161
|
-
const q = blobSearch.value.toLowerCase()
|
|
162
|
-
list = list.filter((f) => f.key.toLowerCase().includes(q))
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return list
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
async function loadBlob() {
|
|
169
|
-
await executeLoadBlob()
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Fetch text preview whenever a text/json file is selected in slideover
|
|
173
|
-
watch(
|
|
174
|
-
selectedKey,
|
|
175
|
-
async (key) => {
|
|
176
|
-
textContent.value = null
|
|
177
|
-
if (!key) return
|
|
178
|
-
const file = blobFiles.value.find((f) => f.key === key)
|
|
179
|
-
if (file && isTextOrJson(file.contentType)) {
|
|
180
|
-
textLoading.value = true
|
|
181
|
-
try {
|
|
182
|
-
textContent.value = await $fetch<string>(`/api/storage/file/${key}`, {
|
|
183
|
-
responseType: "text",
|
|
184
|
-
})
|
|
185
|
-
} catch {
|
|
186
|
-
textContent.value = "(Unable to load preview)"
|
|
187
|
-
} finally {
|
|
188
|
-
textLoading.value = false
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
{ immediate: true },
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
function selectFile(file: any) {
|
|
196
|
-
selectedKey.value = file.key
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async function uploadFileObject(file: File) {
|
|
200
|
-
uploadingBlob.value = true
|
|
201
|
-
try {
|
|
202
|
-
const formData = new FormData()
|
|
203
|
-
formData.append("file", file)
|
|
204
|
-
const uploaded = await $fetch<any>("/api/storage/upload", {
|
|
205
|
-
method: "POST",
|
|
206
|
-
body: formData,
|
|
207
|
-
})
|
|
208
|
-
await loadBlob()
|
|
209
|
-
const newKey = uploaded?.key || uploaded?.files?.[0]?.key || file.name
|
|
210
|
-
selectedKey.value = newKey
|
|
211
|
-
} catch (err) {
|
|
212
|
-
console.error("Upload failed", err)
|
|
213
|
-
} finally {
|
|
214
|
-
uploadingBlob.value = false
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function handleBlobUpload(e: Event) {
|
|
219
|
-
const target = e.target as HTMLInputElement
|
|
220
|
-
const file = target?.files?.[0]
|
|
221
|
-
if (!file) return
|
|
222
|
-
await uploadFileObject(file)
|
|
223
|
-
if (target) target.value = ""
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
async function handleDrop(e: DragEvent) {
|
|
227
|
-
isDragging.value = false
|
|
228
|
-
const files = e.dataTransfer?.files
|
|
229
|
-
if (!files || files.length === 0) return
|
|
230
|
-
for (let i = 0; i < files.length; i++) {
|
|
231
|
-
const file = files[i]
|
|
232
|
-
if (file) {
|
|
233
|
-
await uploadFileObject(file)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async function deleteBlobFile(key?: string) {
|
|
239
|
-
if (!key) return
|
|
240
|
-
deletingBlob.value = true
|
|
241
|
-
try {
|
|
242
|
-
await $fetch(`/api/storage/file/${key}`, {
|
|
243
|
-
method: "DELETE",
|
|
244
|
-
}).catch(() => {})
|
|
245
|
-
showDeleteBlobModal.value = false
|
|
246
|
-
selectedKey.value = null
|
|
247
|
-
await loadBlob()
|
|
248
|
-
} finally {
|
|
249
|
-
deletingBlob.value = false
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function copyBlobUrl(key?: string) {
|
|
254
|
-
if (!key) return
|
|
255
|
-
if (typeof window !== "undefined") {
|
|
256
|
-
const url = `${window.location.origin}/api/storage/file/${key}`
|
|
257
|
-
navigator.clipboard?.writeText(url)
|
|
258
|
-
copiedUrl.value = true
|
|
259
|
-
setTimeout(() => {
|
|
260
|
-
copiedUrl.value = false
|
|
261
|
-
}, 1500)
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function copyBlobKey(key?: string) {
|
|
266
|
-
if (!key) return
|
|
267
|
-
if (typeof navigator !== "undefined") {
|
|
268
|
-
navigator.clipboard?.writeText(key)
|
|
269
|
-
copiedKey.value = true
|
|
270
|
-
setTimeout(() => {
|
|
271
|
-
copiedKey.value = false
|
|
272
|
-
}, 1500)
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
onMounted(() => {
|
|
277
|
-
loadBlob()
|
|
278
|
-
})
|
|
279
|
-
</script>
|
|
280
|
-
|
|
281
|
-
<template>
|
|
282
|
-
<UDashboardPanel id="devtools-blob">
|
|
283
|
-
<template #header>
|
|
284
|
-
<UDashboardNavbar>
|
|
285
|
-
<template #title>
|
|
286
|
-
<div class="flex items-center gap-2">
|
|
287
|
-
<UIcon name="i-lucide-box" class="w-4 h-4 text-primary" />
|
|
288
|
-
<span class="font-bold text-sm text-highlighted">Blob Storage</span>
|
|
289
|
-
<UBadge size="xs" color="neutral" variant="subtle">R2</UBadge>
|
|
290
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
291
|
-
{{ filteredFiles.length }}
|
|
292
|
-
</UBadge>
|
|
293
|
-
</div>
|
|
294
|
-
</template>
|
|
295
|
-
|
|
296
|
-
<template #right>
|
|
297
|
-
<div class="flex items-center gap-1.5">
|
|
298
|
-
<input ref="fileInputRef" type="file" class="hidden" @change="handleBlobUpload" />
|
|
299
|
-
<UButton
|
|
300
|
-
icon="i-lucide-upload"
|
|
301
|
-
label="Upload File"
|
|
302
|
-
size="xs"
|
|
303
|
-
color="primary"
|
|
304
|
-
:loading="uploadingBlob"
|
|
305
|
-
@click="fileInputRef?.click()"
|
|
306
|
-
/>
|
|
307
|
-
<UButton
|
|
308
|
-
icon="i-lucide-refresh-cw"
|
|
309
|
-
size="xs"
|
|
310
|
-
color="neutral"
|
|
311
|
-
variant="ghost"
|
|
312
|
-
title="Refresh files"
|
|
313
|
-
:loading="blobLoading"
|
|
314
|
-
@click="loadBlob"
|
|
315
|
-
/>
|
|
316
|
-
</div>
|
|
317
|
-
</template>
|
|
318
|
-
</UDashboardNavbar>
|
|
319
|
-
|
|
320
|
-
<!-- Media Filter Toolbar -->
|
|
321
|
-
<UDashboardToolbar>
|
|
322
|
-
<!-- Type Filter Segmented Buttons -->
|
|
323
|
-
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
324
|
-
<UButton
|
|
325
|
-
label="All"
|
|
326
|
-
size="xs"
|
|
327
|
-
:color="filterType === 'all' ? 'primary' : 'neutral'"
|
|
328
|
-
:variant="filterType === 'all' ? 'subtle' : 'ghost'"
|
|
329
|
-
@click="filterType = 'all'"
|
|
330
|
-
>
|
|
331
|
-
<template #trailing>
|
|
332
|
-
<UBadge
|
|
333
|
-
size="xs"
|
|
334
|
-
:color="filterType === 'all' ? 'primary' : 'neutral'"
|
|
335
|
-
variant="subtle"
|
|
336
|
-
>
|
|
337
|
-
{{ counts.all }}
|
|
338
|
-
</UBadge>
|
|
339
|
-
</template>
|
|
340
|
-
</UButton>
|
|
341
|
-
|
|
342
|
-
<UButton
|
|
343
|
-
label="Images"
|
|
344
|
-
icon="i-lucide-image"
|
|
345
|
-
size="xs"
|
|
346
|
-
:color="filterType === 'images' ? 'primary' : 'neutral'"
|
|
347
|
-
:variant="filterType === 'images' ? 'subtle' : 'ghost'"
|
|
348
|
-
@click="filterType = 'images'"
|
|
349
|
-
>
|
|
350
|
-
<template #trailing>
|
|
351
|
-
<UBadge
|
|
352
|
-
size="xs"
|
|
353
|
-
:color="filterType === 'images' ? 'primary' : 'neutral'"
|
|
354
|
-
variant="subtle"
|
|
355
|
-
>
|
|
356
|
-
{{ counts.images }}
|
|
357
|
-
</UBadge>
|
|
358
|
-
</template>
|
|
359
|
-
</UButton>
|
|
360
|
-
|
|
361
|
-
<UButton
|
|
362
|
-
label="Documents"
|
|
363
|
-
icon="i-lucide-file-text"
|
|
364
|
-
size="xs"
|
|
365
|
-
:color="filterType === 'documents' ? 'primary' : 'neutral'"
|
|
366
|
-
:variant="filterType === 'documents' ? 'subtle' : 'ghost'"
|
|
367
|
-
@click="filterType = 'documents'"
|
|
368
|
-
>
|
|
369
|
-
<template #trailing>
|
|
370
|
-
<UBadge
|
|
371
|
-
size="xs"
|
|
372
|
-
:color="filterType === 'documents' ? 'primary' : 'neutral'"
|
|
373
|
-
variant="subtle"
|
|
374
|
-
>
|
|
375
|
-
{{ counts.docs }}
|
|
376
|
-
</UBadge>
|
|
377
|
-
</template>
|
|
378
|
-
</UButton>
|
|
379
|
-
|
|
380
|
-
<UButton
|
|
381
|
-
label="Other"
|
|
382
|
-
size="xs"
|
|
383
|
-
:color="filterType === 'other' ? 'primary' : 'neutral'"
|
|
384
|
-
:variant="filterType === 'other' ? 'subtle' : 'ghost'"
|
|
385
|
-
@click="filterType = 'other'"
|
|
386
|
-
>
|
|
387
|
-
<template #trailing>
|
|
388
|
-
<UBadge
|
|
389
|
-
size="xs"
|
|
390
|
-
:color="filterType === 'other' ? 'primary' : 'neutral'"
|
|
391
|
-
variant="subtle"
|
|
392
|
-
>
|
|
393
|
-
{{ counts.other }}
|
|
394
|
-
</UBadge>
|
|
395
|
-
</template>
|
|
396
|
-
</UButton>
|
|
397
|
-
</div>
|
|
398
|
-
|
|
399
|
-
<!-- Search Input -->
|
|
400
|
-
<div class="flex items-center gap-2 max-w-xs flex-1">
|
|
401
|
-
<UInput
|
|
402
|
-
v-model="blobSearch"
|
|
403
|
-
icon="i-lucide-search"
|
|
404
|
-
placeholder="Search files by key…"
|
|
405
|
-
class="w-full"
|
|
406
|
-
/>
|
|
407
|
-
</div>
|
|
408
|
-
</UDashboardToolbar>
|
|
409
|
-
</template>
|
|
410
|
-
|
|
411
|
-
<template #body>
|
|
412
|
-
<div
|
|
413
|
-
class="space-y-4 min-h-[400px]"
|
|
414
|
-
@dragover.prevent="isDragging = true"
|
|
415
|
-
@dragleave.prevent="isDragging = false"
|
|
416
|
-
@drop.prevent="handleDrop"
|
|
417
|
-
>
|
|
418
|
-
<!-- Drag & Drop Active Overlay -->
|
|
419
|
-
<div
|
|
420
|
-
v-if="isDragging"
|
|
421
|
-
class="border-2 border-dashed border-primary rounded-xl p-8 flex flex-col items-center justify-center text-primary bg-primary/10 animate-pulse text-center"
|
|
422
|
-
>
|
|
423
|
-
<UIcon name="i-lucide-upload-cloud" class="w-10 h-10 mb-2" />
|
|
424
|
-
<span class="text-sm font-bold">Drop files here to upload</span>
|
|
425
|
-
<span class="text-xs text-muted"
|
|
426
|
-
>Files will be uploaded directly to Cloudflare R2 storage</span
|
|
427
|
-
>
|
|
428
|
-
</div>
|
|
429
|
-
<!-- Loading Skeleton Grid -->
|
|
430
|
-
<div
|
|
431
|
-
v-if="blobLoading"
|
|
432
|
-
class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4"
|
|
433
|
-
>
|
|
434
|
-
<div
|
|
435
|
-
v-for="i in 12"
|
|
436
|
-
:key="i"
|
|
437
|
-
class="bg-elevated/40 border border-default rounded-xl overflow-hidden flex flex-col animate-pulse"
|
|
438
|
-
>
|
|
439
|
-
<div class="aspect-square bg-muted/60"></div>
|
|
440
|
-
<div class="p-2.5 space-y-2">
|
|
441
|
-
<div class="h-3 w-3/4 rounded bg-muted"></div>
|
|
442
|
-
<div class="h-2 w-1/2 rounded bg-muted"></div>
|
|
443
|
-
</div>
|
|
444
|
-
</div>
|
|
445
|
-
</div>
|
|
446
|
-
|
|
447
|
-
<!-- Visual Media Grid -->
|
|
448
|
-
<div
|
|
449
|
-
v-else-if="filteredFiles.length"
|
|
450
|
-
class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4"
|
|
451
|
-
>
|
|
452
|
-
<div
|
|
453
|
-
v-for="file in filteredFiles"
|
|
454
|
-
:key="file.key"
|
|
455
|
-
class="group relative bg-elevated/40 hover:bg-elevated border border-default hover:border-primary/50 rounded-xl cursor-pointer transition-all duration-200 flex flex-col shadow-xs"
|
|
456
|
-
@click="selectFile(file)"
|
|
457
|
-
>
|
|
458
|
-
<!-- Thumbnail preview area -->
|
|
459
|
-
<div
|
|
460
|
-
class="aspect-square bg-muted/20 flex items-center justify-center border-b border-default relative"
|
|
461
|
-
>
|
|
462
|
-
<img
|
|
463
|
-
v-if="isImage(file.contentType) && !failedImages[file.key]"
|
|
464
|
-
:src="'/api/storage/file/' + file.key"
|
|
465
|
-
:alt="file.key"
|
|
466
|
-
class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
|
|
467
|
-
loading="lazy"
|
|
468
|
-
@error="onImageError(file.key)"
|
|
469
|
-
/>
|
|
470
|
-
<div v-else class="flex flex-col items-center justify-center p-4 text-center">
|
|
471
|
-
<UIcon
|
|
472
|
-
:name="getBlobIcon(file.contentType)"
|
|
473
|
-
class="w-10 h-10 text-primary/70 mb-2 group-hover:scale-110 transition-transform"
|
|
474
|
-
/>
|
|
475
|
-
<span class="text-[10px] font-mono text-muted uppercase">
|
|
476
|
-
{{ file.contentType?.split("/")[1] || "file" }}
|
|
477
|
-
</span>
|
|
478
|
-
</div>
|
|
479
|
-
|
|
480
|
-
<!-- Hover overlay badge -->
|
|
481
|
-
<div
|
|
482
|
-
class="absolute inset-0 bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"
|
|
483
|
-
>
|
|
484
|
-
<UBadge size="xs" color="primary" variant="solid">View Details</UBadge>
|
|
485
|
-
</div>
|
|
486
|
-
</div>
|
|
487
|
-
|
|
488
|
-
<!-- Metadata Caption -->
|
|
489
|
-
<div class="p-2.5 flex flex-col justify-between flex-1">
|
|
490
|
-
<div
|
|
491
|
-
class="font-mono text-xs font-semibold text-highlighted truncate"
|
|
492
|
-
:title="file.key"
|
|
493
|
-
>
|
|
494
|
-
{{ file.key }}
|
|
495
|
-
</div>
|
|
496
|
-
<div class="flex items-center justify-between text-[11px] text-muted mt-1 font-mono">
|
|
497
|
-
<span>{{ fmtBytes(file.size) }}</span>
|
|
498
|
-
<span>{{ fmtDate(file.uploaded) }}</span>
|
|
499
|
-
</div>
|
|
500
|
-
</div>
|
|
501
|
-
</div>
|
|
502
|
-
</div>
|
|
503
|
-
|
|
504
|
-
<!-- Empty State -->
|
|
505
|
-
<div v-else class="flex flex-col items-center justify-center py-20 text-center space-y-3">
|
|
506
|
-
<div
|
|
507
|
-
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary"
|
|
508
|
-
>
|
|
509
|
-
<UIcon name="i-lucide-box" class="w-6 h-6" />
|
|
510
|
-
</div>
|
|
511
|
-
<div class="font-bold text-sm text-highlighted">No files found</div>
|
|
512
|
-
<p class="text-xs text-muted max-w-sm">
|
|
513
|
-
Upload images, documents, or data files to store them directly in your Cloudflare R2
|
|
514
|
-
bucket.
|
|
515
|
-
</p>
|
|
516
|
-
<UButton
|
|
517
|
-
label="Upload First File"
|
|
518
|
-
icon="i-lucide-upload"
|
|
519
|
-
size="sm"
|
|
520
|
-
color="primary"
|
|
521
|
-
@click="fileInputRef?.click()"
|
|
522
|
-
/>
|
|
523
|
-
</div>
|
|
524
|
-
</div>
|
|
525
|
-
</template>
|
|
526
|
-
</UDashboardPanel>
|
|
527
|
-
<!-- ── Right Side Slideover for File Details & Live Preview ─────────── -->
|
|
528
|
-
<USlideover v-model:open="isSlideoverOpen" side="right" :title="selectedBlob?.key">
|
|
529
|
-
<template #title>
|
|
530
|
-
<div class="flex items-center gap-2 min-w-0 pr-4">
|
|
531
|
-
<UIcon
|
|
532
|
-
:name="getBlobIcon(selectedBlob?.contentType)"
|
|
533
|
-
class="w-5 h-5 text-primary shrink-0"
|
|
534
|
-
/>
|
|
535
|
-
<span
|
|
536
|
-
class="font-mono font-bold text-sm text-highlighted truncate"
|
|
537
|
-
:title="selectedBlob?.key"
|
|
538
|
-
>
|
|
539
|
-
{{ selectedBlob?.key }}
|
|
540
|
-
</span>
|
|
541
|
-
</div>
|
|
542
|
-
</template>
|
|
543
|
-
|
|
544
|
-
<template #body>
|
|
545
|
-
<div v-if="selectedBlob" class="space-y-6">
|
|
546
|
-
<!-- Live Media Preview Box -->
|
|
547
|
-
<div
|
|
548
|
-
class="bg-muted/30 border border-default rounded-xl flex items-center justify-center p-4 min-h-[220px]"
|
|
549
|
-
>
|
|
550
|
-
<!-- Image -->
|
|
551
|
-
<div
|
|
552
|
-
v-if="isImage(selectedBlob.contentType)"
|
|
553
|
-
class="w-full flex items-center justify-center"
|
|
554
|
-
>
|
|
555
|
-
<img
|
|
556
|
-
v-if="!failedImages[selectedBlob.key]"
|
|
557
|
-
:src="'/api/storage/file/' + selectedBlob.key"
|
|
558
|
-
:alt="selectedBlob.key"
|
|
559
|
-
class="max-h-[320px] max-w-full object-contain rounded-lg shadow-xs"
|
|
560
|
-
@error="onImageError(selectedBlob.key)"
|
|
561
|
-
/>
|
|
562
|
-
<div v-else class="text-center py-8 text-muted">
|
|
563
|
-
<UIcon name="i-lucide-image" class="w-12 h-12 opacity-40 mx-auto mb-2 text-primary" />
|
|
564
|
-
<div class="text-xs">Preview placeholder</div>
|
|
565
|
-
</div>
|
|
566
|
-
</div>
|
|
567
|
-
|
|
568
|
-
<!-- Audio -->
|
|
569
|
-
<div v-else-if="isAudio(selectedBlob.contentType)" class="w-full p-2 text-center">
|
|
570
|
-
<audio controls :src="'/api/storage/file/' + selectedBlob.key" class="w-full" />
|
|
571
|
-
</div>
|
|
572
|
-
|
|
573
|
-
<!-- Video -->
|
|
574
|
-
<div v-else-if="isVideo(selectedBlob.contentType)" class="w-full text-center">
|
|
575
|
-
<video
|
|
576
|
-
controls
|
|
577
|
-
:src="'/api/storage/file/' + selectedBlob.key"
|
|
578
|
-
class="w-full rounded-lg max-h-[300px]"
|
|
579
|
-
/>
|
|
580
|
-
</div>
|
|
581
|
-
|
|
582
|
-
<!-- Text / Code / JSON -->
|
|
583
|
-
<div v-else-if="isTextOrJson(selectedBlob.contentType)" class="w-full">
|
|
584
|
-
<div v-if="textLoading" class="text-xs text-muted text-center py-8">
|
|
585
|
-
Loading text preview…
|
|
586
|
-
</div>
|
|
587
|
-
<pre
|
|
588
|
-
v-else
|
|
589
|
-
class="font-mono text-xs text-default bg-muted/40 p-3 rounded-md border border-default overflow-auto max-h-[300px] whitespace-pre-wrap break-all"
|
|
590
|
-
>{{ textContent || "(empty file)" }}</pre>
|
|
591
|
-
</div>
|
|
592
|
-
|
|
593
|
-
<!-- Generic Document / File -->
|
|
594
|
-
<div v-else class="text-center py-8 space-y-2 text-muted">
|
|
595
|
-
<UIcon
|
|
596
|
-
:name="getBlobIcon(selectedBlob.contentType)"
|
|
597
|
-
class="w-16 h-16 opacity-40 mx-auto"
|
|
598
|
-
/>
|
|
599
|
-
<div class="text-xs">Preview not supported for this file format</div>
|
|
600
|
-
</div>
|
|
601
|
-
</div>
|
|
602
|
-
|
|
603
|
-
<!-- File Metadata List -->
|
|
604
|
-
<div class="space-y-3">
|
|
605
|
-
<div class="text-xs font-semibold uppercase tracking-wider text-muted">File Metadata</div>
|
|
606
|
-
|
|
607
|
-
<div
|
|
608
|
-
class="divide-y divide-default rounded-lg border border-default bg-elevated/40 text-xs font-mono"
|
|
609
|
-
>
|
|
610
|
-
<div class="flex items-center justify-between p-3">
|
|
611
|
-
<span class="text-muted">Storage Key</span>
|
|
612
|
-
<div class="flex items-center gap-1.5 min-w-0 ml-2">
|
|
613
|
-
<span class="text-highlighted font-bold truncate">{{ selectedBlob.key }}</span>
|
|
614
|
-
<UButton
|
|
615
|
-
type="button"
|
|
616
|
-
:icon="copiedKey ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
617
|
-
:color="copiedKey ? 'success' : 'neutral'"
|
|
618
|
-
variant="ghost"
|
|
619
|
-
size="xs"
|
|
620
|
-
:title="copiedKey ? 'Copied!' : 'Copy key'"
|
|
621
|
-
class="shrink-0"
|
|
622
|
-
@click="copyBlobKey(selectedBlob.key)"
|
|
623
|
-
/>
|
|
624
|
-
</div>
|
|
625
|
-
</div>
|
|
626
|
-
|
|
627
|
-
<div class="flex items-center justify-between p-3">
|
|
628
|
-
<span class="text-muted">Content-Type</span>
|
|
629
|
-
<span class="text-default font-semibold">{{ selectedBlob.contentType }}</span>
|
|
630
|
-
</div>
|
|
631
|
-
|
|
632
|
-
<div class="flex items-center justify-between p-3">
|
|
633
|
-
<span class="text-muted">File Size</span>
|
|
634
|
-
<span class="text-default">{{ fmtBytes(selectedBlob.size) }}</span>
|
|
635
|
-
</div>
|
|
636
|
-
|
|
637
|
-
<div class="flex items-center justify-between p-3">
|
|
638
|
-
<span class="text-muted">Uploaded</span>
|
|
639
|
-
<span class="text-default">{{ fmtFullDate(selectedBlob.uploaded) }}</span>
|
|
640
|
-
</div>
|
|
641
|
-
|
|
642
|
-
<div class="flex items-start justify-between p-3 gap-2">
|
|
643
|
-
<span class="text-muted shrink-0">Public URL</span>
|
|
644
|
-
<div class="flex items-center gap-1.5 min-w-0">
|
|
645
|
-
<span class="text-primary truncate font-mono text-[11px]">
|
|
646
|
-
/api/storage/file/{{ selectedBlob.key }}
|
|
647
|
-
</span>
|
|
648
|
-
<UButton
|
|
649
|
-
type="button"
|
|
650
|
-
:icon="copiedUrl ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
651
|
-
:color="copiedUrl ? 'success' : 'neutral'"
|
|
652
|
-
variant="ghost"
|
|
653
|
-
size="xs"
|
|
654
|
-
:title="copiedUrl ? 'Copied URL!' : 'Copy URL'"
|
|
655
|
-
class="shrink-0"
|
|
656
|
-
@click="copyBlobUrl(selectedBlob.key)"
|
|
657
|
-
/>
|
|
658
|
-
</div>
|
|
659
|
-
</div>
|
|
660
|
-
</div>
|
|
661
|
-
</div>
|
|
662
|
-
</div>
|
|
663
|
-
</template>
|
|
664
|
-
|
|
665
|
-
<template #footer>
|
|
666
|
-
<div v-if="selectedBlob" class="flex items-center justify-between w-full gap-2">
|
|
667
|
-
<div class="flex items-center gap-1.5">
|
|
668
|
-
<UButton
|
|
669
|
-
:label="copiedUrl ? 'Copied!' : 'Copy URL'"
|
|
670
|
-
:icon="copiedUrl ? 'i-lucide-check' : 'i-lucide-link'"
|
|
671
|
-
size="xs"
|
|
672
|
-
:color="copiedUrl ? 'success' : 'neutral'"
|
|
673
|
-
variant="subtle"
|
|
674
|
-
@click="copyBlobUrl(selectedBlob.key)"
|
|
675
|
-
/>
|
|
676
|
-
<UButton
|
|
677
|
-
label="Download"
|
|
678
|
-
icon="i-lucide-download"
|
|
679
|
-
size="xs"
|
|
680
|
-
color="neutral"
|
|
681
|
-
variant="subtle"
|
|
682
|
-
:to="'/api/storage/file/' + selectedBlob.key"
|
|
683
|
-
target="_blank"
|
|
684
|
-
download
|
|
685
|
-
/>
|
|
686
|
-
</div>
|
|
687
|
-
<UButton
|
|
688
|
-
label="Delete"
|
|
689
|
-
icon="i-lucide-trash"
|
|
690
|
-
size="xs"
|
|
691
|
-
color="error"
|
|
692
|
-
variant="subtle"
|
|
693
|
-
@click="showDeleteBlobModal = true"
|
|
694
|
-
/>
|
|
695
|
-
</div>
|
|
696
|
-
</template>
|
|
697
|
-
</USlideover>
|
|
698
|
-
|
|
699
|
-
<!-- Delete File Confirmation Modal -->
|
|
700
|
-
<UModal v-model:open="showDeleteBlobModal" title="Delete Storage File">
|
|
701
|
-
<template #body>
|
|
702
|
-
<div class="space-y-3">
|
|
703
|
-
<p class="text-xs text-default">
|
|
704
|
-
Are you sure you want to permanently delete
|
|
705
|
-
<span class="font-mono font-bold text-highlighted">{{ selectedBlob?.key }}</span
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
<span>
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
<span>
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
3
|
+
import { computed, onMounted, ref, watch } from "vue"
|
|
4
|
+
|
|
5
|
+
const route = useRoute()
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
data: blobData,
|
|
9
|
+
status: blobStatus,
|
|
10
|
+
pending: blobPending,
|
|
11
|
+
execute: executeLoadBlob,
|
|
12
|
+
} = useFetch<any>("/_qarpeo/api/blob/files", {
|
|
13
|
+
immediate: false,
|
|
14
|
+
lazy: true,
|
|
15
|
+
default: () => ({ files: [] }),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const blobLoading = computed(
|
|
19
|
+
() => blobPending.value || blobStatus.value === "idle" || blobStatus.value === "pending",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const blobFiles = computed(() => blobData.value?.files || [])
|
|
23
|
+
const blobSearch = ref("")
|
|
24
|
+
const filterType = ref<"all" | "images" | "documents" | "other">("all")
|
|
25
|
+
const fileInputRef = ref<HTMLInputElement | null>(null)
|
|
26
|
+
const uploadingBlob = ref(false)
|
|
27
|
+
const deletingBlob = ref(false)
|
|
28
|
+
const showDeleteBlobModal = ref(false)
|
|
29
|
+
const isDragging = ref(false)
|
|
30
|
+
const copiedUrl = ref(false)
|
|
31
|
+
const copiedKey = ref(false)
|
|
32
|
+
|
|
33
|
+
const textContent = ref<string | null>(null)
|
|
34
|
+
const textLoading = ref(false)
|
|
35
|
+
const failedImages = ref<Record<string, boolean>>({})
|
|
36
|
+
|
|
37
|
+
function onImageError(key: string) {
|
|
38
|
+
failedImages.value[key] = true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// selectedKey is derived from / synced to the ?key= query param
|
|
42
|
+
const selectedKey = computed({
|
|
43
|
+
get: () => (route.query.key as string) || null,
|
|
44
|
+
set: (key: string | null) => {
|
|
45
|
+
navigateTo({ query: { ...route.query, key: key ?? undefined } })
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const selectedBlob = computed(
|
|
50
|
+
() => blobFiles.value.find((f) => f.key === selectedKey.value) || null,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const isSlideoverOpen = computed({
|
|
54
|
+
get: () => Boolean(selectedBlob.value),
|
|
55
|
+
set: (val: boolean) => {
|
|
56
|
+
if (!val) {
|
|
57
|
+
selectedKey.value = null
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function fmtBytes(bytes: number) {
|
|
63
|
+
if (!bytes) return "0 B"
|
|
64
|
+
if (bytes < 1024) return `${bytes} B`
|
|
65
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
|
|
66
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function fmtDate(iso?: string) {
|
|
70
|
+
if (!iso) return "—"
|
|
71
|
+
return new Date(iso).toLocaleDateString()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function fmtFullDate(iso?: string) {
|
|
75
|
+
if (!iso) return "—"
|
|
76
|
+
return new Date(iso).toLocaleString()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getBlobIcon(contentType?: string): string {
|
|
80
|
+
if (contentType?.startsWith("image/")) return "i-lucide-image"
|
|
81
|
+
if (contentType?.startsWith("audio/")) return "i-lucide-music"
|
|
82
|
+
if (contentType?.startsWith("video/")) return "i-lucide-video"
|
|
83
|
+
if (
|
|
84
|
+
contentType?.includes("pdf") ||
|
|
85
|
+
contentType?.includes("document") ||
|
|
86
|
+
contentType?.includes("sheet")
|
|
87
|
+
) {
|
|
88
|
+
return "i-lucide-file-text"
|
|
89
|
+
}
|
|
90
|
+
if (
|
|
91
|
+
contentType?.includes("json") ||
|
|
92
|
+
contentType?.includes("javascript") ||
|
|
93
|
+
contentType?.includes("text/")
|
|
94
|
+
) {
|
|
95
|
+
return "i-lucide-file-code"
|
|
96
|
+
}
|
|
97
|
+
return "i-lucide-file"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isImage(ct?: string) {
|
|
101
|
+
return Boolean(ct?.startsWith("image/"))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isAudio(ct?: string) {
|
|
105
|
+
return Boolean(ct?.startsWith("audio/"))
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isVideo(ct?: string) {
|
|
109
|
+
return Boolean(ct?.startsWith("video/"))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isTextOrJson(ct?: string) {
|
|
113
|
+
if (!ct) return false
|
|
114
|
+
return ct.startsWith("text/") || ct.includes("json") || ct.includes("javascript")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const counts = computed(() => {
|
|
118
|
+
let images = 0
|
|
119
|
+
let docs = 0
|
|
120
|
+
let other = 0
|
|
121
|
+
for (const f of blobFiles.value) {
|
|
122
|
+
if (isImage(f.contentType)) {
|
|
123
|
+
images++
|
|
124
|
+
} else if (
|
|
125
|
+
f.contentType?.includes("pdf") ||
|
|
126
|
+
f.contentType?.includes("text/") ||
|
|
127
|
+
f.contentType?.includes("json")
|
|
128
|
+
) {
|
|
129
|
+
docs++
|
|
130
|
+
} else {
|
|
131
|
+
other++
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { all: blobFiles.value.length, images, docs, other }
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const filteredFiles = computed(() => {
|
|
138
|
+
let list = blobFiles.value
|
|
139
|
+
|
|
140
|
+
if (filterType.value === "images") {
|
|
141
|
+
list = list.filter((f) => isImage(f.contentType))
|
|
142
|
+
} else if (filterType.value === "documents") {
|
|
143
|
+
list = list.filter(
|
|
144
|
+
(f) =>
|
|
145
|
+
!isImage(f.contentType) &&
|
|
146
|
+
(f.contentType?.includes("pdf") ||
|
|
147
|
+
f.contentType?.includes("text/") ||
|
|
148
|
+
f.contentType?.includes("json")),
|
|
149
|
+
)
|
|
150
|
+
} else if (filterType.value === "other") {
|
|
151
|
+
list = list.filter(
|
|
152
|
+
(f) =>
|
|
153
|
+
!isImage(f.contentType) &&
|
|
154
|
+
!f.contentType?.includes("pdf") &&
|
|
155
|
+
!f.contentType?.includes("text/") &&
|
|
156
|
+
!f.contentType?.includes("json"),
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (blobSearch.value.trim()) {
|
|
161
|
+
const q = blobSearch.value.toLowerCase()
|
|
162
|
+
list = list.filter((f) => f.key.toLowerCase().includes(q))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return list
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
async function loadBlob() {
|
|
169
|
+
await executeLoadBlob()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Fetch text preview whenever a text/json file is selected in slideover
|
|
173
|
+
watch(
|
|
174
|
+
selectedKey,
|
|
175
|
+
async (key) => {
|
|
176
|
+
textContent.value = null
|
|
177
|
+
if (!key) return
|
|
178
|
+
const file = blobFiles.value.find((f) => f.key === key)
|
|
179
|
+
if (file && isTextOrJson(file.contentType)) {
|
|
180
|
+
textLoading.value = true
|
|
181
|
+
try {
|
|
182
|
+
textContent.value = await $fetch<string>(`/api/storage/file/${key}`, {
|
|
183
|
+
responseType: "text",
|
|
184
|
+
})
|
|
185
|
+
} catch {
|
|
186
|
+
textContent.value = "(Unable to load preview)"
|
|
187
|
+
} finally {
|
|
188
|
+
textLoading.value = false
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{ immediate: true },
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
function selectFile(file: any) {
|
|
196
|
+
selectedKey.value = file.key
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function uploadFileObject(file: File) {
|
|
200
|
+
uploadingBlob.value = true
|
|
201
|
+
try {
|
|
202
|
+
const formData = new FormData()
|
|
203
|
+
formData.append("file", file)
|
|
204
|
+
const uploaded = await $fetch<any>("/api/storage/upload", {
|
|
205
|
+
method: "POST",
|
|
206
|
+
body: formData,
|
|
207
|
+
})
|
|
208
|
+
await loadBlob()
|
|
209
|
+
const newKey = uploaded?.key || uploaded?.files?.[0]?.key || file.name
|
|
210
|
+
selectedKey.value = newKey
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.error("Upload failed", err)
|
|
213
|
+
} finally {
|
|
214
|
+
uploadingBlob.value = false
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async function handleBlobUpload(e: Event) {
|
|
219
|
+
const target = e.target as HTMLInputElement
|
|
220
|
+
const file = target?.files?.[0]
|
|
221
|
+
if (!file) return
|
|
222
|
+
await uploadFileObject(file)
|
|
223
|
+
if (target) target.value = ""
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function handleDrop(e: DragEvent) {
|
|
227
|
+
isDragging.value = false
|
|
228
|
+
const files = e.dataTransfer?.files
|
|
229
|
+
if (!files || files.length === 0) return
|
|
230
|
+
for (let i = 0; i < files.length; i++) {
|
|
231
|
+
const file = files[i]
|
|
232
|
+
if (file) {
|
|
233
|
+
await uploadFileObject(file)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function deleteBlobFile(key?: string) {
|
|
239
|
+
if (!key) return
|
|
240
|
+
deletingBlob.value = true
|
|
241
|
+
try {
|
|
242
|
+
await $fetch(`/api/storage/file/${key}`, {
|
|
243
|
+
method: "DELETE",
|
|
244
|
+
}).catch(() => {})
|
|
245
|
+
showDeleteBlobModal.value = false
|
|
246
|
+
selectedKey.value = null
|
|
247
|
+
await loadBlob()
|
|
248
|
+
} finally {
|
|
249
|
+
deletingBlob.value = false
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function copyBlobUrl(key?: string) {
|
|
254
|
+
if (!key) return
|
|
255
|
+
if (typeof window !== "undefined") {
|
|
256
|
+
const url = `${window.location.origin}/api/storage/file/${key}`
|
|
257
|
+
navigator.clipboard?.writeText(url)
|
|
258
|
+
copiedUrl.value = true
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
copiedUrl.value = false
|
|
261
|
+
}, 1500)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function copyBlobKey(key?: string) {
|
|
266
|
+
if (!key) return
|
|
267
|
+
if (typeof navigator !== "undefined") {
|
|
268
|
+
navigator.clipboard?.writeText(key)
|
|
269
|
+
copiedKey.value = true
|
|
270
|
+
setTimeout(() => {
|
|
271
|
+
copiedKey.value = false
|
|
272
|
+
}, 1500)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
onMounted(() => {
|
|
277
|
+
loadBlob()
|
|
278
|
+
})
|
|
279
|
+
</script>
|
|
280
|
+
|
|
281
|
+
<template>
|
|
282
|
+
<UDashboardPanel id="devtools-blob">
|
|
283
|
+
<template #header>
|
|
284
|
+
<UDashboardNavbar>
|
|
285
|
+
<template #title>
|
|
286
|
+
<div class="flex items-center gap-2">
|
|
287
|
+
<UIcon name="i-lucide-box" class="w-4 h-4 text-primary" />
|
|
288
|
+
<span class="font-bold text-sm text-highlighted">Blob Storage</span>
|
|
289
|
+
<UBadge size="xs" color="neutral" variant="subtle">R2</UBadge>
|
|
290
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
291
|
+
{{ filteredFiles.length }}
|
|
292
|
+
</UBadge>
|
|
293
|
+
</div>
|
|
294
|
+
</template>
|
|
295
|
+
|
|
296
|
+
<template #right>
|
|
297
|
+
<div class="flex items-center gap-1.5">
|
|
298
|
+
<input ref="fileInputRef" type="file" class="hidden" @change="handleBlobUpload" />
|
|
299
|
+
<UButton
|
|
300
|
+
icon="i-lucide-upload"
|
|
301
|
+
label="Upload File"
|
|
302
|
+
size="xs"
|
|
303
|
+
color="primary"
|
|
304
|
+
:loading="uploadingBlob"
|
|
305
|
+
@click="fileInputRef?.click()"
|
|
306
|
+
/>
|
|
307
|
+
<UButton
|
|
308
|
+
icon="i-lucide-refresh-cw"
|
|
309
|
+
size="xs"
|
|
310
|
+
color="neutral"
|
|
311
|
+
variant="ghost"
|
|
312
|
+
title="Refresh files"
|
|
313
|
+
:loading="blobLoading"
|
|
314
|
+
@click="loadBlob"
|
|
315
|
+
/>
|
|
316
|
+
</div>
|
|
317
|
+
</template>
|
|
318
|
+
</UDashboardNavbar>
|
|
319
|
+
|
|
320
|
+
<!-- Media Filter Toolbar -->
|
|
321
|
+
<UDashboardToolbar>
|
|
322
|
+
<!-- Type Filter Segmented Buttons -->
|
|
323
|
+
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
324
|
+
<UButton
|
|
325
|
+
label="All"
|
|
326
|
+
size="xs"
|
|
327
|
+
:color="filterType === 'all' ? 'primary' : 'neutral'"
|
|
328
|
+
:variant="filterType === 'all' ? 'subtle' : 'ghost'"
|
|
329
|
+
@click="filterType = 'all'"
|
|
330
|
+
>
|
|
331
|
+
<template #trailing>
|
|
332
|
+
<UBadge
|
|
333
|
+
size="xs"
|
|
334
|
+
:color="filterType === 'all' ? 'primary' : 'neutral'"
|
|
335
|
+
variant="subtle"
|
|
336
|
+
>
|
|
337
|
+
{{ counts.all }}
|
|
338
|
+
</UBadge>
|
|
339
|
+
</template>
|
|
340
|
+
</UButton>
|
|
341
|
+
|
|
342
|
+
<UButton
|
|
343
|
+
label="Images"
|
|
344
|
+
icon="i-lucide-image"
|
|
345
|
+
size="xs"
|
|
346
|
+
:color="filterType === 'images' ? 'primary' : 'neutral'"
|
|
347
|
+
:variant="filterType === 'images' ? 'subtle' : 'ghost'"
|
|
348
|
+
@click="filterType = 'images'"
|
|
349
|
+
>
|
|
350
|
+
<template #trailing>
|
|
351
|
+
<UBadge
|
|
352
|
+
size="xs"
|
|
353
|
+
:color="filterType === 'images' ? 'primary' : 'neutral'"
|
|
354
|
+
variant="subtle"
|
|
355
|
+
>
|
|
356
|
+
{{ counts.images }}
|
|
357
|
+
</UBadge>
|
|
358
|
+
</template>
|
|
359
|
+
</UButton>
|
|
360
|
+
|
|
361
|
+
<UButton
|
|
362
|
+
label="Documents"
|
|
363
|
+
icon="i-lucide-file-text"
|
|
364
|
+
size="xs"
|
|
365
|
+
:color="filterType === 'documents' ? 'primary' : 'neutral'"
|
|
366
|
+
:variant="filterType === 'documents' ? 'subtle' : 'ghost'"
|
|
367
|
+
@click="filterType = 'documents'"
|
|
368
|
+
>
|
|
369
|
+
<template #trailing>
|
|
370
|
+
<UBadge
|
|
371
|
+
size="xs"
|
|
372
|
+
:color="filterType === 'documents' ? 'primary' : 'neutral'"
|
|
373
|
+
variant="subtle"
|
|
374
|
+
>
|
|
375
|
+
{{ counts.docs }}
|
|
376
|
+
</UBadge>
|
|
377
|
+
</template>
|
|
378
|
+
</UButton>
|
|
379
|
+
|
|
380
|
+
<UButton
|
|
381
|
+
label="Other"
|
|
382
|
+
size="xs"
|
|
383
|
+
:color="filterType === 'other' ? 'primary' : 'neutral'"
|
|
384
|
+
:variant="filterType === 'other' ? 'subtle' : 'ghost'"
|
|
385
|
+
@click="filterType = 'other'"
|
|
386
|
+
>
|
|
387
|
+
<template #trailing>
|
|
388
|
+
<UBadge
|
|
389
|
+
size="xs"
|
|
390
|
+
:color="filterType === 'other' ? 'primary' : 'neutral'"
|
|
391
|
+
variant="subtle"
|
|
392
|
+
>
|
|
393
|
+
{{ counts.other }}
|
|
394
|
+
</UBadge>
|
|
395
|
+
</template>
|
|
396
|
+
</UButton>
|
|
397
|
+
</div>
|
|
398
|
+
|
|
399
|
+
<!-- Search Input -->
|
|
400
|
+
<div class="flex items-center gap-2 max-w-xs flex-1">
|
|
401
|
+
<UInput
|
|
402
|
+
v-model="blobSearch"
|
|
403
|
+
icon="i-lucide-search"
|
|
404
|
+
placeholder="Search files by key…"
|
|
405
|
+
class="w-full"
|
|
406
|
+
/>
|
|
407
|
+
</div>
|
|
408
|
+
</UDashboardToolbar>
|
|
409
|
+
</template>
|
|
410
|
+
|
|
411
|
+
<template #body>
|
|
412
|
+
<div
|
|
413
|
+
class="space-y-4 min-h-[400px]"
|
|
414
|
+
@dragover.prevent="isDragging = true"
|
|
415
|
+
@dragleave.prevent="isDragging = false"
|
|
416
|
+
@drop.prevent="handleDrop"
|
|
417
|
+
>
|
|
418
|
+
<!-- Drag & Drop Active Overlay -->
|
|
419
|
+
<div
|
|
420
|
+
v-if="isDragging"
|
|
421
|
+
class="border-2 border-dashed border-primary rounded-xl p-8 flex flex-col items-center justify-center text-primary bg-primary/10 animate-pulse text-center"
|
|
422
|
+
>
|
|
423
|
+
<UIcon name="i-lucide-upload-cloud" class="w-10 h-10 mb-2" />
|
|
424
|
+
<span class="text-sm font-bold">Drop files here to upload</span>
|
|
425
|
+
<span class="text-xs text-muted"
|
|
426
|
+
>Files will be uploaded directly to Cloudflare R2 storage</span
|
|
427
|
+
>
|
|
428
|
+
</div>
|
|
429
|
+
<!-- Loading Skeleton Grid -->
|
|
430
|
+
<div
|
|
431
|
+
v-if="blobLoading"
|
|
432
|
+
class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4"
|
|
433
|
+
>
|
|
434
|
+
<div
|
|
435
|
+
v-for="i in 12"
|
|
436
|
+
:key="i"
|
|
437
|
+
class="bg-elevated/40 border border-default rounded-xl overflow-hidden flex flex-col animate-pulse"
|
|
438
|
+
>
|
|
439
|
+
<div class="aspect-square bg-muted/60"></div>
|
|
440
|
+
<div class="p-2.5 space-y-2">
|
|
441
|
+
<div class="h-3 w-3/4 rounded bg-muted"></div>
|
|
442
|
+
<div class="h-2 w-1/2 rounded bg-muted"></div>
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
|
|
447
|
+
<!-- Visual Media Grid -->
|
|
448
|
+
<div
|
|
449
|
+
v-else-if="filteredFiles.length"
|
|
450
|
+
class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4"
|
|
451
|
+
>
|
|
452
|
+
<div
|
|
453
|
+
v-for="file in filteredFiles"
|
|
454
|
+
:key="file.key"
|
|
455
|
+
class="group relative bg-elevated/40 hover:bg-elevated border border-default hover:border-primary/50 rounded-xl cursor-pointer transition-all duration-200 flex flex-col shadow-xs"
|
|
456
|
+
@click="selectFile(file)"
|
|
457
|
+
>
|
|
458
|
+
<!-- Thumbnail preview area -->
|
|
459
|
+
<div
|
|
460
|
+
class="aspect-square bg-muted/20 flex items-center justify-center border-b border-default relative"
|
|
461
|
+
>
|
|
462
|
+
<img
|
|
463
|
+
v-if="isImage(file.contentType) && !failedImages[file.key]"
|
|
464
|
+
:src="'/api/storage/file/' + file.key"
|
|
465
|
+
:alt="file.key"
|
|
466
|
+
class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
|
|
467
|
+
loading="lazy"
|
|
468
|
+
@error="onImageError(file.key)"
|
|
469
|
+
/>
|
|
470
|
+
<div v-else class="flex flex-col items-center justify-center p-4 text-center">
|
|
471
|
+
<UIcon
|
|
472
|
+
:name="getBlobIcon(file.contentType)"
|
|
473
|
+
class="w-10 h-10 text-primary/70 mb-2 group-hover:scale-110 transition-transform"
|
|
474
|
+
/>
|
|
475
|
+
<span class="text-[10px] font-mono text-muted uppercase">
|
|
476
|
+
{{ file.contentType?.split("/")[1] || "file" }}
|
|
477
|
+
</span>
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
<!-- Hover overlay badge -->
|
|
481
|
+
<div
|
|
482
|
+
class="absolute inset-0 bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"
|
|
483
|
+
>
|
|
484
|
+
<UBadge size="xs" color="primary" variant="solid">View Details</UBadge>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
|
|
488
|
+
<!-- Metadata Caption -->
|
|
489
|
+
<div class="p-2.5 flex flex-col justify-between flex-1">
|
|
490
|
+
<div
|
|
491
|
+
class="font-mono text-xs font-semibold text-highlighted truncate"
|
|
492
|
+
:title="file.key"
|
|
493
|
+
>
|
|
494
|
+
{{ file.key }}
|
|
495
|
+
</div>
|
|
496
|
+
<div class="flex items-center justify-between text-[11px] text-muted mt-1 font-mono">
|
|
497
|
+
<span>{{ fmtBytes(file.size) }}</span>
|
|
498
|
+
<span>{{ fmtDate(file.uploaded) }}</span>
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
</div>
|
|
503
|
+
|
|
504
|
+
<!-- Empty State -->
|
|
505
|
+
<div v-else class="flex flex-col items-center justify-center py-20 text-center space-y-3">
|
|
506
|
+
<div
|
|
507
|
+
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary"
|
|
508
|
+
>
|
|
509
|
+
<UIcon name="i-lucide-box" class="w-6 h-6" />
|
|
510
|
+
</div>
|
|
511
|
+
<div class="font-bold text-sm text-highlighted">No files found</div>
|
|
512
|
+
<p class="text-xs text-muted max-w-sm">
|
|
513
|
+
Upload images, documents, or data files to store them directly in your Cloudflare R2
|
|
514
|
+
bucket.
|
|
515
|
+
</p>
|
|
516
|
+
<UButton
|
|
517
|
+
label="Upload First File"
|
|
518
|
+
icon="i-lucide-upload"
|
|
519
|
+
size="sm"
|
|
520
|
+
color="primary"
|
|
521
|
+
@click="fileInputRef?.click()"
|
|
522
|
+
/>
|
|
523
|
+
</div>
|
|
524
|
+
</div>
|
|
525
|
+
</template>
|
|
526
|
+
</UDashboardPanel>
|
|
527
|
+
<!-- ── Right Side Slideover for File Details & Live Preview ─────────── -->
|
|
528
|
+
<USlideover v-model:open="isSlideoverOpen" side="right" :title="selectedBlob?.key">
|
|
529
|
+
<template #title>
|
|
530
|
+
<div class="flex items-center gap-2 min-w-0 pr-4">
|
|
531
|
+
<UIcon
|
|
532
|
+
:name="getBlobIcon(selectedBlob?.contentType)"
|
|
533
|
+
class="w-5 h-5 text-primary shrink-0"
|
|
534
|
+
/>
|
|
535
|
+
<span
|
|
536
|
+
class="font-mono font-bold text-sm text-highlighted truncate"
|
|
537
|
+
:title="selectedBlob?.key"
|
|
538
|
+
>
|
|
539
|
+
{{ selectedBlob?.key }}
|
|
540
|
+
</span>
|
|
541
|
+
</div>
|
|
542
|
+
</template>
|
|
543
|
+
|
|
544
|
+
<template #body>
|
|
545
|
+
<div v-if="selectedBlob" class="space-y-6">
|
|
546
|
+
<!-- Live Media Preview Box -->
|
|
547
|
+
<div
|
|
548
|
+
class="bg-muted/30 border border-default rounded-xl flex items-center justify-center p-4 min-h-[220px]"
|
|
549
|
+
>
|
|
550
|
+
<!-- Image -->
|
|
551
|
+
<div
|
|
552
|
+
v-if="isImage(selectedBlob.contentType)"
|
|
553
|
+
class="w-full flex items-center justify-center"
|
|
554
|
+
>
|
|
555
|
+
<img
|
|
556
|
+
v-if="!failedImages[selectedBlob.key]"
|
|
557
|
+
:src="'/api/storage/file/' + selectedBlob.key"
|
|
558
|
+
:alt="selectedBlob.key"
|
|
559
|
+
class="max-h-[320px] max-w-full object-contain rounded-lg shadow-xs"
|
|
560
|
+
@error="onImageError(selectedBlob.key)"
|
|
561
|
+
/>
|
|
562
|
+
<div v-else class="text-center py-8 text-muted">
|
|
563
|
+
<UIcon name="i-lucide-image" class="w-12 h-12 opacity-40 mx-auto mb-2 text-primary" />
|
|
564
|
+
<div class="text-xs">Preview placeholder</div>
|
|
565
|
+
</div>
|
|
566
|
+
</div>
|
|
567
|
+
|
|
568
|
+
<!-- Audio -->
|
|
569
|
+
<div v-else-if="isAudio(selectedBlob.contentType)" class="w-full p-2 text-center">
|
|
570
|
+
<audio controls :src="'/api/storage/file/' + selectedBlob.key" class="w-full" />
|
|
571
|
+
</div>
|
|
572
|
+
|
|
573
|
+
<!-- Video -->
|
|
574
|
+
<div v-else-if="isVideo(selectedBlob.contentType)" class="w-full text-center">
|
|
575
|
+
<video
|
|
576
|
+
controls
|
|
577
|
+
:src="'/api/storage/file/' + selectedBlob.key"
|
|
578
|
+
class="w-full rounded-lg max-h-[300px]"
|
|
579
|
+
/>
|
|
580
|
+
</div>
|
|
581
|
+
|
|
582
|
+
<!-- Text / Code / JSON -->
|
|
583
|
+
<div v-else-if="isTextOrJson(selectedBlob.contentType)" class="w-full">
|
|
584
|
+
<div v-if="textLoading" class="text-xs text-muted text-center py-8">
|
|
585
|
+
Loading text preview…
|
|
586
|
+
</div>
|
|
587
|
+
<pre
|
|
588
|
+
v-else
|
|
589
|
+
class="font-mono text-xs text-default bg-muted/40 p-3 rounded-md border border-default overflow-auto max-h-[300px] whitespace-pre-wrap break-all"
|
|
590
|
+
>{{ textContent || "(empty file)" }}</pre>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<!-- Generic Document / File -->
|
|
594
|
+
<div v-else class="text-center py-8 space-y-2 text-muted">
|
|
595
|
+
<UIcon
|
|
596
|
+
:name="getBlobIcon(selectedBlob.contentType)"
|
|
597
|
+
class="w-16 h-16 opacity-40 mx-auto"
|
|
598
|
+
/>
|
|
599
|
+
<div class="text-xs">Preview not supported for this file format</div>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
|
|
603
|
+
<!-- File Metadata List -->
|
|
604
|
+
<div class="space-y-3">
|
|
605
|
+
<div class="text-xs font-semibold uppercase tracking-wider text-muted">File Metadata</div>
|
|
606
|
+
|
|
607
|
+
<div
|
|
608
|
+
class="divide-y divide-default rounded-lg border border-default bg-elevated/40 text-xs font-mono"
|
|
609
|
+
>
|
|
610
|
+
<div class="flex items-center justify-between p-3">
|
|
611
|
+
<span class="text-muted">Storage Key</span>
|
|
612
|
+
<div class="flex items-center gap-1.5 min-w-0 ml-2">
|
|
613
|
+
<span class="text-highlighted font-bold truncate">{{ selectedBlob.key }}</span>
|
|
614
|
+
<UButton
|
|
615
|
+
type="button"
|
|
616
|
+
:icon="copiedKey ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
617
|
+
:color="copiedKey ? 'success' : 'neutral'"
|
|
618
|
+
variant="ghost"
|
|
619
|
+
size="xs"
|
|
620
|
+
:title="copiedKey ? 'Copied!' : 'Copy key'"
|
|
621
|
+
class="shrink-0"
|
|
622
|
+
@click="copyBlobKey(selectedBlob.key)"
|
|
623
|
+
/>
|
|
624
|
+
</div>
|
|
625
|
+
</div>
|
|
626
|
+
|
|
627
|
+
<div class="flex items-center justify-between p-3">
|
|
628
|
+
<span class="text-muted">Content-Type</span>
|
|
629
|
+
<span class="text-default font-semibold">{{ selectedBlob.contentType }}</span>
|
|
630
|
+
</div>
|
|
631
|
+
|
|
632
|
+
<div class="flex items-center justify-between p-3">
|
|
633
|
+
<span class="text-muted">File Size</span>
|
|
634
|
+
<span class="text-default">{{ fmtBytes(selectedBlob.size) }}</span>
|
|
635
|
+
</div>
|
|
636
|
+
|
|
637
|
+
<div class="flex items-center justify-between p-3">
|
|
638
|
+
<span class="text-muted">Uploaded</span>
|
|
639
|
+
<span class="text-default">{{ fmtFullDate(selectedBlob.uploaded) }}</span>
|
|
640
|
+
</div>
|
|
641
|
+
|
|
642
|
+
<div class="flex items-start justify-between p-3 gap-2">
|
|
643
|
+
<span class="text-muted shrink-0">Public URL</span>
|
|
644
|
+
<div class="flex items-center gap-1.5 min-w-0">
|
|
645
|
+
<span class="text-primary truncate font-mono text-[11px]">
|
|
646
|
+
/api/storage/file/{{ selectedBlob.key }}
|
|
647
|
+
</span>
|
|
648
|
+
<UButton
|
|
649
|
+
type="button"
|
|
650
|
+
:icon="copiedUrl ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
651
|
+
:color="copiedUrl ? 'success' : 'neutral'"
|
|
652
|
+
variant="ghost"
|
|
653
|
+
size="xs"
|
|
654
|
+
:title="copiedUrl ? 'Copied URL!' : 'Copy URL'"
|
|
655
|
+
class="shrink-0"
|
|
656
|
+
@click="copyBlobUrl(selectedBlob.key)"
|
|
657
|
+
/>
|
|
658
|
+
</div>
|
|
659
|
+
</div>
|
|
660
|
+
</div>
|
|
661
|
+
</div>
|
|
662
|
+
</div>
|
|
663
|
+
</template>
|
|
664
|
+
|
|
665
|
+
<template #footer>
|
|
666
|
+
<div v-if="selectedBlob" class="flex items-center justify-between w-full gap-2">
|
|
667
|
+
<div class="flex items-center gap-1.5">
|
|
668
|
+
<UButton
|
|
669
|
+
:label="copiedUrl ? 'Copied!' : 'Copy URL'"
|
|
670
|
+
:icon="copiedUrl ? 'i-lucide-check' : 'i-lucide-link'"
|
|
671
|
+
size="xs"
|
|
672
|
+
:color="copiedUrl ? 'success' : 'neutral'"
|
|
673
|
+
variant="subtle"
|
|
674
|
+
@click="copyBlobUrl(selectedBlob.key)"
|
|
675
|
+
/>
|
|
676
|
+
<UButton
|
|
677
|
+
label="Download"
|
|
678
|
+
icon="i-lucide-download"
|
|
679
|
+
size="xs"
|
|
680
|
+
color="neutral"
|
|
681
|
+
variant="subtle"
|
|
682
|
+
:to="'/api/storage/file/' + selectedBlob.key"
|
|
683
|
+
target="_blank"
|
|
684
|
+
download
|
|
685
|
+
/>
|
|
686
|
+
</div>
|
|
687
|
+
<UButton
|
|
688
|
+
label="Delete"
|
|
689
|
+
icon="i-lucide-trash"
|
|
690
|
+
size="xs"
|
|
691
|
+
color="error"
|
|
692
|
+
variant="subtle"
|
|
693
|
+
@click="showDeleteBlobModal = true"
|
|
694
|
+
/>
|
|
695
|
+
</div>
|
|
696
|
+
</template>
|
|
697
|
+
</USlideover>
|
|
698
|
+
|
|
699
|
+
<!-- Delete File Confirmation Modal -->
|
|
700
|
+
<UModal v-model:open="showDeleteBlobModal" title="Delete Storage File">
|
|
701
|
+
<template #body>
|
|
702
|
+
<div class="space-y-3">
|
|
703
|
+
<p class="text-xs text-default">
|
|
704
|
+
Are you sure you want to permanently delete
|
|
705
|
+
<span class="font-mono font-bold text-highlighted">{{ selectedBlob?.key }}</span>?
|
|
706
|
+
</p>
|
|
707
|
+
<div class="bg-elevated/40 border border-default rounded-lg p-2.5 text-xs space-y-1">
|
|
708
|
+
<div class="flex justify-between text-muted">
|
|
709
|
+
<span>Size:</span>
|
|
710
|
+
<span class="text-default font-mono">{{ fmtBytes(selectedBlob?.size || 0) }}</span>
|
|
711
|
+
</div>
|
|
712
|
+
<div class="flex justify-between text-muted">
|
|
713
|
+
<span>Type:</span>
|
|
714
|
+
<span class="text-default font-mono">{{ selectedBlob?.contentType }}</span>
|
|
715
|
+
</div>
|
|
716
|
+
</div>
|
|
717
|
+
<p class="text-xs text-muted">
|
|
718
|
+
This object will be deleted from your Cloudflare R2 bucket. Public or signed links to this
|
|
719
|
+
file will immediately return 404 Not Found.
|
|
720
|
+
</p>
|
|
721
|
+
</div>
|
|
722
|
+
</template>
|
|
723
|
+
<template #footer>
|
|
724
|
+
<div class="flex justify-end gap-2">
|
|
725
|
+
<UButton
|
|
726
|
+
label="Cancel"
|
|
727
|
+
color="neutral"
|
|
728
|
+
variant="ghost"
|
|
729
|
+
size="xs"
|
|
730
|
+
@click="showDeleteBlobModal = false"
|
|
731
|
+
/>
|
|
732
|
+
<UButton
|
|
733
|
+
label="Confirm Delete"
|
|
734
|
+
color="error"
|
|
735
|
+
size="xs"
|
|
736
|
+
icon="i-lucide-trash"
|
|
737
|
+
:loading="deletingBlob"
|
|
738
|
+
@click="deleteBlobFile(selectedBlob?.key)"
|
|
739
|
+
/>
|
|
740
|
+
</div>
|
|
741
|
+
</template>
|
|
742
|
+
</UModal>
|
|
743
|
+
</template>
|