feat(dameng): add user and role administration
This commit is contained in:
1 parent
9bacb752e4
commit
ec4f8582e6
25 files changed
+3435
-4
No files matched your search
@@ -1380,6 +1380,34 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
};
|
||||
}
|
||||
|
||||
function buildDamengUserNode(connectionId: string, existingConnectionNode?: TreeNode): TreeNode | undefined {
|
||||
const config = getConfig(connectionId);
|
||||
if (effectiveDatabaseTypeForConnection(config) !== "dameng") return undefined;
|
||||
const existing = existingConnectionNode?.children?.find((child) => child.type === "dameng-users");
|
||||
return {
|
||||
id: `${connectionId}:__dameng_users`,
|
||||
label: "tree.damengUsers",
|
||||
type: "dameng-users",
|
||||
connectionId,
|
||||
database: "",
|
||||
isExpanded: existing?.isExpanded ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
function buildDamengRoleNode(connectionId: string, existingConnectionNode?: TreeNode): TreeNode | undefined {
|
||||
const config = getConfig(connectionId);
|
||||
if (effectiveDatabaseTypeForConnection(config) !== "dameng") return undefined;
|
||||
const existing = existingConnectionNode?.children?.find((child) => child.type === "dameng-roles");
|
||||
return {
|
||||
id: `${connectionId}:__dameng_roles`,
|
||||
label: "tree.damengRoles",
|
||||
type: "dameng-roles",
|
||||
connectionId,
|
||||
database: "",
|
||||
isExpanded: existing?.isExpanded ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
function buildDamengJobAdminNode(connectionId: string, existingConnectionNode?: TreeNode): TreeNode | undefined {
|
||||
const config = getConfig(connectionId);
|
||||
if (effectiveDatabaseTypeForConnection(config) !== "dameng") return undefined;
|
||||
@@ -1397,8 +1425,10 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
function withConnectionUtilityNodes(connectionId: string, children: TreeNode[], existingConnectionNode?: TreeNode): TreeNode[] {
|
||||
const nonUtilityChildren = connectionMetadataChildren(children);
|
||||
const userAdminNode = buildUserAdminNode(connectionId, existingConnectionNode);
|
||||
const damengUserNode = buildDamengUserNode(connectionId, existingConnectionNode);
|
||||
const damengRoleNode = buildDamengRoleNode(connectionId, existingConnectionNode);
|
||||
const damengJobAdminNode = buildDamengJobAdminNode(connectionId, existingConnectionNode);
|
||||
return [...nonUtilityChildren, userAdminNode, damengJobAdminNode].filter(Boolean) as TreeNode[];
|
||||
return [...nonUtilityChildren, userAdminNode, damengUserNode, damengRoleNode, damengJobAdminNode].filter(Boolean) as TreeNode[];
|
||||
}
|
||||
|
||||
function withSavedSqlRoot(connectionId: string, children: TreeNode[], existingConnectionNode?: TreeNode): TreeNode[] {
|
||||
|
||||
@@ -1880,6 +1880,56 @@ export const useQueryStore = defineStore("query", () => {
|
||||
return id;
|
||||
}
|
||||
|
||||
function openDamengUsers(connectionId: string) {
|
||||
const existing = tabs.value.find((tab) => tab.mode === "dameng-users" && tab.connectionId === connectionId);
|
||||
if (existing) {
|
||||
switchTab(existing.id);
|
||||
return existing.id;
|
||||
}
|
||||
|
||||
const conn = useConnectionStore().getConfig(connectionId);
|
||||
const id = uuid();
|
||||
const tab: QueryTab = {
|
||||
id,
|
||||
title: t("damengUserAdmin.title"),
|
||||
connectionId,
|
||||
database: conn?.database || "",
|
||||
sql: "",
|
||||
isExecuting: false,
|
||||
isCancelling: false,
|
||||
isExplaining: false,
|
||||
mode: "dameng-users",
|
||||
};
|
||||
tabs.value.push(tab);
|
||||
activeTabId.value = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
function openDamengRoles(connectionId: string) {
|
||||
const existing = tabs.value.find((tab) => tab.mode === "dameng-roles" && tab.connectionId === connectionId);
|
||||
if (existing) {
|
||||
switchTab(existing.id);
|
||||
return existing.id;
|
||||
}
|
||||
|
||||
const conn = useConnectionStore().getConfig(connectionId);
|
||||
const id = uuid();
|
||||
const tab: QueryTab = {
|
||||
id,
|
||||
title: t("damengRoleAdmin.title"),
|
||||
connectionId,
|
||||
database: conn?.database || "",
|
||||
sql: "",
|
||||
isExecuting: false,
|
||||
isCancelling: false,
|
||||
isExplaining: false,
|
||||
mode: "dameng-roles",
|
||||
};
|
||||
tabs.value.push(tab);
|
||||
activeTabId.value = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
function openMongoBucket(connectionId: string, database: string, bucketName: string) {
|
||||
const title = `${database}.${bucketName}`;
|
||||
const existing = tabs.value.find((tab) => tab.mode === "mongo-bucket" && tab.connectionId === connectionId && tab.database === database && tab.mongoBucket?.bucketName === bucketName);
|
||||
@@ -5768,6 +5818,8 @@ export const useQueryStore = defineStore("query", () => {
|
||||
openMysqlDashboard,
|
||||
openPostgresDashboard,
|
||||
openNacosDashboard,
|
||||
openDamengUsers,
|
||||
openDamengRoles,
|
||||
openDamengJobAdmin,
|
||||
openMqAdmin,
|
||||
openMqttAdmin,
|
||||
|
||||
Reference in new issue
Block a user