Skip to content

Commit 6a29e15

Browse files
committed
feat: imrpove schema detection
1 parent f41fdc7 commit 6a29e15

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

client/app/components/EmptyScreen.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ if (typeof window !== 'undefined') {
109109

110110
<template>
111111
<div class="relative w-full h-full overflow-hidden font-mono text-slate-300">
112-
<div class="absolute -left-48 -top-10 pointer-events-none z-1 opacity-50">
113-
<canvas ref="matrixCanvas" />
114-
</div>
115-
116112
<div class="absolute inset-0 flex items-center justify-center z-2">
113+
<canvas
114+
ref="matrixCanvas"
115+
class="absolute opacity-25"
116+
/>
117+
117118
<div class="text-center space-y-6 max-w-md px-6">
118119
<div class="space-y-2">
119120
<h2 class="text-2xl font-bold text-white">

client/app/layouts/default.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ const selectedCollection = computed(() => route.params.collection as string || '
251251
<template #right>
252252
<slot name="actions" />
253253

254-
<USlideover v-model:open="deleteConfirmOpen">
254+
<USlideover
255+
v-if="selectedCollection"
256+
v-model:open="deleteConfirmOpen"
257+
>
255258
<UButton
256259
icon="i-lucide-trash-2"
257260
color="error"

client/app/pages/[...collection]/index.vue

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ const schema = computedAsync<any>(async () => {
6666
if (!result || 'error' in result) {
6767
return null
6868
}
69+
if (Object.keys(result).length === 0) {
70+
const schemas = await rpc.value?.resourceSchema(collectionName.value)
71+
if (schemas && !('error' in schemas)) {
72+
// Normalize resourceSchema format to match getCollectionSchema
73+
const normalized: Record<string, any> = {}
74+
for (const [key, value] of Object.entries(schemas)) {
75+
if (value && typeof value === 'object' && 'type' in value) {
76+
const typeValue = (value as any).type
77+
// If type is already a string, use it; otherwise get the constructor name
78+
const typeName = typeof typeValue === 'string' ? typeValue : (typeValue?.name || 'unknown')
79+
normalized[key] = { ...value, type: typeName }
80+
}
81+
else {
82+
normalized[key] = value
83+
}
84+
}
85+
return normalized
86+
}
87+
}
6988
return result
7089
}, null)
7190
@@ -223,16 +242,16 @@ function addDocument() {
223242
return
224243
editing.value = true
225244
selectedDocument.value = {}
226-
// if (schema.value) {
227-
// for (const field of Object.keys(schema.value))
228-
// selectedDocument.value[field] = ''
229-
// }
230-
// else {
231-
for (const field of fields.value) {
232-
if (field !== '_id')
245+
if (schema.value) {
246+
for (const field of Object.keys(schema.value))
233247
selectedDocument.value[field] = ''
234248
}
235-
// }
249+
else {
250+
for (const field of fields.value) {
251+
if (field !== '_id')
252+
selectedDocument.value[field] = ''
253+
}
254+
}
236255
237256
// Scroll to new document and focus on first field
238257
setTimeout(() => {
@@ -443,8 +462,6 @@ useEventListener(tableRef, 'scroll', updateShadow)
443462
</div>
444463
</div>
445464

446-
{{ JSON.stringify(schema) }}
447-
448465
<UTable
449466
v-if="documents?.length || selectedDocument || fields.length"
450467
ref="tableRef"

0 commit comments

Comments
 (0)