Skip to content

Commit 3552618

Browse files
committed
feat(queries): show metadata counts in table-view footers
- emit countChange from schema, indexes, foreign keys, and triggers panels - render a persistent database/count footer for every metadata sub-page - add localized count labels
1 parent 5315086 commit 3552618

7 files changed

Lines changed: 83 additions & 3 deletions

File tree

‎src/components/database-browser/DataTableView.vue‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ watch(() => props.initialSubPage, (subPage) => {
8585
activeSubPage.value = subPage
8686
})
8787
88+
// Counts reported by the metadata sub-pages, shown in their footer.
89+
const subPageCounts = ref<Partial<Record<SubPage, number>>>({})
90+
91+
function setSubPageCount(subPage: SubPage, count: number | undefined) {
92+
subPageCounts.value = { ...subPageCounts.value, [subPage]: count }
93+
}
94+
95+
const activeSubPageCountLabel = computed(() => {
96+
const count = subPageCounts.value[activeSubPage.value]
97+
if (count === undefined)
98+
return ''
99+
switch (activeSubPage.value) {
100+
case 'schema':
101+
return t('components.dataTableView.columnsCount', { count })
102+
case 'indexes':
103+
return t('components.dataTableView.indexesCount', { count })
104+
case 'foreign_keys':
105+
return t('components.dataTableView.foreignKeysCount', { count })
106+
case 'triggers':
107+
return t('components.dataTableView.triggersCount', { count })
108+
default:
109+
return ''
110+
}
111+
})
112+
88113
const currentPage = ref(1)
89114
const rowsPerPage = ref<RowsPerPage>(100)
90115
const filterInput = ref('')
@@ -859,6 +884,7 @@ watch(
859884
hiddenColumns.value = new Set()
860885
sort.clearSort()
861886
connectionError.value = null
887+
subPageCounts.value = {}
862888
863889
if (newConnId !== oldConnId) {
864890
data.value = null
@@ -1318,6 +1344,7 @@ watch(
13181344
:schema="props.schema ?? null"
13191345
:table-name="props.tableName"
13201346
class="flex-1"
1347+
@count-change="setSubPageCount('schema', $event)"
13211348
/>
13221349

13231350
<!-- Indexes sub-page -->
@@ -1328,6 +1355,7 @@ watch(
13281355
:schema="props.schema ?? null"
13291356
:table-name="props.tableName"
13301357
class="flex-1"
1358+
@count-change="setSubPageCount('indexes', $event)"
13311359
/>
13321360

13331361
<!-- Foreign Keys sub-page -->
@@ -1338,6 +1366,7 @@ watch(
13381366
:schema="props.schema ?? null"
13391367
:table-name="props.tableName"
13401368
class="flex-1"
1369+
@count-change="setSubPageCount('foreign_keys', $event)"
13411370
/>
13421371

13431372
<!-- Triggers sub-page -->
@@ -1348,8 +1377,20 @@ watch(
13481377
:schema="props.schema ?? null"
13491378
:table-name="props.tableName"
13501379
class="flex-1"
1380+
@count-change="setSubPageCount('triggers', $event)"
13511381
/>
13521382

1383+
<!-- Status footer for metadata sub-pages -->
1384+
<div
1385+
v-if="activeSubPage !== 'data'"
1386+
class="text-xs text-muted-foreground px-3 py-1.5 border-t bg-muted/20 flex shrink-0 gap-3 items-center overflow-hidden"
1387+
>
1388+
<span v-if="props.database" class="tabular-nums">
1389+
{{ t('pages.queries.status.database') }}: {{ props.database }}
1390+
</span>
1391+
<span v-if="activeSubPageCountLabel" class="tabular-nums">{{ activeSubPageCountLabel }}</span>
1392+
</div>
1393+
13531394
<!-- ── Delete confirmation dialog ── -->
13541395
<DestructiveConfirmDialog
13551396
v-model:open="deleteDialogOpen"

‎src/components/database-browser/ForeignKeysTab.vue‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const props = defineProps<{
1212
tableName: string
1313
}>()
1414
15+
const emit = defineEmits<{
16+
(e: 'countChange', count: number | undefined): void
17+
}>()
18+
1519
const { t } = useI18n()
1620
1721
const foreignKeys = ref<ForeignKeyInfo[]>([])
@@ -21,16 +25,20 @@ const error = ref<string | null>(null)
2125
async function fetchForeignKeys() {
2226
loading.value = true
2327
error.value = null
28+
emit('countChange', undefined)
2429
try {
25-
foreignKeys.value = await browseApi.listForeignKeys(
30+
const result = await browseApi.listForeignKeys(
2631
props.connectionId,
2732
props.database,
2833
props.schema,
2934
props.tableName,
3035
)
36+
foreignKeys.value = result
37+
emit('countChange', result.length)
3138
}
3239
catch (err) {
3340
error.value = String(err)
41+
emit('countChange', undefined)
3442
}
3543
finally {
3644
loading.value = false

‎src/components/database-browser/IndexesTab.vue‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const props = defineProps<{
1212
tableName: string
1313
}>()
1414
15+
const emit = defineEmits<{
16+
(e: 'countChange', count: number | undefined): void
17+
}>()
18+
1519
const { t } = useI18n()
1620
1721
const indexes = ref<IndexInfo[]>([])
@@ -21,16 +25,20 @@ const error = ref<string | null>(null)
2125
async function fetchIndexes() {
2226
loading.value = true
2327
error.value = null
28+
emit('countChange', undefined)
2429
try {
25-
indexes.value = await browseApi.listIndexes(
30+
const result = await browseApi.listIndexes(
2631
props.connectionId,
2732
props.database,
2833
props.schema,
2934
props.tableName,
3035
)
36+
indexes.value = result
37+
emit('countChange', result.length)
3138
}
3239
catch (err) {
3340
error.value = String(err)
41+
emit('countChange', undefined)
3442
}
3543
finally {
3644
loading.value = false

‎src/components/database-browser/SchemaTab.vue‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const props = defineProps<{
2424
tableName: string
2525
}>()
2626
27+
const emit = defineEmits<{
28+
(e: 'countChange', count: number | undefined): void
29+
}>()
30+
2731
const { t } = useI18n()
2832
2933
const columns = ref<ColumnInfo[]>([])
@@ -33,6 +37,7 @@ const error = ref<string | null>(null)
3337
async function fetchColumns() {
3438
loading.value = true
3539
error.value = null
40+
emit('countChange', undefined)
3641
try {
3742
const result = await invoke<ColumnInfo[]>('list_columns', {
3843
connectionId: props.connectionId,
@@ -41,9 +46,11 @@ async function fetchColumns() {
4146
tableName: props.tableName,
4247
})
4348
columns.value = result
49+
emit('countChange', result.length)
4450
}
4551
catch (err) {
4652
error.value = String(err)
53+
emit('countChange', undefined)
4754
}
4855
finally {
4956
loading.value = false

‎src/components/database-browser/TriggersTab.vue‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const props = defineProps<{
1414
tableName: string
1515
}>()
1616
17+
const emit = defineEmits<{
18+
(e: 'countChange', count: number | undefined): void
19+
}>()
20+
1721
const { t } = useI18n()
1822
1923
const triggers = ref<TriggerInfo[]>([])
@@ -28,16 +32,20 @@ const ddlContent = ref('')
2832
async function fetchTriggers() {
2933
loading.value = true
3034
error.value = null
35+
emit('countChange', undefined)
3136
try {
32-
triggers.value = await browseApi.listTriggers(
37+
const result = await browseApi.listTriggers(
3338
props.connectionId,
3439
props.database,
3540
props.schema,
3641
props.tableName,
3742
)
43+
triggers.value = result
44+
emit('countChange', result.length)
3845
}
3946
catch (err) {
4047
error.value = String(err)
48+
emit('countChange', undefined)
4149
}
4250
finally {
4351
loading.value = false

‎src/lang/enUS.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,10 @@ export const enUS = {
15671567
reconnect: 'Reconnect',
15681568
noRows: 'No rows found',
15691569
rows: 'rows',
1570+
columnsCount: '{count} columns',
1571+
indexesCount: '{count} indexes',
1572+
foreignKeysCount: '{count} foreign keys',
1573+
triggersCount: '{count} triggers',
15701574
page: 'Page {page} of {total}',
15711575
rowsPerPage: 'Rows per page:',
15721576
actions: 'Actions',

‎src/lang/zhCN.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,10 @@ export const zhCN = {
15061506
reconnect: '重新连接',
15071507
noRows: '未找到行',
15081508
rows: '行',
1509+
columnsCount: '{count} 列',
1510+
indexesCount: '{count} 个索引',
1511+
foreignKeysCount: '{count} 个外键',
1512+
triggersCount: '{count} 个触发器',
15091513
page: '第 {page} 页,共 {total} 页',
15101514
rowsPerPage: '每页行数:',
15111515
actions: '操作',

0 commit comments

Comments
 (0)