2
0
czhen 3 жил өмнө
parent
commit
3a0f18d8d7

+ 6 - 21
client/src/pages/query/Query.tsx

@@ -13,8 +13,6 @@ import icons from '../../components/icons/Icons';
 import CustomButton from '../../components/customButton/CustomButton';
 import CustomButton from '../../components/customButton/CustomButton';
 import MilvusGrid from '../../components/grid/Grid';
 import MilvusGrid from '../../components/grid/Grid';
 import { getQueryStyles } from './Styles';
 import { getQueryStyles } from './Styles';
-import CustomToolBar from '../../components/grid/ToolBar';
-import { ColDefinitionsType, ToolBarConfig } from '../../components/grid/Types';
 import Filter from '../../components/advancedSearch';
 import Filter from '../../components/advancedSearch';
 import { CollectionHttp } from '../../http/Collection';
 import { CollectionHttp } from '../../http/Collection';
 import { FieldHttp } from '../../http/Field';
 import { FieldHttp } from '../../http/Field';
@@ -34,6 +32,7 @@ const Query: FC<{
   const { t: searchTrans } = useTranslation('search');
   const { t: searchTrans } = useTranslation('search');
   const { t: collectionTrans } = useTranslation('collection');
   const { t: collectionTrans } = useTranslation('collection');
   const { t: btnTrans } = useTranslation('btn');
   const { t: btnTrans } = useTranslation('btn');
+
   const classes = getQueryStyles();
   const classes = getQueryStyles();
 
 
   const {
   const {
@@ -47,6 +46,7 @@ const Query: FC<{
     orderBy,
     orderBy,
     handleGridSort,
     handleGridSort,
   } = usePaginationHook(queryResult || []);
   } = usePaginationHook(queryResult || []);
+
   const handlePageChange = (e: any, page: number) => {
   const handlePageChange = (e: any, page: number) => {
     handleCurrentPage(page);
     handleCurrentPage(page);
   };
   };
@@ -57,23 +57,23 @@ const Query: FC<{
       name: i.name,
       name: i.name,
       type: i.data_type.includes('Int') ? 'int' : 'float',
       type: i.data_type.includes('Int') ? 'int' : 'float',
     }));
     }));
-    console.log(schemaList);
     setFields(nameList);
     setFields(nameList);
   };
   };
 
 
+  // Get fields at first or collection name changed.
   useEffect(() => {
   useEffect(() => {
     collectionName && getFields(collectionName);
     collectionName && getFields(collectionName);
   }, [collectionName]);
   }, [collectionName]);
 
 
   const filterRef = useRef();
   const filterRef = useRef();
-  const resetFilter = () => {
+
+  const handleFilterReset = () => {
     const currentFilter: any = filterRef.current;
     const currentFilter: any = filterRef.current;
     currentFilter?.getReset();
     currentFilter?.getReset();
     setExpression('');
     setExpression('');
     setTableLoading(null);
     setTableLoading(null);
     setQueryResult(null);
     setQueryResult(null);
   };
   };
-
   const handleFilterSubmit = (expression: string) => {
   const handleFilterSubmit = (expression: string) => {
     setExpression(expression);
     setExpression(expression);
   };
   };
@@ -85,9 +85,7 @@ const Query: FC<{
         output_fields: fields.map(i => i.name),
         output_fields: fields.map(i => i.name),
       });
       });
       setTableLoading(false);
       setTableLoading(false);
-      console.log(res);
       const result = res.data;
       const result = res.data;
-      // const result = transferSearchResult(res.results);
       setQueryResult(result);
       setQueryResult(result);
     } catch (err) {
     } catch (err) {
       setTableLoading(false);
       setTableLoading(false);
@@ -112,7 +110,7 @@ const Query: FC<{
           />
           />
         </div>
         </div>
         <div className="right">
         <div className="right">
-          <CustomButton className="btn" onClick={resetFilter}>
+          <CustomButton className="btn" onClick={handleFilterReset}>
             <ResetIcon classes={{ root: 'icon' }} />
             <ResetIcon classes={{ root: 'icon' }} />
             {btnTrans('reset')}
             {btnTrans('reset')}
           </CustomButton>
           </CustomButton>
@@ -134,28 +132,15 @@ const Query: FC<{
             disablePadding: false,
             disablePadding: false,
             label: i.name,
             label: i.name,
           }))}
           }))}
-          // rows={queryResult || []}
-          // rowCount={queryResult?.length || 0}
           primaryKey={fields.find(i => i.is_primary_key)?.name}
           primaryKey={fields.find(i => i.is_primary_key)?.name}
-          // page={1}
-          // onChangePage={() => {}}
-          // rowsPerPage={1000}
-          // setRowsPerPage={() => {}}
           openCheckBox={false}
           openCheckBox={false}
-          // isLoading={tableLoading}
           isLoading={!!tableLoading}
           isLoading={!!tableLoading}
-          // orderBy={fields.find(i => i.is_primary_key)?.name}
-          // order={''}
-          // handleSort={() => {}}
           rows={result}
           rows={result}
           rowCount={total}
           rowCount={total}
-          // primaryKey="rank"
           page={currentPage}
           page={currentPage}
           onChangePage={handlePageChange}
           onChangePage={handlePageChange}
           rowsPerPage={pageSize}
           rowsPerPage={pageSize}
           setRowsPerPage={handlePageSize}
           setRowsPerPage={handlePageSize}
-          // openCheckBox={false}
-          // isLoading={tableLoading}
           orderBy={orderBy}
           orderBy={orderBy}
           order={order}
           order={order}
           handleSort={handleGridSort}
           handleSort={handleGridSort}