mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 00:06:50 +00:00
wire sql file execution entry points
This commit is contained in:
+24
-1
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, onUnmounted, nextTick, type Ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { DatabaseZap, FilePlus2, Play, Loader2, Square, X, Globe, Moon, Sun, Upload, Download, Plus, History, Server, Table2, Database, Search, ShieldCheck, Bot, Pin, AlignLeft, CloudDownload, ArrowLeftRight } from "lucide-vue-next";
|
||||
import { DatabaseZap, FilePlus2, Play, Loader2, Square, X, Globe, Moon, Sun, Upload, Download, Plus, History, Server, Table2, Database, Search, ShieldCheck, Bot, Pin, AlignLeft, CloudDownload, ArrowLeftRight, FileCode } from "lucide-vue-next";
|
||||
import { Splitpanes, Pane } from "splitpanes";
|
||||
import "splitpanes/dist/splitpanes.css";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -35,6 +35,7 @@ import QueryHistory from "@/components/editor/QueryHistory.vue";
|
||||
import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";
|
||||
import DataTransferDialog from "@/components/transfer/DataTransferDialog.vue";
|
||||
import SchemaDiffDialog from "@/components/diff/SchemaDiffDialog.vue";
|
||||
import SqlFileExecutionDialog from "@/components/sql-file/SqlFileExecutionDialog.vue";
|
||||
import type { ConnectionConfig } from "@/types/database";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useQueryStore } from "@/stores/queryStore";
|
||||
@@ -115,10 +116,13 @@ const formatSqlRequestId = ref(0);
|
||||
const showDangerDialog = ref(false);
|
||||
const showTransferDialog = ref(false);
|
||||
const showSchemaDiffDialog = ref(false);
|
||||
const showSqlFileDialog = ref(false);
|
||||
const transferPrefillConnectionId = ref("");
|
||||
const transferPrefillDatabase = ref("");
|
||||
const schemaDiffPrefillConnectionId = ref("");
|
||||
const schemaDiffPrefillDatabase = ref("");
|
||||
const sqlFilePrefillConnectionId = ref("");
|
||||
const sqlFilePrefillDatabase = ref("");
|
||||
const databaseOptions = ref<Record<string, string[]>>({});
|
||||
const loadingDatabaseOptions = ref<Record<string, boolean>>({});
|
||||
const checkingUpdates = ref(false);
|
||||
@@ -159,6 +163,15 @@ watch(() => connectionStore.schemaDiffSource, (v) => {
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => connectionStore.sqlFileSource, (v) => {
|
||||
if (v) {
|
||||
sqlFilePrefillConnectionId.value = v.connectionId;
|
||||
sqlFilePrefillDatabase.value = v.database;
|
||||
showSqlFileDialog.value = true;
|
||||
connectionStore.sqlFileSource = null;
|
||||
}
|
||||
});
|
||||
|
||||
function onConnectionConnectStarted(name: string) {
|
||||
toast(t("connection.connecting", { name }), 30000);
|
||||
}
|
||||
@@ -699,6 +712,11 @@ async function setupFileDrop() {
|
||||
{{ t('transfer.dataTransfer') }}
|
||||
</Button>
|
||||
|
||||
<Button variant="ghost" size="sm" class="h-7 px-2 text-xs gap-1" @click="showSqlFileDialog = true" :disabled="!connectionStore.connections.length">
|
||||
<FileCode class="h-3.5 w-3.5" />
|
||||
{{ t('sqlFile.title') }}
|
||||
</Button>
|
||||
|
||||
<div class="flex-1" />
|
||||
|
||||
<Tooltip>
|
||||
@@ -1176,6 +1194,11 @@ async function setupFileDrop() {
|
||||
:prefill-connection-id="schemaDiffPrefillConnectionId"
|
||||
:prefill-database="schemaDiffPrefillDatabase"
|
||||
/>
|
||||
<SqlFileExecutionDialog
|
||||
v-model:open="showSqlFileDialog"
|
||||
:prefill-connection-id="sqlFilePrefillConnectionId"
|
||||
:prefill-database="sqlFilePrefillDatabase"
|
||||
/>
|
||||
<Dialog v-model:open="showUpdateDialog">
|
||||
<DialogContent class="sm:max-w-[520px]">
|
||||
<DialogHeader>
|
||||
|
||||
@@ -333,6 +333,15 @@ function openSchemaDiff() {
|
||||
}
|
||||
}
|
||||
|
||||
function openSqlFileExecution() {
|
||||
if (props.node.connectionId) {
|
||||
connectionStore.sqlFileSource = {
|
||||
connectionId: props.node.connectionId,
|
||||
database: props.node.database ?? "",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const canExpand = !leafTypes.has(props.node.type);
|
||||
const canPin = computed(() => pinnableTypes.has(props.node.type));
|
||||
const isPinned = computed(() => props.node.pinned || connectionStore.isTreeNodePinned(props.node.id));
|
||||
@@ -444,6 +453,9 @@ async function showMore() {
|
||||
<ContextMenuItem @click="newQuery">
|
||||
<TerminalSquare class="w-4 h-4" /> {{ t('contextMenu.newQuery') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="openSqlFileExecution">
|
||||
<FileCode class="w-4 h-4" /> {{ t('sqlFile.title') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuSeparator />
|
||||
<ContextMenuItem @click="refresh">
|
||||
<RefreshCw class="w-4 h-4" /> {{ t('contextMenu.refreshChildren') }}
|
||||
@@ -461,6 +473,9 @@ async function showMore() {
|
||||
<ContextMenuItem @click="newQuery">
|
||||
<TerminalSquare class="w-4 h-4" /> {{ t('contextMenu.newQuery') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="openSqlFileExecution">
|
||||
<FileCode class="w-4 h-4" /> {{ t('sqlFile.title') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="refresh">
|
||||
<RefreshCw class="w-4 h-4" /> {{ t('contextMenu.refreshChildren') }}
|
||||
</ContextMenuItem>
|
||||
|
||||
@@ -302,6 +302,38 @@ export default {
|
||||
overallProgress: "Overall progress",
|
||||
dataTransfer: "Data Transfer",
|
||||
},
|
||||
sqlFile: {
|
||||
title: "SQL File",
|
||||
file: "File",
|
||||
selectSqlFile: "Select SQL file",
|
||||
browse: "Browse",
|
||||
target: "Target",
|
||||
connection: "Connection",
|
||||
selectConnection: "Select connection",
|
||||
database: "Database",
|
||||
selectDatabase: "Select database",
|
||||
databasePlaceholder: "Database name",
|
||||
options: "Options",
|
||||
continueOnError: "Continue on error",
|
||||
cancelling: "Cancelling...",
|
||||
cancel: "Cancel",
|
||||
execute: "Execute",
|
||||
statement: "Statement",
|
||||
succeeded: "Succeeded",
|
||||
failed: "Failed",
|
||||
affectedRows: "Affected rows",
|
||||
currentStatement: "Current statement",
|
||||
status: {
|
||||
idle: "Idle",
|
||||
started: "Started",
|
||||
running: "Running",
|
||||
statementDone: "Statement done",
|
||||
statementFailed: "Statement failed",
|
||||
done: "Done",
|
||||
error: "Error",
|
||||
cancelled: "Cancelled",
|
||||
},
|
||||
},
|
||||
diff: {
|
||||
title: "Compare Databases",
|
||||
source: "Source",
|
||||
|
||||
@@ -302,6 +302,38 @@ export default {
|
||||
overallProgress: "整体进度",
|
||||
dataTransfer: "数据传输",
|
||||
},
|
||||
sqlFile: {
|
||||
title: "SQL 文件",
|
||||
file: "文件",
|
||||
selectSqlFile: "选择 SQL 文件",
|
||||
browse: "浏览",
|
||||
target: "目标",
|
||||
connection: "连接",
|
||||
selectConnection: "选择连接",
|
||||
database: "数据库",
|
||||
selectDatabase: "选择数据库",
|
||||
databasePlaceholder: "数据库名称",
|
||||
options: "选项",
|
||||
continueOnError: "出错后继续",
|
||||
cancelling: "正在取消...",
|
||||
cancel: "取消",
|
||||
execute: "执行",
|
||||
statement: "语句",
|
||||
succeeded: "成功",
|
||||
failed: "失败",
|
||||
affectedRows: "影响行数",
|
||||
currentStatement: "当前语句",
|
||||
status: {
|
||||
idle: "空闲",
|
||||
started: "已开始",
|
||||
running: "执行中",
|
||||
statementDone: "语句完成",
|
||||
statementFailed: "语句失败",
|
||||
done: "完成",
|
||||
error: "错误",
|
||||
cancelled: "已取消",
|
||||
},
|
||||
},
|
||||
diff: {
|
||||
title: "比较数据库",
|
||||
source: "源数据库",
|
||||
|
||||
Reference in New Issue
Block a user