feat(db): 支持 VictoriaMetrics 数据库
* feat(victoriametrics): support native MetricsQL queries * fix(victoriametrics): 完善指标浏览和结果导出 * fix(victoriametrics): 修复指标对象通用操作入口 * fix(victoriametrics): 修正指标注释和截断提示 * fix(i18n): 补齐 VictoriaMetrics 连接配置翻译 --------- Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
1 parent
930aa48c20
commit
2ede64f1cb
64 files changed
+1293
-64
No files matched your search
@@ -891,7 +891,7 @@ function normalizedTreeClipboardTableEntries(): TableClipboardTableContext[] {
|
||||
}
|
||||
|
||||
function canPasteTreeClipboardToCurrentNode(): boolean {
|
||||
return tableClipboardMatchesTarget(normalizedTreeClipboardTableEntries(), pasteTableTargetContext());
|
||||
return currentDatabaseType() !== "victoriametrics" && tableClipboardMatchesTarget(normalizedTreeClipboardTableEntries(), pasteTableTargetContext());
|
||||
}
|
||||
|
||||
function canTransferTreeClipboardToCurrentNode(): boolean {
|
||||
@@ -924,6 +924,7 @@ function openTransferFromTreeClipboard(): boolean {
|
||||
}
|
||||
|
||||
function requestPasteTreeClipboard(): boolean {
|
||||
if (currentDatabaseType() === "victoriametrics") return false;
|
||||
claimTreeItemDialogOwnership();
|
||||
ensureDangerDialogRouting();
|
||||
routeTreeItemDialogController();
|
||||
@@ -1376,6 +1377,7 @@ async function newDeleteTemplate() {
|
||||
}
|
||||
|
||||
async function generateDdlTemplate() {
|
||||
if (currentDatabaseType() === "victoriametrics") return;
|
||||
const targets = selectedDdlTargets();
|
||||
if (!targets.length) return;
|
||||
const tabTarget = targets.find((target) => target.id === activeNode.value.id) ?? targets[0]!;
|
||||
@@ -1411,6 +1413,7 @@ function selectedDdlTargets() {
|
||||
}
|
||||
|
||||
async function openDdl() {
|
||||
if (currentDatabaseType() === "victoriametrics") return;
|
||||
const targets = selectedDdlTargets();
|
||||
if (!targets.length) return;
|
||||
if (targets.length > 1) {
|
||||
@@ -1471,6 +1474,10 @@ function updateTreeClipboardForNodes(nodes: TreeNode[]) {
|
||||
connectionStore.treeClipboard = null;
|
||||
return;
|
||||
}
|
||||
if (tableNodes.some((node) => databaseTypeForNode(node) === "victoriametrics")) {
|
||||
connectionStore.treeClipboard = null;
|
||||
return;
|
||||
}
|
||||
connectionStore.treeClipboard = {
|
||||
kind: "table-copy",
|
||||
tables: tableNodes.map((node) => ({
|
||||
@@ -3083,6 +3090,7 @@ async function confirmDropSchema() {
|
||||
|
||||
function duplicateStructure(source: TreeNode = activeNode.value) {
|
||||
if (!isDuplicateStructureSource(source)) return;
|
||||
if (databaseTypeForNode(source) === "victoriametrics") return;
|
||||
duplicateStructureSource.value = source;
|
||||
duplicateTableName.value = `${source.label}_copy`;
|
||||
showDuplicateDialog.value = true;
|
||||
@@ -3096,6 +3104,7 @@ async function confirmDuplicateStructure() {
|
||||
const node = duplicateStructureSource.value || (isDuplicateStructureSource(activeNode.value) ? activeNode.value : null);
|
||||
const newName = duplicateTableName.value.trim();
|
||||
if (!newName || !node) return;
|
||||
if (databaseTypeForNode(node) === "victoriametrics") return;
|
||||
showDuplicateDialog.value = false;
|
||||
try {
|
||||
await connectionStore.ensureConnected(node.connectionId);
|
||||
@@ -3840,16 +3849,17 @@ const shortcutRefresh = "F5";
|
||||
|
||||
const shortcutDelete = "Delete";
|
||||
|
||||
function exportDataSubmenu(): ContextMenuItem {
|
||||
function exportDataSubmenu(includeSqlInsert = true): ContextMenuItem {
|
||||
const children: ContextMenuItem[] = [
|
||||
{ label: "CSV", action: () => exportData("csv") },
|
||||
{ label: "JSON", action: () => exportData("json") },
|
||||
];
|
||||
if (includeSqlInsert) children.push({ label: "SQL INSERT", action: () => exportData("sql") });
|
||||
children.push({ label: "XLSX", action: () => exportDataXlsx() });
|
||||
return {
|
||||
label: t("contextMenu.exportData"),
|
||||
icon: Upload,
|
||||
children: [
|
||||
{ label: "CSV", action: () => exportData("csv") },
|
||||
{ label: "JSON", action: () => exportData("json") },
|
||||
{ label: "SQL INSERT", action: () => exportData("sql") },
|
||||
{ label: "XLSX", action: () => exportDataXlsx() },
|
||||
],
|
||||
children,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4349,6 +4359,17 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
const { node, items, deleteMenuLabel, deleteMenuAction, truncateMenuLabel, truncateMenuAction, emptyMenuLabel, emptyMenuAction } = context;
|
||||
// 6. Table / View / Materialized View
|
||||
if (node.type === "table" || node.type === "view" || node.type === "materialized_view") {
|
||||
if (currentDatabaseType() === "victoriametrics" && node.type === "table") {
|
||||
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
|
||||
items.push({ label: "", separator: true });
|
||||
items.push({ label: t("contextMenu.viewData"), action: openDataImmediately, icon: TableProperties });
|
||||
items.push({ label: t("contextMenu.openInNewDataTab"), action: openDataInNewTabImmediately, icon: CopyPlus });
|
||||
items.push({ label: t("contextMenu.newQuery"), action: newQuery, icon: TerminalSquare });
|
||||
items.push({ label: "", separator: true });
|
||||
items.push(exportDataSubmenu(false));
|
||||
items.push({ label: t("contextMenu.refreshChildren"), action: refresh, icon: RefreshCw, shortcut: shortcutRefresh });
|
||||
return true;
|
||||
}
|
||||
const destructiveActions: ContextMenuItem[] = [];
|
||||
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
|
||||
items.push({ label: "", separator: true });
|
||||
@@ -4568,6 +4589,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
}
|
||||
|
||||
function treeTableClipboardMenuItems(node: TreeNode): ContextMenuItem[] {
|
||||
if (currentDatabaseType() === "victoriametrics") return [];
|
||||
const copyItem: ContextMenuItem = { label: t("contextMenu.copyTable"), action: copySelectedNames, icon: Copy };
|
||||
if (!node.connectionId || !node.database) return [copyItem];
|
||||
const state = tableClipboardMenuState(
|
||||
|
||||
Reference in new issue
Block a user