Browse Source

Merge pull request #156 from nameczz/main

Fix autoid and add createdtime
nameczz 4 years ago
parent
commit
06307b6226

+ 9 - 0
client/src/components/insert/Container.tsx

@@ -72,6 +72,8 @@ const InsertContainer: FC<InsertContentProps> = ({
   const [isContainFieldNames, setIsContainFieldNames] = useState<number>(1);
   const [isContainFieldNames, setIsContainFieldNames] = useState<number>(1);
   // uploaded file name
   // uploaded file name
   const [fileName, setFileName] = useState<string>('');
   const [fileName, setFileName] = useState<string>('');
+  const [file, setFile] = useState<File | null>(null);
+
   // uploaded csv data (type: string)
   // uploaded csv data (type: string)
   const [csvData, setCsvData] = useState<any[]>([]);
   const [csvData, setCsvData] = useState<any[]>([]);
 
 
@@ -225,6 +227,7 @@ const InsertContainer: FC<InsertContentProps> = ({
       openSnackBar(insertTrans('uploadFieldNamesLenWarning'), 'error');
       openSnackBar(insertTrans('uploadFieldNamesLenWarning'), 'error');
       // reset uploader value and filename
       // reset uploader value and filename
       setFileName('');
       setFileName('');
+      setFile(null);
       uploader.value = null;
       uploader.value = null;
       return;
       return;
     }
     }
@@ -272,6 +275,10 @@ const InsertContainer: FC<InsertContentProps> = ({
     }
     }
   };
   };
 
 
+  const handleUploadFileChange = (file: File, upload: HTMLFormElement) => {
+    setFile(file);
+  };
+
   const handleBack = () => {
   const handleBack = () => {
     switch (activeStep) {
     switch (activeStep) {
       case InsertStepperEnum.import:
       case InsertStepperEnum.import:
@@ -299,6 +306,7 @@ const InsertContainer: FC<InsertContentProps> = ({
             handleCollectionChange={handleCollectionChange}
             handleCollectionChange={handleCollectionChange}
             handlePartitionChange={setPartitionValue}
             handlePartitionChange={setPartitionValue}
             handleUploadedData={handleUploadedData}
             handleUploadedData={handleUploadedData}
+            handleUploadFileChange={handleUploadFileChange}
             fileName={fileName}
             fileName={fileName}
             setFileName={setFileName}
             setFileName={setFileName}
           />
           />
@@ -311,6 +319,7 @@ const InsertContainer: FC<InsertContentProps> = ({
             tableHeads={tableHeads}
             tableHeads={tableHeads}
             setTableHeads={setTableHeads}
             setTableHeads={setTableHeads}
             isContainFieldNames={isContainFieldNames}
             isContainFieldNames={isContainFieldNames}
+            file={file}
             handleIsContainedChange={setIsContainFieldNames}
             handleIsContainedChange={setIsContainFieldNames}
           />
           />
         );
         );

+ 2 - 0
client/src/components/insert/Import.tsx

@@ -102,6 +102,7 @@ const InsertImport: FC<InsertImportProps> = ({
   handlePartitionChange,
   handlePartitionChange,
 
 
   handleUploadedData,
   handleUploadedData,
+  handleUploadFileChange,
   fileName,
   fileName,
   setFileName,
   setFileName,
 }) => {
 }) => {
@@ -162,6 +163,7 @@ const InsertImport: FC<InsertImportProps> = ({
             handleUploadedData={handleUploadedData}
             handleUploadedData={handleUploadedData}
             maxSize={parseByte('150m')}
             maxSize={parseByte('150m')}
             overSizeWarning={insertTrans('overSizeWarning')}
             overSizeWarning={insertTrans('overSizeWarning')}
+            handleUploadFileChange={handleUploadFileChange}
           />
           />
           <Typography className="text">
           <Typography className="text">
             {fileName || insertTrans('fileNamePlaceHolder')}
             {fileName || insertTrans('fileNamePlaceHolder')}

+ 1 - 0
client/src/components/insert/Preview.tsx

@@ -88,6 +88,7 @@ const InsertPreview: FC<InsertPreviewProps> = ({
   handleIsContainedChange,
   handleIsContainedChange,
   tableHeads,
   tableHeads,
   setTableHeads,
   setTableHeads,
+  file,
 }) => {
 }) => {
   const classes = getStyles();
   const classes = getStyles();
   const { t: insertTrans } = useTranslation('insert');
   const { t: insertTrans } = useTranslation('insert');

+ 2 - 0
client/src/components/insert/Types.ts

@@ -54,6 +54,7 @@ export interface InsertImportProps {
   handlePartitionChange: (partitionName: string) => void;
   handlePartitionChange: (partitionName: string) => void;
   // handle uploaded data
   // handle uploaded data
   handleUploadedData: (data: string, uploader: HTMLFormElement) => void;
   handleUploadedData: (data: string, uploader: HTMLFormElement) => void;
+  handleUploadFileChange: (file: File, uploader: HTMLFormElement) => void;
   fileName: string;
   fileName: string;
   setFileName: (fileName: string) => void;
   setFileName: (fileName: string) => void;
 }
 }
@@ -67,6 +68,7 @@ export interface InsertPreviewProps {
 
 
   isContainFieldNames: number;
   isContainFieldNames: number;
   handleIsContainedChange: (isContained: number) => void;
   handleIsContainedChange: (isContained: number) => void;
+  file: File | null; // csv file
 }
 }
 
 
 export interface InsertStatusProps {
 export interface InsertStatusProps {

+ 4 - 1
client/src/pages/collections/Create.tsx

@@ -160,13 +160,16 @@ const CreateCollection: FC<CollectionCreateProps> = ({ handleCreate }) => {
     const param: CollectionCreateParam = {
     const param: CollectionCreateParam = {
       ...form,
       ...form,
       fields: fields.map(v => {
       fields: fields.map(v => {
-        return {
+        const data: any = {
           name: v.name,
           name: v.name,
           description: v.description,
           description: v.description,
           is_primary_key: v.is_primary_key,
           is_primary_key: v.is_primary_key,
           data_type: v.data_type,
           data_type: v.data_type,
           dimension: vectorType.includes(v.data_type) ? v.dimension : undefined,
           dimension: vectorType.includes(v.data_type) ? v.dimension : undefined,
         };
         };
+
+        v.is_primary_key && (data.autoID = form.autoID);
+        return data;
       }),
       }),
     };
     };
     handleCreate(param);
     handleCreate(param);

+ 1 - 6
client/src/pages/connect/Connect.tsx

@@ -4,12 +4,7 @@ import { ITextfieldConfig } from '../../components/customInput/Types';
 import icons from '../../components/icons/Icons';
 import icons from '../../components/icons/Icons';
 import ConnectContainer from './ConnectContainer';
 import ConnectContainer from './ConnectContainer';
 import CustomInput from '../../components/customInput/CustomInput';
 import CustomInput from '../../components/customInput/CustomInput';
-import {
-  useContext,
-  // useEffect,
-  useMemo,
-  useState,
-} from 'react';
+import { useContext, useMemo, useState } from 'react';
 import { formatForm } from '../../utils/Form';
 import { formatForm } from '../../utils/Form';
 import { useFormValidation } from '../../hooks/Form';
 import { useFormValidation } from '../../hooks/Form';
 import CustomButton from '../../components/customButton/CustomButton';
 import CustomButton from '../../components/customButton/CustomButton';

+ 1 - 1
server/package.json

@@ -32,7 +32,7 @@
     "@nestjs/websockets": "^8.0.4",
     "@nestjs/websockets": "^8.0.4",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-local": "^1.0.33",
     "@types/passport-local": "^1.0.33",
-    "@zilliz/milvus2-sdk-node": "^1.0.3",
+    "@zilliz/milvus2-sdk-node": "^1.0.4",
     "body-parser": "^1.19.0",
     "body-parser": "^1.19.0",
     "cache-manager": "^3.4.4",
     "cache-manager": "^3.4.4",
     "class-transformer": "^0.4.0",
     "class-transformer": "^0.4.0",

+ 11 - 3
server/src/collections/collections.controller.ts

@@ -29,18 +29,26 @@ import { cacheKeys } from '../cache/config';
 @ApiTags('collections')
 @ApiTags('collections')
 @Controller('collections')
 @Controller('collections')
 export class CollectionsController {
 export class CollectionsController {
-  constructor(private collectionsService: CollectionsService, @Inject(CACHE_MANAGER) private cacheManager: Cache) { }
+  constructor(
+    private collectionsService: CollectionsService,
+    @Inject(CACHE_MANAGER) private cacheManager: Cache,
+  ) {}
 
 
   // manually control cache if logic is complicated
   // manually control cache if logic is complicated
   @Get()
   @Get()
   async getCollections(@Query() data?: ShowCollections) {
   async getCollections(@Query() data?: ShowCollections) {
     if (Number(data.type) === 1) {
     if (Number(data.type) === 1) {
-      let loadedCollections = await this.cacheManager.get(cacheKeys.LOADEDCOLLECTIONS);
+      let loadedCollections = await this.cacheManager.get(
+        cacheKeys.LOADEDCOLLECTIONS,
+      );
       if (loadedCollections) {
       if (loadedCollections) {
         return loadedCollections;
         return loadedCollections;
       }
       }
       loadedCollections = await this.collectionsService.getLoadedColletions();
       loadedCollections = await this.collectionsService.getLoadedColletions();
-      await this.cacheManager.set(cacheKeys.LOADEDCOLLECTIONS, loadedCollections);
+      await this.cacheManager.set(
+        cacheKeys.LOADEDCOLLECTIONS,
+        loadedCollections,
+      );
       return loadedCollections;
       return loadedCollections;
     }
     }
     let allCollections = await this.cacheManager.get(cacheKeys.ALLCOLLECTIONS);
     let allCollections = await this.cacheManager.get(cacheKeys.ALLCOLLECTIONS);

+ 1 - 0
server/src/collections/collections.service.ts

@@ -118,6 +118,7 @@ export class CollectionsService {
           rowCount: findKeyValue(collectionStatistics.stats, ROW_COUNT),
           rowCount: findKeyValue(collectionStatistics.stats, ROW_COUNT),
           id: collectionInfo.collectionID,
           id: collectionInfo.collectionID,
           isLoaded: loadedCollections.collection_names.includes(name),
           isLoaded: loadedCollections.collection_names.includes(name),
+          createdTime: collectionInfo.created_utc_timestamp,
         });
         });
       }
       }
     }
     }

+ 4 - 4
server/yarn.lock

@@ -1337,10 +1337,10 @@
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
 
 
-"@zilliz/milvus2-sdk-node@^1.0.3":
-  version "1.0.3"
-  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.3.tgz#909f1b44f5a7dedcfc3d075180f0273e8ace90f1"
-  integrity sha512-jAc/l7siEyNcDJ/WJ5tvbD/9bPMKXNWXCXaeUgLWLTitSrmjRLquhHKkf66OUU+rbEiDQw0l408jQyyY3CIZwA==
+"@zilliz/milvus2-sdk-node@^1.0.4":
+  version "1.0.4"
+  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.4.tgz#3e32edb5338abbcb710ea7da8b4e2ba2603fcea5"
+  integrity sha512-67KTHnZP1pLAGDct15XPZfUIHJy/4RPGcUQ3rAMepEj/4BmxCAL8rpRqThFL+UPJz4QYcphoqL5HQDNK59IH0A==
   dependencies:
   dependencies:
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/proto-loader" "^0.6.0"
     "@grpc/proto-loader" "^0.6.0"