feat: show username/password fields for Access database connections

This commit is contained in:
t8y2 committed 2026-06-10 08:37:18 +08:00
1 parent 2e021d37d1
commit edba8214b5
477 files changed
+5720 -19773

No files matched your search

@@ -65,21 +65,9 @@ const exportCancelled = ref(false);
const pendingPrefillTable = ref("");
const pendingPrefillTables = ref<string[]>([]);
const sqlConnections = computed(() =>
store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "etcd"].includes(c.db_type)),
);
const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "etcd"].includes(c.db_type)));
const canExport = computed(
() =>
connectionId.value &&
database.value &&
schema.value &&
!loadingTables.value &&
!tableError.value &&
(tables.value.length === 0 || selectedTables.value.length > 0) &&
(includeStructure.value || includeData.value || includeObjects.value) &&
!isExporting.value,
);
const canExport = computed(() => connectionId.value && database.value && schema.value && !loadingTables.value && !tableError.value && (tables.value.length === 0 || selectedTables.value.length > 0) && (includeStructure.value || includeData.value || includeObjects.value) && !isExporting.value);
const selectedTableSet = computed(() => new Set(selectedTables.value));
@@ -121,12 +109,7 @@ async function loadSchemas(preferredSchema = "") {
}
const schemaList = await api.listSchemas(connectionId.value, database.value);
const selected =
preferredSchema && schemaList.includes(preferredSchema)
? preferredSchema
: schemaList.includes("public")
? "public"
: (schemaList[0] ?? "");
const selected = preferredSchema && schemaList.includes(preferredSchema) ? preferredSchema : schemaList.includes("public") ? "public" : (schemaList[0] ?? "");
schemas.value = schemaList;
schema.value = selected;
}
@@ -142,12 +125,7 @@ async function loadTables(preferredTable = "", preferredTables: string[] = []) {
const names = tableInfos.map((table) => table.name);
tables.value = names;
const preferredSet = new Set(preferredTables.filter((name) => names.includes(name)));
selectedTables.value =
preferredSet.size > 0
? names.filter((name) => preferredSet.has(name))
: preferredTable && names.includes(preferredTable)
? [preferredTable]
: [...names];
selectedTables.value = preferredSet.size > 0 ? names.filter((name) => preferredSet.has(name)) : preferredTable && names.includes(preferredTable) ? [preferredTable] : [...names];
} catch (e: any) {
tableError.value = e?.message || String(e);
} finally {
@@ -425,13 +403,7 @@ watch(
</Button>
</div>
<div class="max-h-40 overflow-auto space-y-1 pr-1">
<button
v-for="table in filteredTables"
:key="table"
type="button"
class="flex w-full min-w-0 items-center gap-2 rounded px-1.5 py-1 text-left text-xs hover:bg-muted"
@click="toggleTable(table)"
>
<button v-for="table in filteredTables" :key="table" type="button" class="flex w-full min-w-0 items-center gap-2 rounded px-1.5 py-1 text-left text-xs hover:bg-muted" @click="toggleTable(table)">
<CheckSquare v-if="selectedTableSet.has(table)" class="w-3.5 h-3.5 text-primary shrink-0" />
<Square v-else class="w-3.5 h-3.5 text-muted-foreground/40 shrink-0" />
<span class="truncate">{{ table }}</span>
@@ -453,11 +425,7 @@ watch(
<Square v-else class="w-3.5 h-3.5 text-muted-foreground/40 shrink-0" />
{{ t("databaseExport.includeStructure") }}
</div>
<div
class="flex items-center gap-2 text-xs"
:class="includeStructure ? 'cursor-pointer' : 'cursor-not-allowed text-muted-foreground/50'"
@click="includeStructure && (dropTableIfExists = !dropTableIfExists)"
>
<div class="flex items-center gap-2 text-xs" :class="includeStructure ? 'cursor-pointer' : 'cursor-not-allowed text-muted-foreground/50'" @click="includeStructure && (dropTableIfExists = !dropTableIfExists)">
<CheckSquare v-if="dropTableIfExists && includeStructure" class="w-3.5 h-3.5 text-primary shrink-0" />
<Square v-else class="w-3.5 h-3.5 text-muted-foreground/40 shrink-0" />
{{ t("databaseExport.dropTableIfExists") }}
@@ -489,11 +457,7 @@ watch(
</div>
<div class="w-full bg-muted rounded-full h-2 overflow-hidden">
<div
class="h-full rounded-full transition-all duration-300"
:class="exportError ? 'bg-destructive' : exportCancelled ? 'bg-yellow-500' : 'bg-primary'"
:style="{ width: `${progressPercent}%` }"
/>
<div class="h-full rounded-full transition-all duration-300" :class="exportError ? 'bg-destructive' : exportCancelled ? 'bg-yellow-500' : 'bg-primary'" :style="{ width: `${progressPercent}%` }" />
</div>
<div class="text-xs text-muted-foreground">
@@ -61,12 +61,7 @@ const rowsText = computed(() => {
<!-- Progress bar -->
<div class="w-full bg-muted rounded-full h-2 overflow-hidden">
<div
v-if="status === 'Running' || status === 'Writing'"
class="h-full bg-primary rounded-full transition-all duration-300"
:class="{ 'animate-pulse': !totalRows }"
:style="{ width: totalRows ? `${progressPercent}%` : '50%' }"
/>
<div v-if="status === 'Running' || status === 'Writing'" class="h-full bg-primary rounded-full transition-all duration-300" :class="{ 'animate-pulse': !totalRows }" :style="{ width: totalRows ? `${progressPercent}%` : '50%' }" />
<div v-else-if="status === 'Done'" class="h-full bg-green-500 rounded-full" style="width: 100%" />
</div>
@@ -79,18 +79,9 @@ function toggleShowAll() {
<template>
<Popover v-if="tasks.length > 0" v-model:open="open">
<PopoverTrigger as-child>
<Button
variant="ghost"
size="icon"
class="relative h-8 w-8"
:title="t('exportProgress.tooltip')"
:class="{ 'bg-accent text-primary': hasActive }"
>
<Button variant="ghost" size="icon" class="relative h-8 w-8" :title="t('exportProgress.tooltip')" :class="{ 'bg-accent text-primary': hasActive }">
<FileDown class="h-4 w-4" />
<span
v-if="hasActive"
class="absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium leading-none text-primary-foreground"
>
<span v-if="hasActive" class="absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium leading-none text-primary-foreground">
{{ activeCount > 9 ? "9+" : activeCount }}
</span>
</Button>
@@ -102,28 +93,16 @@ function toggleShowAll() {
</div>
<div class="max-h-80 overflow-y-auto">
<div
v-for="task in visibleTasks"
:key="task.exportId"
class="flex items-center gap-2 border-b px-3 py-2.5 text-xs last:border-b-0"
>
<div v-for="task in visibleTasks" :key="task.exportId" class="flex items-center gap-2 border-b px-3 py-2.5 text-xs last:border-b-0">
<div class="flex-1 min-w-0 flex flex-col gap-1">
<div class="flex items-center gap-1.5">
<component
:is="statusIcon(task.status)"
:class="[statusColor(task.status), isActive(task.status) ? 'animate-spin' : '']"
class="h-3.5 w-3.5 shrink-0"
/>
<component :is="statusIcon(task.status)" :class="[statusColor(task.status), isActive(task.status) ? 'animate-spin' : '']" class="h-3.5 w-3.5 shrink-0" />
<span class="truncate font-medium">{{ task.tableName }}.{{ task.format }}</span>
</div>
<!-- Progress bar -->
<div v-if="isActive(task.status)" class="w-full bg-muted rounded-full h-1.5 overflow-hidden">
<div
class="h-full bg-primary rounded-full transition-all duration-300"
:class="{ 'animate-pulse': !task.totalRows }"
:style="{ width: task.totalRows ? `${progressPercent(task.totalRows, task.rowsExported)}%` : '50%' }"
/>
<div class="h-full bg-primary rounded-full transition-all duration-300" :class="{ 'animate-pulse': !task.totalRows }" :style="{ width: task.totalRows ? `${progressPercent(task.totalRows, task.rowsExported)}%` : '50%' }" />
</div>
<div v-else-if="task.status === 'Done'" class="w-full bg-muted rounded-full h-1.5 overflow-hidden">
<div class="h-full bg-green-500 rounded-full" style="width: 100%" />
@@ -131,11 +110,7 @@ function toggleShowAll() {
<div class="flex items-center justify-between text-muted-foreground">
<span class="tabular-nums">{{ rowsText(task) }}</span>
<span
v-if="task.status === 'Error' && task.errorMessage"
class="truncate ml-2 text-destructive"
:title="task.errorMessage"
>
<span v-if="task.status === 'Error' && task.errorMessage" class="truncate ml-2 text-destructive" :title="task.errorMessage">
{{ task.errorMessage }}
</span>
</div>
@@ -143,20 +118,10 @@ function toggleShowAll() {
<!-- Actions: stop/cancel for active, delete for finished -->
<div class="flex shrink-0 self-center">
<button
v-if="isActive(task.status)"
class="flex h-6 w-6 items-center justify-center rounded hover:bg-muted"
:title="t('exportProgress.cancel')"
@click="cancelTask(task.exportId)"
>
<button v-if="isActive(task.status)" class="flex h-6 w-6 items-center justify-center rounded hover:bg-muted" :title="t('exportProgress.cancel')" @click="cancelTask(task.exportId)">
<X class="h-3.5 w-3.5 text-muted-foreground hover:text-destructive" />
</button>
<button
v-else
class="flex h-6 w-6 items-center justify-center rounded hover:bg-muted"
:title="t('exportProgress.delete')"
@click="removeTask(task.exportId)"
>
<button v-else class="flex h-6 w-6 items-center justify-center rounded hover:bg-muted" :title="t('exportProgress.delete')" @click="removeTask(task.exportId)">
<X class="h-3.5 w-3.5 text-muted-foreground hover:text-foreground" />
</button>
</div>
@@ -165,9 +130,7 @@ function toggleShowAll() {
<div v-if="hasMore" class="border-t bg-muted/30 px-3 py-1.5">
<button class="w-full text-center text-xs text-muted-foreground hover:text-foreground" @click="toggleShowAll">
{{
showAll ? t("exportProgress.showLess") : t("exportProgress.showMore", { count: tasks.length - MAX_VISIBLE })
}}
{{ showAll ? t("exportProgress.showLess") : t("exportProgress.showMore", { count: tasks.length - MAX_VISIBLE }) }}
</button>
</div>