From ccef94ff866e1e3d1cc4f6281d8906c420ade975 Mon Sep 17 00:00:00 2001 From: "ruiyi.jiang" Date: Mon, 7 Aug 2023 09:37:21 +0800 Subject: [PATCH] refactor http export/import Signed-off-by: ruiyi.jiang --- client/src/components/layout/Header.tsx | 2 +- client/src/context/Auth.tsx | 2 +- client/src/context/Database.tsx | 2 +- client/src/context/Prometheus.tsx | 2 +- client/src/context/Root.tsx | 2 +- client/src/context/WebSocket.tsx | 4 +- client/src/http/Index.ts | 117 ++---------------- client/src/http/MilvusIndex.ts | 107 ++++++++++++++++ client/src/pages/collections/Aliases.tsx | 2 +- client/src/pages/collections/Collections.tsx | 3 +- client/src/pages/connect/AuthForm.tsx | 2 +- client/src/pages/database/Database.tsx | 2 +- .../src/pages/dialogs/CreateAliasDialog.tsx | 2 +- .../pages/dialogs/CreateCollectionDialog.tsx | 2 +- .../pages/dialogs/CreatePartitionDialog.tsx | 2 +- .../pages/dialogs/DropCollectionDialog.tsx | 2 +- .../src/pages/dialogs/DropPartitionDialog.tsx | 4 +- .../src/pages/dialogs/ImportSampleDialog.tsx | 3 +- .../pages/dialogs/LoadCollectionDialog.tsx | 5 +- .../pages/dialogs/ReleaseCollectionDialog.tsx | 4 +- .../pages/dialogs/RenameCollectionDialog.tsx | 6 +- client/src/pages/dialogs/insert/Dialog.tsx | 2 +- client/src/pages/overview/Overview.tsx | 3 +- client/src/pages/partitions/Partitions.tsx | 5 +- client/src/pages/preview/Preview.tsx | 10 +- client/src/pages/query/Query.tsx | 9 +- client/src/pages/schema/IndexTypeElement.tsx | 12 +- client/src/pages/schema/Schema.tsx | 3 +- client/src/pages/search/VectorSearch.tsx | 3 +- client/src/pages/system/SystemView.tsx | 4 +- .../pages/systemHealthy/SystemHealthyView.tsx | 2 +- client/src/pages/user/Roles.tsx | 6 +- client/src/pages/user/UpdateRoleDialog.tsx | 2 +- client/src/pages/user/UpdateUserRole.tsx | 2 +- client/src/pages/user/User.tsx | 2 +- 35 files changed, 169 insertions(+), 173 deletions(-) create mode 100644 client/src/http/MilvusIndex.ts diff --git a/client/src/components/layout/Header.tsx b/client/src/components/layout/Header.tsx index bdbe497f..f19099bc 100644 --- a/client/src/components/layout/Header.tsx +++ b/client/src/components/layout/Header.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { makeStyles, Theme, createStyles, Typography } from '@material-ui/core'; import { useNavigate } from 'react-router-dom'; import { navContext, databaseContext, authContext } from '@/context'; -import { MilvusHttp } from '@/http/Milvus'; +import { MilvusHttp } from '@/http'; import { MILVUS_ADDRESS } from '@/consts'; import CustomSelector from '@/components/customSelector/CustomSelector'; import icons from '../icons/Icons'; diff --git a/client/src/context/Auth.tsx b/client/src/context/Auth.tsx index 434b5df9..0943c549 100644 --- a/client/src/context/Auth.tsx +++ b/client/src/context/Auth.tsx @@ -1,6 +1,6 @@ import { createContext, useEffect, useState } from 'react'; import { MILVUS_ADDRESS } from '@/consts'; -import { MilvusHttp } from '@/http/Milvus'; +import { MilvusHttp } from '@/http'; import { AuthContextType } from './Types'; export const authContext = createContext({ diff --git a/client/src/context/Database.tsx b/client/src/context/Database.tsx index 6b0e5c17..6f6751fb 100644 --- a/client/src/context/Database.tsx +++ b/client/src/context/Database.tsx @@ -1,5 +1,5 @@ import { createContext, useEffect, useState } from 'react'; -import { DatabaseHttp } from '@/http/Database'; +import { DatabaseHttp } from '@/http'; import { DatabaseContextType } from './Types'; export const databaseContext = createContext({ diff --git a/client/src/context/Prometheus.tsx b/client/src/context/Prometheus.tsx index 28b139f3..5439a6c3 100644 --- a/client/src/context/Prometheus.tsx +++ b/client/src/context/Prometheus.tsx @@ -13,7 +13,7 @@ import { WITH_PROMETHEUS, } from '@/consts'; import { formatPrometheusAddress } from '@/utils'; -import { PrometheusHttp } from '@/http/Prometheus'; +import { PrometheusHttp } from '@/http'; export const prometheusContext = createContext({ withPrometheus: false, diff --git a/client/src/context/Root.tsx b/client/src/context/Root.tsx index 84662ee8..3763b84d 100644 --- a/client/src/context/Root.tsx +++ b/client/src/context/Root.tsx @@ -11,7 +11,7 @@ import { } from './Types'; import CustomSnackBar from '@/components/customSnackBar/CustomSnackBar'; import CustomDialog from '@/components/customDialog/CustomDialog'; -import { MilvusHttp } from '@/http/Milvus'; +import { MilvusHttp } from '@/http'; import { theme } from '../styles/theme'; const DefaultDialogConfigs: DialogType = { diff --git a/client/src/context/WebSocket.tsx b/client/src/context/WebSocket.tsx index 271d73c3..0826bc87 100644 --- a/client/src/context/WebSocket.tsx +++ b/client/src/context/WebSocket.tsx @@ -2,9 +2,7 @@ import { createContext, useContext, useEffect, useState, useRef } from 'react'; import { io, Socket } from 'socket.io-client'; import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts'; import { authContext } from '@/context'; -import { url } from '@/http/Axios'; -import { CollectionHttp } from '@/http/Collection'; -import { MilvusHttp } from '@/http/Milvus'; +import { url, CollectionHttp, MilvusHttp } from '@/http'; import { CollectionView } from '@/pages/collections/Types'; import { checkIndexBuilding, checkLoading } from '@/utils'; import { WebSocketType } from './Types'; diff --git a/client/src/http/Index.ts b/client/src/http/Index.ts index 15eb150d..733c0289 100644 --- a/client/src/http/Index.ts +++ b/client/src/http/Index.ts @@ -1,107 +1,10 @@ -import { - IndexCreateParam, - IndexManageParam, - IndexView, -} from '../pages/schema/Types'; -import { ManageRequestMethods } from '../types/Common'; -import { IndexState } from '../types/Milvus'; -import { findKeyValue } from '../utils/Common'; -import { getKeyValueListFromJsonString } from '../utils/Format'; -import BaseModel from './BaseModel'; - -export class IndexHttp extends BaseModel implements IndexView { - params!: { key: string; value: string }[]; - field_name!: string; - index_name!: string; - - constructor(props: {}) { - super(props); - Object.assign(this, props); - } - - static BASE_URL = `/schema/index`; - - static async getIndexStatus( - collectionName: string, - fieldName: string, - indexName: string - ): Promise<{ state: IndexState }> { - const path = `${this.BASE_URL}/state`; - return super.search({ - path, - params: { - collection_name: collectionName, - field_name: fieldName, - index_name: indexName, - }, - }); - } - - static async getIndexInfo(collectionName: string): Promise { - const path = this.BASE_URL; - - const res = await super.findAll({ - path, - params: { collection_name: collectionName }, - }); - return res.index_descriptions.map((index: any) => new this(index)); - } - - static async createIndex(param: IndexCreateParam) { - const path = this.BASE_URL; - const type: ManageRequestMethods = ManageRequestMethods.CREATE; - - return super.create({ - path, - data: { ...param, type }, - }); - } - - static async deleteIndex(param: IndexManageParam) { - const path = this.BASE_URL; - const type: ManageRequestMethods = ManageRequestMethods.DELETE; - - return super.batchDelete({ path, data: { ...param, type } }); - } - - static async getIndexBuildProgress( - collectionName: string, - fieldName: string, - indexName: string - ) { - const path = `${this.BASE_URL}/progress`; - return super.search({ - path, - params: { - collection_name: collectionName, - field_name: fieldName, - index_name: indexName, - }, - }); - } - - get _indexType() { - return this.params.find(p => p.key === 'index_type')?.value || ''; - } - get _indexName() { - return this.index_name; - } - - get _indexParameterPairs() { - const metricType = this.params.filter(v => v.key === 'metric_type'); - // parms is json string, so we need parse it to key value array - const params = findKeyValue(this.params, 'params'); - if (params) { - return [...metricType, ...getKeyValueListFromJsonString(params)]; - } - return metricType; - } - - get _fieldName() { - return this.field_name; - } - - get _metricType() { - return this.params.find(p => p.key === 'metric_type')?.value || ''; - } -} +export * from './Axios'; +export * from './BaseModel'; +export * from './Collection'; +export * from './Database'; +export * from './Milvus'; +export * from './MilvusIndex'; +export * from './Field'; +export * from './Partition'; +export * from './Prometheus'; +export * from './User'; diff --git a/client/src/http/MilvusIndex.ts b/client/src/http/MilvusIndex.ts new file mode 100644 index 00000000..15eb150d --- /dev/null +++ b/client/src/http/MilvusIndex.ts @@ -0,0 +1,107 @@ +import { + IndexCreateParam, + IndexManageParam, + IndexView, +} from '../pages/schema/Types'; +import { ManageRequestMethods } from '../types/Common'; +import { IndexState } from '../types/Milvus'; +import { findKeyValue } from '../utils/Common'; +import { getKeyValueListFromJsonString } from '../utils/Format'; +import BaseModel from './BaseModel'; + +export class IndexHttp extends BaseModel implements IndexView { + params!: { key: string; value: string }[]; + field_name!: string; + index_name!: string; + + constructor(props: {}) { + super(props); + Object.assign(this, props); + } + + static BASE_URL = `/schema/index`; + + static async getIndexStatus( + collectionName: string, + fieldName: string, + indexName: string + ): Promise<{ state: IndexState }> { + const path = `${this.BASE_URL}/state`; + return super.search({ + path, + params: { + collection_name: collectionName, + field_name: fieldName, + index_name: indexName, + }, + }); + } + + static async getIndexInfo(collectionName: string): Promise { + const path = this.BASE_URL; + + const res = await super.findAll({ + path, + params: { collection_name: collectionName }, + }); + return res.index_descriptions.map((index: any) => new this(index)); + } + + static async createIndex(param: IndexCreateParam) { + const path = this.BASE_URL; + const type: ManageRequestMethods = ManageRequestMethods.CREATE; + + return super.create({ + path, + data: { ...param, type }, + }); + } + + static async deleteIndex(param: IndexManageParam) { + const path = this.BASE_URL; + const type: ManageRequestMethods = ManageRequestMethods.DELETE; + + return super.batchDelete({ path, data: { ...param, type } }); + } + + static async getIndexBuildProgress( + collectionName: string, + fieldName: string, + indexName: string + ) { + const path = `${this.BASE_URL}/progress`; + return super.search({ + path, + params: { + collection_name: collectionName, + field_name: fieldName, + index_name: indexName, + }, + }); + } + + get _indexType() { + return this.params.find(p => p.key === 'index_type')?.value || ''; + } + get _indexName() { + return this.index_name; + } + + get _indexParameterPairs() { + const metricType = this.params.filter(v => v.key === 'metric_type'); + // parms is json string, so we need parse it to key value array + const params = findKeyValue(this.params, 'params'); + if (params) { + return [...metricType, ...getKeyValueListFromJsonString(params)]; + } + return metricType; + } + + get _fieldName() { + return this.field_name; + } + + get _metricType() { + return this.params.find(p => p.key === 'metric_type')?.value || ''; + } +} diff --git a/client/src/pages/collections/Aliases.tsx b/client/src/pages/collections/Aliases.tsx index b51a6894..291bdf11 100644 --- a/client/src/pages/collections/Aliases.tsx +++ b/client/src/pages/collections/Aliases.tsx @@ -7,7 +7,7 @@ import icons from '@/components/icons/Icons'; import DeleteIcon from '@material-ui/icons/Delete'; import CreateAliasDialog from '../dialogs/CreateAliasDialog'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp } from '@/http'; const useStyles = makeStyles((theme: Theme) => ({ wrapper: { diff --git a/client/src/pages/collections/Collections.tsx b/client/src/pages/collections/Collections.tsx index ee3677aa..bcd849eb 100644 --- a/client/src/pages/collections/Collections.tsx +++ b/client/src/pages/collections/Collections.tsx @@ -22,14 +22,13 @@ import { ChildrenStatusType } from '@/components/status/Types'; import StatusIcon from '@/components/status/StatusIcon'; import CustomToolTip from '@/components/customToolTip/CustomToolTip'; import CreateCollectionDialog from '../dialogs/CreateCollectionDialog'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp, MilvusHttp } from '@/http'; import LoadCollectionDialog from '../dialogs/LoadCollectionDialog'; import ReleaseCollectionDialog from '../dialogs/ReleaseCollectionDialog'; import DropCollectionDialog from '../dialogs/DropCollectionDialog'; import RenameCollectionDialog from '../dialogs/RenameCollectionDialog'; import InsertDialog from '../dialogs/insert/Dialog'; import ImportSampleDialog from '../dialogs/ImportSampleDialog'; -import { MilvusHttp } from '@/http/Milvus'; import { LOADING_STATE, WS_EVENTS, WS_EVENTS_TYPE } from '@/consts'; import { checkIndexBuilding, checkLoading } from '@/utils'; import Aliases from './Aliases'; diff --git a/client/src/pages/connect/AuthForm.tsx b/client/src/pages/connect/AuthForm.tsx index ec3af591..d1e13877 100644 --- a/client/src/pages/connect/AuthForm.tsx +++ b/client/src/pages/connect/AuthForm.tsx @@ -7,7 +7,7 @@ import icons from '@/components/icons/Icons'; import { ITextfieldConfig } from '@/components/customInput/Types'; import { useFormValidation } from '@/hooks'; import { formatForm } from '@/utils'; -import { MilvusHttp } from '@/http/Milvus'; +import { MilvusHttp } from '@/http'; import { useNavigate } from 'react-router-dom'; import { rootContext, authContext, prometheusContext } from '@/context'; import { MILVUS_ADDRESS, LAST_TIME_ADDRESS, MILVUS_URL } from '@/consts'; diff --git a/client/src/pages/database/Database.tsx b/client/src/pages/database/Database.tsx index c47993a3..e511b1cd 100644 --- a/client/src/pages/database/Database.tsx +++ b/client/src/pages/database/Database.tsx @@ -1,6 +1,6 @@ import { useContext, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { DatabaseHttp } from '@/http/Database'; +import { DatabaseHttp } from '@/http'; import AttuGrid from '@/components/grid/Grid'; import { ColDefinitionsType, ToolBarConfig } from '@/components/grid/Types'; import { diff --git a/client/src/pages/dialogs/CreateAliasDialog.tsx b/client/src/pages/dialogs/CreateAliasDialog.tsx index 51ffde99..110df33a 100644 --- a/client/src/pages/dialogs/CreateAliasDialog.tsx +++ b/client/src/pages/dialogs/CreateAliasDialog.tsx @@ -7,7 +7,7 @@ import CustomInput from '@/components/customInput/CustomInput'; import { formatForm } from '@/utils'; import { useFormValidation } from '@/hooks'; import { ITextfieldConfig } from '@/components/customInput/Types'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp } from '@/http'; import { CreateAliasProps } from './Types'; const useStyles = makeStyles((theme: Theme) => ({ diff --git a/client/src/pages/dialogs/CreateCollectionDialog.tsx b/client/src/pages/dialogs/CreateCollectionDialog.tsx index 9f13b46b..f8df3c0a 100644 --- a/client/src/pages/dialogs/CreateCollectionDialog.tsx +++ b/client/src/pages/dialogs/CreateCollectionDialog.tsx @@ -9,7 +9,7 @@ import { rootContext } from '@/context'; import { useFormValidation } from '@/hooks'; import { formatForm, TypeEnum } from '@/utils'; import CreateFields from '../collections/CreateFields'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp } from '@/http'; import { CollectionCreateParam, CollectionCreateProps, diff --git a/client/src/pages/dialogs/CreatePartitionDialog.tsx b/client/src/pages/dialogs/CreatePartitionDialog.tsx index 39ef2917..d58a4e9f 100644 --- a/client/src/pages/dialogs/CreatePartitionDialog.tsx +++ b/client/src/pages/dialogs/CreatePartitionDialog.tsx @@ -7,10 +7,10 @@ import CustomInput from '@/components/customInput/CustomInput'; import { ITextfieldConfig } from '@/components/customInput/Types'; import { useFormValidation } from '@/hooks'; import { formatForm } from '@/utils'; +import { PartitionHttp } from '@/http'; import { PartitionCreateProps } from './Types'; import { PartitionManageParam } from '../partitions/Types'; import { ManageRequestMethods } from '../../types/Common'; -import { PartitionHttp } from '@/http/Partition'; const useStyles = makeStyles((theme: Theme) => ({ input: { diff --git a/client/src/pages/dialogs/DropCollectionDialog.tsx b/client/src/pages/dialogs/DropCollectionDialog.tsx index 916ce879..72f240e8 100644 --- a/client/src/pages/dialogs/DropCollectionDialog.tsx +++ b/client/src/pages/dialogs/DropCollectionDialog.tsx @@ -2,7 +2,7 @@ import { FC, useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { rootContext } from '@/context'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp } from '@/http'; import { DropCollectionProps } from './Types'; const DropCollectionDialog: FC = props => { diff --git a/client/src/pages/dialogs/DropPartitionDialog.tsx b/client/src/pages/dialogs/DropPartitionDialog.tsx index 1a3fb9e7..a6752fba 100644 --- a/client/src/pages/dialogs/DropPartitionDialog.tsx +++ b/client/src/pages/dialogs/DropPartitionDialog.tsx @@ -2,10 +2,10 @@ import { FC, useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { rootContext } from '@/context'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; -import { DropPartitionProps } from './Types'; -import { PartitionHttp } from '@/http/Partition'; +import { PartitionHttp } from '@/http'; import { PartitionManageParam } from '../partitions/Types'; import { ManageRequestMethods } from '../../types/Common'; +import { DropPartitionProps } from './Types'; const DropPartitionDialog: FC = props => { const { partitions, onDelete, collectionName } = props; diff --git a/client/src/pages/dialogs/ImportSampleDialog.tsx b/client/src/pages/dialogs/ImportSampleDialog.tsx index 3875e57b..8a53297f 100644 --- a/client/src/pages/dialogs/ImportSampleDialog.tsx +++ b/client/src/pages/dialogs/ImportSampleDialog.tsx @@ -5,8 +5,7 @@ import DialogTemplate from '@/components/customDialog/DialogTemplate'; import CustomSelector from '@/components/customSelector/CustomSelector'; import { rootContext } from '@/context'; import { InsertStatusEnum } from './insert/Types'; -import { CollectionHttp } from '@/http/Collection'; -import { MilvusHttp } from '@/http/Milvus'; +import { CollectionHttp, MilvusHttp } from '@/http'; import { LoadSampleParam } from './Types'; const getStyles = makeStyles((theme: Theme) => { diff --git a/client/src/pages/dialogs/LoadCollectionDialog.tsx b/client/src/pages/dialogs/LoadCollectionDialog.tsx index b723709f..67b6b136 100644 --- a/client/src/pages/dialogs/LoadCollectionDialog.tsx +++ b/client/src/pages/dialogs/LoadCollectionDialog.tsx @@ -8,15 +8,14 @@ import { } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; import { authContext, rootContext } from '@/context'; -import { CollectionHttp } from '@/http/Collection'; +import { CollectionHttp, MilvusHttp } from '@/http'; import { useFormValidation } from '@/hooks'; import { formatForm, parseJson, getNode } from '@/utils'; +import { MILVUS_NODE_TYPE, MILVUS_DEPLOY_MODE } from '@/consts'; import CustomInput from '@/components/customInput/CustomInput'; import { ITextfieldConfig } from '@/components/customInput/Types'; import DialogTemplate from '@/components/customDialog/DialogTemplate'; -import { MilvusHttp } from '@/http/Milvus'; import CustomToolTip from '@/components/customToolTip/CustomToolTip'; -import { MILVUS_NODE_TYPE, MILVUS_DEPLOY_MODE } from '@/consts'; import icons from '@/components/icons/Icons'; const useStyles = makeStyles((theme: Theme) => ({ diff --git a/client/src/pages/dialogs/ReleaseCollectionDialog.tsx b/client/src/pages/dialogs/ReleaseCollectionDialog.tsx index de2c39f4..a3968338 100644 --- a/client/src/pages/dialogs/ReleaseCollectionDialog.tsx +++ b/client/src/pages/dialogs/ReleaseCollectionDialog.tsx @@ -1,9 +1,9 @@ import { useContext, useState } from 'react'; import { Typography, makeStyles, Theme } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; -import { CollectionHttp } from '@/http/Collection'; -import { rootContext } from '@/context'; import DialogTemplate from '@/components/customDialog/DialogTemplate'; +import { CollectionHttp } from '@/http'; +import { rootContext } from '@/context'; const useStyles = makeStyles((theme: Theme) => ({ desc: { diff --git a/client/src/pages/dialogs/RenameCollectionDialog.tsx b/client/src/pages/dialogs/RenameCollectionDialog.tsx index 350dc60f..d6260b2b 100644 --- a/client/src/pages/dialogs/RenameCollectionDialog.tsx +++ b/client/src/pages/dialogs/RenameCollectionDialog.tsx @@ -2,12 +2,12 @@ import { FC, useContext, useMemo, useState } from 'react'; import { Typography, makeStyles, Theme } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; import { rootContext } from '@/context'; -import DialogTemplate from '@/components/customDialog/DialogTemplate'; -import CustomInput from '@/components/customInput/CustomInput'; import { formatForm } from '@/utils'; import { useFormValidation } from '@/hooks'; +import { CollectionHttp } from '@/http'; +import DialogTemplate from '@/components/customDialog/DialogTemplate'; +import CustomInput from '@/components/customInput/CustomInput'; import { ITextfieldConfig } from '@/components/customInput/Types'; -import { CollectionHttp } from '@/http/Collection'; import { RenameCollectionProps } from './Types'; const useStyles = makeStyles((theme: Theme) => ({ diff --git a/client/src/pages/dialogs/insert/Dialog.tsx b/client/src/pages/dialogs/insert/Dialog.tsx index 441edf35..818f7ea4 100644 --- a/client/src/pages/dialogs/insert/Dialog.tsx +++ b/client/src/pages/dialogs/insert/Dialog.tsx @@ -14,7 +14,7 @@ import DialogTemplate from '@/components/customDialog/DialogTemplate'; import icons from '@/components/icons/Icons'; import { rootContext } from '@/context'; import { Option } from '@/components/customSelector/Types'; -import { PartitionHttp } from '@/http/Partition'; +import { PartitionHttp } from '@/http'; import { combineHeadsAndData } from '@/utils'; import InsertImport from './Import'; import InsertPreview from './Preview'; diff --git a/client/src/pages/overview/Overview.tsx b/client/src/pages/overview/Overview.tsx index d21d6ca5..45cdffbc 100644 --- a/client/src/pages/overview/Overview.tsx +++ b/client/src/pages/overview/Overview.tsx @@ -6,8 +6,7 @@ import EmptyCard from '@/components/cards/EmptyCard'; import icons from '@/components/icons/Icons'; import { WS_EVENTS, WS_EVENTS_TYPE, LOADING_STATE } from '@/consts'; import { useNavigationHook } from '@/hooks'; -import { CollectionHttp } from '@/http/Collection'; -import { MilvusHttp } from '@/http/Milvus'; +import { CollectionHttp, MilvusHttp } from '@/http'; import { ALL_ROUTER_TYPES } from '@/router/Types'; import { checkLoading, checkIndexBuilding, formatNumber } from '@/utils'; import CollectionCard from './collectionCard/CollectionCard'; diff --git a/client/src/pages/partitions/Partitions.tsx b/client/src/pages/partitions/Partitions.tsx index b951739e..56e2f0b2 100644 --- a/client/src/pages/partitions/Partitions.tsx +++ b/client/src/pages/partitions/Partitions.tsx @@ -9,13 +9,10 @@ import { usePaginationHook, useInsertDialogHook } from '@/hooks'; import icons from '@/components/icons/Icons'; import CustomToolTip from '@/components/customToolTip/CustomToolTip'; import { rootContext } from '@/context'; -import { PartitionHttp } from '@/http/Partition'; +import { CollectionHttp, PartitionHttp, FieldHttp, MilvusHttp } from '@/http'; import InsertContainer from '../dialogs/insert/Dialog'; -import { CollectionHttp } from '@/http/Collection'; -import { FieldHttp } from '@/http/Field'; import { Field } from '../schema/Types'; import { InsertDataParam } from '../collections/Types'; -import { MilvusHttp } from '@/http/Milvus'; import CreatePartitionDialog from '../dialogs/CreatePartitionDialog'; import DropPartitionDialog from '../dialogs/DropPartitionDialog'; import { PartitionView } from './Types'; diff --git a/client/src/pages/preview/Preview.tsx b/client/src/pages/preview/Preview.tsx index 0c06e841..fddb7bbf 100644 --- a/client/src/pages/preview/Preview.tsx +++ b/client/src/pages/preview/Preview.tsx @@ -1,16 +1,14 @@ import { FC, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import AttuGrid from '@/components/grid/Grid'; -import { getQueryStyles } from '../query/Styles'; -import { CollectionHttp } from '@/http/Collection'; -import { FieldHttp } from '@/http/Field'; -import { IndexHttp } from '@/http/Index'; +import { CollectionHttp, FieldHttp, IndexHttp } from '@/http'; import { usePaginationHook, useSearchResult } from '@/hooks'; +import { generateVector } from '@/utils'; +import { INDEX_CONFIG, DEFAULT_SEARCH_PARAM_VALUE_MAP } from '@/consts'; import { ToolBarConfig } from '@/components/grid/Types'; import CustomToolBar from '@/components/grid/ToolBar'; -import { generateVector } from '@/utils'; import { DataTypeEnum } from '@/pages/collections/Types'; -import { INDEX_CONFIG, DEFAULT_SEARCH_PARAM_VALUE_MAP } from '@/consts'; +import { getQueryStyles } from '../query/Styles'; const Preview: FC<{ collectionName: string; diff --git a/client/src/pages/query/Query.tsx b/client/src/pages/query/Query.tsx index aef24bce..a813f21b 100644 --- a/client/src/pages/query/Query.tsx +++ b/client/src/pages/query/Query.tsx @@ -1,25 +1,24 @@ import { FC, useEffect, useState, useRef, useContext } from 'react'; import { TextField } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; +import { saveAs } from 'file-saver'; import { Parser } from '@json2csv/plainjs'; import { rootContext } from '@/context'; +import { CollectionHttp, FieldHttp } from '@/http'; +import { usePaginationHook, useSearchResult } from '@/hooks'; import EmptyCard from '@/components/cards/EmptyCard'; import icons from '@/components/icons/Icons'; import CustomButton from '@/components/customButton/CustomButton'; import AttuGrid from '@/components/grid/Grid'; import { ToolBarConfig } from '@/components/grid/Types'; -import { saveAs } from 'file-saver'; -import { getQueryStyles } from './Styles'; import Filter from '@/components/advancedSearch'; -import { CollectionHttp } from '@/http/Collection'; -import { FieldHttp } from '@/http/Field'; -import { usePaginationHook, useSearchResult } from '@/hooks'; // import { useTimeTravelHook } from '@/hooks'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; import CustomToolBar from '@/components/grid/ToolBar'; // import { CustomDatePicker } from '@/components/customDatePicker/CustomDatePicker'; import { DataTypeStringEnum } from '../collections/Types'; import { getLabelDisplayedRows } from '../search/Utils'; +import { getQueryStyles } from './Styles'; const Query: FC<{ collectionName: string; diff --git a/client/src/pages/schema/IndexTypeElement.tsx b/client/src/pages/schema/IndexTypeElement.tsx index b04a6484..e2e521ca 100644 --- a/client/src/pages/schema/IndexTypeElement.tsx +++ b/client/src/pages/schema/IndexTypeElement.tsx @@ -1,22 +1,22 @@ import { FC, useContext, useEffect, useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import Chip from '@material-ui/core/Chip'; -import { IndexHttp } from '@/http/Index'; -import { IndexState } from '../../types/Milvus'; +import { makeStyles, Theme } from '@material-ui/core'; import { FieldView, IndexCreateParam, IndexExtraParam, IndexManageParam, } from './Types'; -import { useTranslation } from 'react-i18next'; -import { makeStyles, Theme } from '@material-ui/core'; -import icons from '@/components/icons/Icons'; +import { IndexHttp } from '@/http'; import { rootContext } from '@/context'; -import CreateIndex from './Create'; +import icons from '@/components/icons/Icons'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; import StatusIcon from '@/components/status/StatusIcon'; import { ChildrenStatusType } from '@/components/status/Types'; import { sleep } from '@/utils'; +import CreateIndex from './Create'; +import { IndexState } from '../../types/Milvus'; const useStyles = makeStyles((theme: Theme) => ({ wrapper: { diff --git a/client/src/pages/schema/Schema.tsx b/client/src/pages/schema/Schema.tsx index 028e8e76..596cfe1b 100644 --- a/client/src/pages/schema/Schema.tsx +++ b/client/src/pages/schema/Schema.tsx @@ -5,10 +5,9 @@ import { ColDefinitionsType } from '@/components/grid/Types'; import { useTranslation } from 'react-i18next'; import { usePaginationHook } from '@/hooks'; import icons from '@/components/icons/Icons'; -import { FieldHttp } from '@/http/Field'; +import { FieldHttp, IndexHttp } from '@/http'; import { FieldView } from './Types'; import IndexTypeElement from './IndexTypeElement'; -import { IndexHttp } from '@/http/Index'; import { DataTypeStringEnum } from '../collections/Types'; const useStyles = makeStyles((theme: Theme) => ({ diff --git a/client/src/pages/search/VectorSearch.tsx b/client/src/pages/search/VectorSearch.tsx index b8d6dca9..970836e4 100644 --- a/client/src/pages/search/VectorSearch.tsx +++ b/client/src/pages/search/VectorSearch.tsx @@ -21,8 +21,7 @@ import { Option } from '@/components/customSelector/Types'; import Filter from '@/components/advancedSearch'; import { Field } from '@/components/advancedSearch/Types'; import { CustomDatePicker } from '@/components/customDatePicker/CustomDatePicker'; -import { CollectionHttp } from '@/http/Collection'; -import { IndexHttp } from '@/http/Index'; +import { CollectionHttp, IndexHttp } from '@/http'; import { parseValue, parseLocationSearch, diff --git a/client/src/pages/system/SystemView.tsx b/client/src/pages/system/SystemView.tsx index d1225ef5..43ddfdee 100644 --- a/client/src/pages/system/SystemView.tsx +++ b/client/src/pages/system/SystemView.tsx @@ -4,13 +4,13 @@ import { makeStyles, Theme } from '@material-ui/core'; import clsx from 'clsx'; import { useNavigationHook, useInterval } from '@/hooks'; import { ALL_ROUTER_TYPES } from '@/router/Types'; -import { MilvusHttp } from '@/http/Milvus'; +import { MilvusHttp } from '@/http'; +import { parseJson } from '@/utils'; import Topo from './Topology'; import NodeListView from './NodeListView'; // import LineChartCard from './LineChartCard'; // import ProgressCard from './ProgressCard'; import DataCard from './DataCard'; -import { parseJson } from '@/utils'; const getStyles = makeStyles((theme: Theme) => ({ root: { diff --git a/client/src/pages/systemHealthy/SystemHealthyView.tsx b/client/src/pages/systemHealthy/SystemHealthyView.tsx index 80ed4480..a2b8d8ea 100644 --- a/client/src/pages/systemHealthy/SystemHealthyView.tsx +++ b/client/src/pages/systemHealthy/SystemHealthyView.tsx @@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react'; import { makeStyles, Theme } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; import { useNavigationHook, useInterval } from '@/hooks'; -import { PrometheusHttp } from '@/http/Prometheus'; +import { PrometheusHttp } from '@/http'; import { ALL_ROUTER_TYPES } from '@/router/Types'; import { LAST_TIME_HEALTHY_THRESHOLD_CPU, diff --git a/client/src/pages/user/Roles.tsx b/client/src/pages/user/Roles.tsx index 4b392739..0acd66fb 100644 --- a/client/src/pages/user/Roles.tsx +++ b/client/src/pages/user/Roles.tsx @@ -1,13 +1,13 @@ import { useContext, useEffect, useState } from 'react'; import { makeStyles, Theme, Chip } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; -import { UserHttp } from '@/http/User'; +import { UserHttp } from '@/http'; +import { rootContext } from '@/context'; +import { useNavigationHook } from '@/hooks'; import AttuGrid from '@/components/grid/Grid'; import { ColDefinitionsType, ToolBarConfig } from '@/components/grid/Types'; import { DeleteRoleParams, RoleData } from './Types'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; -import { rootContext } from '@/context'; -import { useNavigationHook } from '@/hooks'; import { ALL_ROUTER_TYPES } from '@/router/Types'; import UpdateRoleDialog from './UpdateRoleDialog'; diff --git a/client/src/pages/user/UpdateRoleDialog.tsx b/client/src/pages/user/UpdateRoleDialog.tsx index 41e5baf1..378d1936 100644 --- a/client/src/pages/user/UpdateRoleDialog.tsx +++ b/client/src/pages/user/UpdateRoleDialog.tsx @@ -6,7 +6,7 @@ import CustomInput from '@/components/customInput/CustomInput'; import { ITextfieldConfig } from '@/components/customInput/Types'; import { useFormValidation } from '@/hooks'; import { formatForm } from '@/utils'; -import { UserHttp } from '@/http/User'; +import { UserHttp } from '@/http'; import { CreateRoleProps, CreateRoleParams, diff --git a/client/src/pages/user/UpdateUserRole.tsx b/client/src/pages/user/UpdateUserRole.tsx index ccc7ba83..4123f699 100644 --- a/client/src/pages/user/UpdateUserRole.tsx +++ b/client/src/pages/user/UpdateUserRole.tsx @@ -9,7 +9,7 @@ import { FC, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import DialogTemplate from '@/components/customDialog/DialogTemplate'; import { UpdateUserRoleProps, UpdateUserRoleParams } from './Types'; -import { UserHttp } from '@/http/User'; +import { UserHttp } from '@/http'; const useStyles = makeStyles((theme: Theme) => ({ input: { diff --git a/client/src/pages/user/User.tsx b/client/src/pages/user/User.tsx index 14560f3b..9da25885 100644 --- a/client/src/pages/user/User.tsx +++ b/client/src/pages/user/User.tsx @@ -1,7 +1,7 @@ import React, { useContext, useEffect, useState } from 'react'; import { makeStyles, Theme } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; -import { UserHttp } from '@/http/User'; +import { UserHttp } from '@/http'; import AttuGrid from '@/components/grid/Grid'; import { ColDefinitionsType, ToolBarConfig } from '@/components/grid/Types'; import {