2
0
Эх сурвалжийг харах

Merge pull request #85 from Tumao727/bugfix/style-adjust

fix pagination and update table style
ryjiang 4 жил өмнө
parent
commit
ef0253343d

+ 9 - 11
client/src/components/grid/Table.tsx

@@ -78,6 +78,8 @@ const useStyles = makeStyles(theme => ({
     },
     },
   },
   },
   cell: {
   cell: {
+    borderBottom: '1px solid #e9e9ed',
+
     '& p': {
     '& p': {
       display: 'inline-block',
       display: 'inline-block',
       verticalAlign: 'middle',
       verticalAlign: 'middle',
@@ -85,15 +87,9 @@ const useStyles = makeStyles(theme => ({
       textOverflow: 'ellipsis',
       textOverflow: 'ellipsis',
       whiteSpace: 'nowrap',
       whiteSpace: 'nowrap',
       maxWidth: '300px',
       maxWidth: '300px',
-      fontSize: '12.8px',
-    },
-    '& button': {
-      textTransform: 'inherit',
-      justifyContent: 'flex-start',
+      fontSize: '14px',
+      lineHeight: '20px',
     },
     },
-    // '& svg': {
-    //   color: 'rgba(0, 0, 0, 0.33)',
-    // },
   },
   },
   noData: {
   noData: {
     paddingTop: theme.spacing(6),
     paddingTop: theme.spacing(6),
@@ -126,7 +122,6 @@ const EnhancedTable: FC<TableType> = props => {
   const [loadingRowCount, setLoadingRowCount] = useState<number>(0);
   const [loadingRowCount, setLoadingRowCount] = useState<number>(0);
 
 
   const containerRef = useRef(null);
   const containerRef = useRef(null);
-  const rowRef = useRef(null);
 
 
   const handleRequestSort = (event: any, property: string) => {
   const handleRequestSort = (event: any, property: string) => {
     const isAsc = orderBy === property && order === 'asc';
     const isAsc = orderBy === property && order === 'asc';
@@ -145,7 +140,11 @@ const EnhancedTable: FC<TableType> = props => {
     if (setPageSize) {
     if (setPageSize) {
       const containerHeight: number = (containerRef.current as any)!
       const containerHeight: number = (containerRef.current as any)!
         .offsetHeight;
         .offsetHeight;
-      const rowHeight: number = (rowRef.current as any)?.offsetHeight || 0;
+
+      // table default row height is 54
+      // if pass component as row item, its max height should be 54 too
+      const rowHeight = 54;
+      // table header default height is 57
       const tableHeaderHeight: number = 57;
       const tableHeaderHeight: number = 57;
       if (rowHeight > 0) {
       if (rowHeight > 0) {
         const pageSize = Math.floor(
         const pageSize = Math.floor(
@@ -200,7 +199,6 @@ const EnhancedTable: FC<TableType> = props => {
 
 
                     return (
                     return (
                       <TableRow
                       <TableRow
-                        ref={rowRef}
                         hover={showHoverStyle}
                         hover={showHoverStyle}
                         key={'row' + row[primaryKey] + index}
                         key={'row' + row[primaryKey] + index}
                         onClick={event => onSelected(event, row)}
                         onClick={event => onSelected(event, row)}

+ 1 - 1
client/src/components/status/StatusIcon.tsx

@@ -23,7 +23,7 @@ const StatusIcon: FC<StatusIconType> = props => {
       case 'creating':
       case 'creating':
         return (
         return (
           <CircularProgress
           <CircularProgress
-            size={24}
+            size={20}
             thickness={8}
             thickness={8}
             classes={{ svg: classes.svg }}
             classes={{ svg: classes.svg }}
           />
           />

+ 12 - 12
client/src/consts/Milvus.tsx

@@ -65,14 +65,14 @@ export const INDEX_CONFIG: {
     create: ['nlist', 'm'],
     create: ['nlist', 'm'],
     search: ['nprobe'],
     search: ['nprobe'],
   },
   },
-  IVF_SQ8: {
-    create: ['nlist'],
-    search: ['nprobe'],
-  },
-  IVF_SQ8_HYBRID: {
-    create: ['nlist'],
-    search: ['nprobe'],
-  },
+  // IVF_SQ8: {
+  //   create: ['nlist'],
+  //   search: ['nprobe'],
+  // },
+  // IVF_SQ8_HYBRID: {
+  //   create: ['nlist'],
+  //   search: ['nprobe'],
+  // },
   FLAT: {
   FLAT: {
     create: ['nlist'],
     create: ['nlist'],
     search: ['nprobe'],
     search: ['nprobe'],
@@ -85,10 +85,10 @@ export const INDEX_CONFIG: {
     create: ['n_trees'],
     create: ['n_trees'],
     search: ['search_k'],
     search: ['search_k'],
   },
   },
-  RNSG: {
-    create: ['out_degree', 'candidate_pool_size', 'search_length', 'knng'],
-    search: ['search_length'],
-  },
+  // RNSG: {
+  //   create: ['out_degree', 'candidate_pool_size', 'search_length', 'knng'],
+  //   search: ['search_length'],
+  // },
 };
 };
 
 
 export const COLLECTION_NAME_REGX = /^[0-9,a-z,A-Z$_]+$/;
 export const COLLECTION_NAME_REGX = /^[0-9,a-z,A-Z$_]+$/;

+ 2 - 1
client/src/hooks/Pagination.ts

@@ -7,9 +7,10 @@ export const usePaginationHook = (list: any[]) => {
   const total = list.length;
   const total = list.length;
   const { data, offset } = useMemo(() => {
   const { data, offset } = useMemo(() => {
     const offset = pageSize * currentPage;
     const offset = pageSize * currentPage;
+    const data = list.slice(offset, offset + pageSize);
     return {
     return {
       offset,
       offset,
-      data: list.slice(offset, offset + pageSize),
+      data,
     };
     };
   }, [list, currentPage, pageSize]);
   }, [list, currentPage, pageSize]);
 
 

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

@@ -4,7 +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';

+ 42 - 11
client/src/pages/structure/IndexTypeElement.tsx

@@ -1,6 +1,5 @@
 import { FC, useCallback, useContext, useEffect, useState } from 'react';
 import { FC, useCallback, useContext, useEffect, useState } from 'react';
 import Chip from '@material-ui/core/Chip';
 import Chip from '@material-ui/core/Chip';
-import CustomButton from '../../components/customButton/CustomButton';
 import { IndexHttp } from '../../http/Index';
 import { IndexHttp } from '../../http/Index';
 import { IndexState } from '../../types/Milvus';
 import { IndexState } from '../../types/Milvus';
 import {
 import {
@@ -23,13 +22,43 @@ const useStyles = makeStyles((theme: Theme) => ({
     paddingLeft: theme.spacing(1),
     paddingLeft: theme.spacing(1),
   },
   },
   btn: {
   btn: {
-    '& span': {
-      textTransform: 'uppercase',
-      whiteSpace: 'nowrap',
+    display: 'flex',
+    alignItems: 'center',
+    textTransform: 'uppercase',
+    whiteSpace: 'nowrap',
+
+    fontSize: '14px',
+    color: theme.palette.primary.main,
+
+    '&:hover': {
+      cursor: 'pointer',
+    },
+  },
+  btnDisabled: {
+    color: '#82838e',
+    pointerEvents: 'none',
+
+    '&:hover': {
+      cursor: 'default',
     },
     },
   },
   },
   chip: {
   chip: {
+    height: '24px',
     backgroundColor: '#e9e9ed',
     backgroundColor: '#e9e9ed',
+    padding: theme.spacing(0.5),
+
+    '& .icon': {
+      width: '16px',
+      height: '16px',
+    },
+  },
+  chipLabel: {
+    fontSize: '12px',
+    lineHeight: '16px',
+  },
+  addIcon: {
+    width: '20px',
+    height: '20px',
   },
   },
 }));
 }));
 
 
@@ -136,14 +165,16 @@ const IndexTypeElement: FC<{
     switch (data._indexType) {
     switch (data._indexType) {
       case '': {
       case '': {
         return (
         return (
-          <CustomButton
-            disabled={data._createIndexDisabled}
-            className={classes.btn}
+          <div
+            role="button"
             onClick={handleCreate}
             onClick={handleCreate}
+            className={`${classes.btn} ${
+              data._createIndexDisabled ? classes.btnDisabled : ''
+            }`}
           >
           >
-            <AddIcon />
+            <AddIcon classes={{ root: classes.addIcon }} />
             {indexTrans('create')}
             {indexTrans('create')}
-          </CustomButton>
+          </div>
         );
         );
       }
       }
       default: {
       default: {
@@ -152,8 +183,8 @@ const IndexTypeElement: FC<{
         ) : (
         ) : (
           <Chip
           <Chip
             label={data._indexType}
             label={data._indexType}
-            classes={{ root: classes.chip }}
-            deleteIcon={<DeleteIcon />}
+            classes={{ root: classes.chip, label: classes.chipLabel }}
+            deleteIcon={<DeleteIcon classes={{ root: 'icon' }} />}
             onDelete={handleDelete}
             onDelete={handleDelete}
           />
           />
         );
         );

+ 2 - 2
client/src/pages/structure/Types.ts

@@ -41,10 +41,10 @@ export interface IndexView {
 export type IndexType =
 export type IndexType =
   | 'FLAT'
   | 'FLAT'
   | 'IVF_FLAT'
   | 'IVF_FLAT'
-  | 'IVF_SQ8'
+  // | 'IVF_SQ8'
   // | 'IVF_SQ8_HYBRID'
   // | 'IVF_SQ8_HYBRID'
   | 'IVF_PQ'
   | 'IVF_PQ'
-  | 'RNSG'
+  // | 'RNSG'
   | 'HNSW'
   | 'HNSW'
   | 'ANNOY';
   | 'ANNOY';
 
 

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

@@ -112,6 +112,7 @@ export class CollectionsService {
       totalData: 0,
       totalData: 0,
     };
     };
     const res = await this.getCollectionNames();
     const res = await this.getCollectionNames();
+    data.collectionCount = res.collection_names.length;
     if (res.collection_names.length > 0) {
     if (res.collection_names.length > 0) {
       for (const name of res.collection_names) {
       for (const name of res.collection_names) {
         const collectionStatistics = await this.getCollectionStatistics({
         const collectionStatistics = await this.getCollectionStatistics({