Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/plugins/iotdb/components/Meta/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function Meta(props: Props) {
if (node.levelType === 'tables' && node.database) {
const tables = await getTables({
...baseParams,
db: node.database,
query: [node.database],
});
setTreeData((origin) =>
updateTreeData(
Expand All @@ -87,22 +87,21 @@ export default function Meta(props: Props) {
} else if (node.levelType === 'table' && node.database && node.table) {
const columns = await getColumns({
...baseParams,
db: node.database,
table: node.table,
query: [{ database: node.database, table: node.table }],
});
setTreeData((origin) =>
updateTreeData(
origin,
key,
_.map(columns, (item) => {
return {
title: `${item.name} (${item.type})`,
key: `${key}.${item.name}`,
title: `${item.field} (${item.type})`,
key: `${key}.${item.field}`,
isLeaf: true,
levelType: 'field',
database: node.database,
table: node.table,
field: item.name,
field: item.field,
type: item.type,
};
}),
Expand Down
20 changes: 9 additions & 11 deletions src/plugins/iotdb/services.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import request from '@/utils/request';
import { RequestMethod } from '@/store/common';
import { DatasourceCateEnum } from '@/utils/constant';
import { BaseParams } from './types';

const getDatasourceCate = (cate?: string) => encodeURIComponent(cate || DatasourceCateEnum.iotdb);

export function getDatabases(data: BaseParams): Promise<string[]> {
return request(`/api/n9e/${getDatasourceCate(data.cate)}-databases`, {
return request('/api/n9e/db-databases', {
method: RequestMethod.Post,
data,
}).then((res) => {
Expand All @@ -16,10 +13,10 @@ export function getDatabases(data: BaseParams): Promise<string[]> {

export function getTables(
data: BaseParams & {
db: string;
query: string[];
},
): Promise<string[]> {
return request(`/api/n9e/${getDatasourceCate(data.cate)}-tables`, {
return request('/api/n9e/db-tables', {
method: RequestMethod.Post,
data,
}).then((res) => {
Expand All @@ -29,17 +26,18 @@ export function getTables(

export function getColumns(
data: BaseParams & {
db: string;
table: string;
query: {
database: string;
table: string;
}[];
},
): Promise<
{
name: string;
field: string;
type: string;
size: number;
}[]
> {
return request(`/api/n9e/${getDatasourceCate(data.cate)}-columns`, {
return request('/api/n9e/db-desc-table', {
method: RequestMethod.Post,
data,
}).then((res) => {
Expand Down