|
@@ -9,6 +9,7 @@ import {
|
|
|
CollectionView,
|
|
|
DataTypeEnum,
|
|
|
InsertDataParam,
|
|
|
+ LoadSampleParam,
|
|
|
} from './Types';
|
|
|
import { ColDefinitionsType, ToolBarConfig } from '../../components/grid/Types';
|
|
|
import { usePaginationHook } from '../../hooks/Pagination';
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
import Highlighter from 'react-highlight-words';
|
|
|
import { parseLocationSearch } from '../../utils/Format';
|
|
|
import InsertContainer from '../../components/insert/Container';
|
|
|
+import ImportSample from '../../components/insert/ImportSample';
|
|
|
import { MilvusHttp } from '../../http/Milvus';
|
|
|
import { LOADING_STATE } from '../../consts/Milvus';
|
|
|
import { webSokcetContext } from '../../context/WebSocket';
|
|
@@ -88,6 +90,7 @@ const Collections = () => {
|
|
|
const LoadIcon = icons.load;
|
|
|
const ReleaseIcon = icons.release;
|
|
|
const InfoIcon = icons.info;
|
|
|
+ const SourceIcon = icons.source;
|
|
|
|
|
|
const searchedCollections = useMemo(
|
|
|
() => collections.filter(collection => collection._name.includes(search)),
|
|
@@ -183,6 +186,28 @@ const Collections = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const handleImportSample = async (
|
|
|
+ collectionName: string,
|
|
|
+ size: string
|
|
|
+ ): Promise<{ result: boolean; msg: string }> => {
|
|
|
+ const param: LoadSampleParam = {
|
|
|
+ collection_name: collectionName,
|
|
|
+ size: size,
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ await CollectionHttp.importSample(collectionName, param);
|
|
|
+ await MilvusHttp.flush(collectionName);
|
|
|
+ return { result: true, msg: '' };
|
|
|
+ } catch (err: any) {
|
|
|
+ const {
|
|
|
+ response: {
|
|
|
+ data: { message },
|
|
|
+ },
|
|
|
+ } = err;
|
|
|
+ return { result: false, msg: message || '' };
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const handleCreateCollection = async (param: CollectionCreateParam) => {
|
|
|
const data: CollectionCreateParam = JSON.parse(JSON.stringify(param));
|
|
|
const vectorType = [DataTypeEnum.BinaryVector, DataTypeEnum.FloatVector];
|
|
@@ -294,6 +319,14 @@ const Collections = () => {
|
|
|
collectionList.length === 0 || selectedCollections.length > 1,
|
|
|
btnVariant: 'outlined',
|
|
|
},
|
|
|
+ {
|
|
|
+ type: 'iconBtn',
|
|
|
+ onClick: () => {
|
|
|
+ fetchData();
|
|
|
+ },
|
|
|
+ label: collectionTrans('delete'),
|
|
|
+ icon: 'refresh',
|
|
|
+ },
|
|
|
{
|
|
|
type: 'iconBtn',
|
|
|
onClick: () => {
|
|
@@ -369,12 +402,6 @@ const Collections = () => {
|
|
|
sortBy: '_status',
|
|
|
label: collectionTrans('status'),
|
|
|
},
|
|
|
- {
|
|
|
- id: 'consistency_level',
|
|
|
- align: 'left',
|
|
|
- disablePadding: false,
|
|
|
- label: collectionTrans('consistencyLevel'),
|
|
|
- },
|
|
|
{
|
|
|
id: '_rowCount',
|
|
|
align: 'left',
|
|
@@ -388,6 +415,12 @@ const Collections = () => {
|
|
|
</span>
|
|
|
),
|
|
|
},
|
|
|
+ {
|
|
|
+ id: 'consistency_level',
|
|
|
+ align: 'left',
|
|
|
+ disablePadding: false,
|
|
|
+ label: collectionTrans('consistencyLevel'),
|
|
|
+ },
|
|
|
{
|
|
|
id: '_desc',
|
|
|
align: 'left',
|
|
@@ -436,6 +469,37 @@ const Collections = () => {
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
+ {
|
|
|
+ id: 'import',
|
|
|
+ align: 'center',
|
|
|
+ disablePadding: false,
|
|
|
+ label: '',
|
|
|
+ showActionCell: true,
|
|
|
+ isHoverAction: true,
|
|
|
+ actionBarConfigs: [
|
|
|
+ {
|
|
|
+ onClick: (e: React.MouseEvent, row: CollectionView) => {
|
|
|
+ setDialog({
|
|
|
+ open: true,
|
|
|
+ type: 'custom',
|
|
|
+ params: {
|
|
|
+ component: (
|
|
|
+ <ImportSample
|
|
|
+ collection={row._name}
|
|
|
+ handleImport={handleImportSample}
|
|
|
+ />
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ icon: 'source',
|
|
|
+ label: 'Import',
|
|
|
+ showIconMethod: 'renderFn',
|
|
|
+ getLabel: () => 'Import sample data',
|
|
|
+ renderIconFn: (row: CollectionView) => <SourceIcon />,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
];
|
|
|
|
|
|
const handleSelectChange = (value: any) => {
|