|
@@ -1,11 +1,5 @@
|
|
|
import { useState, useMemo, ChangeEvent, useCallback } from 'react';
|
|
|
-import {
|
|
|
- Typography,
|
|
|
- Accordion,
|
|
|
- AccordionSummary,
|
|
|
- AccordionDetails,
|
|
|
- Checkbox,
|
|
|
-} from '@mui/material';
|
|
|
+import { Typography, AccordionSummary, Checkbox } from '@mui/material';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import { DataService, CollectionService } from '@/http';
|
|
|
import Icons from '@/components/icons/Icons';
|
|
@@ -15,7 +9,6 @@ import EmptyCard from '@/components/cards/EmptyCard';
|
|
|
import CustomButton from '@/components/customButton/CustomButton';
|
|
|
import { getLabelDisplayedRows } from '@/pages/search/Utils';
|
|
|
import { useSearchResult, usePaginationHook } from '@/hooks';
|
|
|
-import { getQueryStyles } from './Styles';
|
|
|
import SearchGlobalParams from './SearchGlobalParams';
|
|
|
import VectorInputBox from './SearchInputBox';
|
|
|
import StatusIcon, { LoadingType } from '@/components/status/StatusIcon';
|
|
@@ -46,6 +39,19 @@ import type {
|
|
|
CollectionFullObject,
|
|
|
VectorSearchResults,
|
|
|
} from '@server/types';
|
|
|
+import {
|
|
|
+ SearchRoot,
|
|
|
+ InputArea,
|
|
|
+ AccordionsContainer,
|
|
|
+ StyledAccordion,
|
|
|
+ StyledAccordionDetails,
|
|
|
+ SearchControls,
|
|
|
+ SearchResults,
|
|
|
+ Toolbar,
|
|
|
+ Explorer,
|
|
|
+ CloseButton,
|
|
|
+ CheckboxRow,
|
|
|
+} from './StyledComponents';
|
|
|
|
|
|
export interface CollectionDataProps {
|
|
|
collectionName: string;
|
|
@@ -74,8 +80,6 @@ const Search = (props: CollectionDataProps) => {
|
|
|
// translations
|
|
|
const { t: searchTrans } = useTranslation('search');
|
|
|
const { t: btnTrans } = useTranslation('btn');
|
|
|
- // classes
|
|
|
- const classes = getQueryStyles();
|
|
|
|
|
|
// UI functions
|
|
|
const handleExpand = useCallback(
|
|
@@ -373,13 +377,13 @@ const Search = (props: CollectionDataProps) => {
|
|
|
|
|
|
if (!hasVectorIndex || !loaded) {
|
|
|
return (
|
|
|
- <div className={classes.root}>
|
|
|
+ <SearchRoot>
|
|
|
<EmptyCard
|
|
|
wrapperClass={`page-empty-card`}
|
|
|
icon={<Icons.load />}
|
|
|
text={searchTrans('loadCollectionFirst')}
|
|
|
/>
|
|
|
- </div>
|
|
|
+ </SearchRoot>
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -405,27 +409,25 @@ const Search = (props: CollectionDataProps) => {
|
|
|
const enablePartitionsFilter = !collection.schema.enablePartitionKey;
|
|
|
|
|
|
return (
|
|
|
- <div className={classes.root}>
|
|
|
+ <SearchRoot>
|
|
|
{collection && (
|
|
|
- <div className={classes.inputArea}>
|
|
|
- <div className={classes.accordions}>
|
|
|
+ <InputArea>
|
|
|
+ <AccordionsContainer>
|
|
|
{searchParams.searchParams.map((s, index: number) => {
|
|
|
const field = s.field;
|
|
|
return (
|
|
|
- <Accordion
|
|
|
+ <StyledAccordion
|
|
|
key={`${collection.collection_name}-${field.name}`}
|
|
|
expanded={s.expanded}
|
|
|
onChange={handleExpand(field.name)}
|
|
|
- className={`${classes.accordion} ${
|
|
|
- highlightField === field.name && 'highlight'
|
|
|
- }`}
|
|
|
+ className={highlightField === field.name ? 'highlight' : ''}
|
|
|
>
|
|
|
<AccordionSummary
|
|
|
expandIcon={<ExpandMoreIcon />}
|
|
|
aria-controls={`${field.name}-content`}
|
|
|
id={`${field.name}-header`}
|
|
|
>
|
|
|
- <div className={classes.checkbox}>
|
|
|
+ <CheckboxRow>
|
|
|
{searchParams.searchParams.length > 1 && (
|
|
|
<Checkbox
|
|
|
size="small"
|
|
@@ -435,9 +437,7 @@ const Search = (props: CollectionDataProps) => {
|
|
|
)}
|
|
|
<div className="label">
|
|
|
<Typography
|
|
|
- className={`field-name ${
|
|
|
- s.data.length > 0 ? 'bold' : ''
|
|
|
- }`}
|
|
|
+ className={`field-name ${s.selected ? 'bold' : ''}`}
|
|
|
>
|
|
|
{field.is_function_output
|
|
|
? `${field.name}<=${
|
|
@@ -450,9 +450,9 @@ const Search = (props: CollectionDataProps) => {
|
|
|
<i>{field.index && field.index.metricType}</i>
|
|
|
</Typography>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </CheckboxRow>
|
|
|
</AccordionSummary>
|
|
|
- <AccordionDetails className={classes.accordionDetail}>
|
|
|
+ <StyledAccordionDetails>
|
|
|
<VectorInputBox
|
|
|
searchParams={s}
|
|
|
onChange={onSearchInputChange}
|
|
@@ -460,12 +460,8 @@ const Search = (props: CollectionDataProps) => {
|
|
|
type={field.is_function_output ? 'text' : 'vector'}
|
|
|
/>
|
|
|
|
|
|
- <Typography className="text">
|
|
|
- {searchTrans('thirdTip')}
|
|
|
- </Typography>
|
|
|
-
|
|
|
<SearchParams
|
|
|
- wrapperClass="paramsWrapper"
|
|
|
+ sx={{ pt: 1 }}
|
|
|
consistency_level={'Strong'}
|
|
|
handleConsistencyChange={(level: string) => {}}
|
|
|
indexType={field.index.indexType}
|
|
@@ -481,8 +477,8 @@ const Search = (props: CollectionDataProps) => {
|
|
|
return false;
|
|
|
}}
|
|
|
/>
|
|
|
- </AccordionDetails>
|
|
|
- </Accordion>
|
|
|
+ </StyledAccordionDetails>
|
|
|
+ </StyledAccordion>
|
|
|
);
|
|
|
})}
|
|
|
|
|
@@ -493,9 +489,9 @@ const Search = (props: CollectionDataProps) => {
|
|
|
setSelected={onPartitionsChange}
|
|
|
/>
|
|
|
)}
|
|
|
- </div>
|
|
|
+ </AccordionsContainer>
|
|
|
|
|
|
- <div className={classes.searchControls}>
|
|
|
+ <SearchControls>
|
|
|
<SearchGlobalParams
|
|
|
onSlideChange={(field: string) => {
|
|
|
setHighlightField(field);
|
|
@@ -514,7 +510,10 @@ const Search = (props: CollectionDataProps) => {
|
|
|
onClick={genRandomVectors}
|
|
|
size="small"
|
|
|
disabled={false}
|
|
|
- className={classes.genBtn}
|
|
|
+ className="genBtn"
|
|
|
+ sx={{
|
|
|
+ mb: 1,
|
|
|
+ }}
|
|
|
>
|
|
|
{btnTrans('example')}
|
|
|
</CustomButton>
|
|
@@ -522,7 +521,7 @@ const Search = (props: CollectionDataProps) => {
|
|
|
<CustomButton
|
|
|
variant="contained"
|
|
|
size="small"
|
|
|
- className={classes.genBtn}
|
|
|
+ className="genBtn"
|
|
|
disabled={disableSearch}
|
|
|
tooltip={disableSearchTooltip}
|
|
|
tooltipPlacement="top"
|
|
@@ -535,10 +534,10 @@ const Search = (props: CollectionDataProps) => {
|
|
|
: '',
|
|
|
})}
|
|
|
</CustomButton>
|
|
|
- </div>
|
|
|
+ </SearchControls>
|
|
|
|
|
|
- <div className={classes.searchResults}>
|
|
|
- <section className={classes.toolbar}>
|
|
|
+ <SearchResults>
|
|
|
+ <Toolbar>
|
|
|
<div className="left">
|
|
|
<CustomInput
|
|
|
type="text"
|
|
@@ -586,14 +585,14 @@ const Search = (props: CollectionDataProps) => {
|
|
|
!searchParams.searchResult ||
|
|
|
searchParams.searchResult!.length === 0
|
|
|
}
|
|
|
- className={classes.btn}
|
|
|
+ className="btn"
|
|
|
startIcon={<Icons.magic classes={{ root: 'icon' }} />}
|
|
|
>
|
|
|
{btnTrans('explore')}
|
|
|
</CustomButton>
|
|
|
|
|
|
<CustomButton
|
|
|
- className={classes.btn}
|
|
|
+ className="btn"
|
|
|
disabled={result.length === 0}
|
|
|
onClick={() => {
|
|
|
saveCsvAs(
|
|
@@ -606,7 +605,7 @@ const Search = (props: CollectionDataProps) => {
|
|
|
{btnTrans('export')}
|
|
|
</CustomButton>
|
|
|
<CustomButton
|
|
|
- className={classes.btn}
|
|
|
+ className="btn"
|
|
|
onClick={
|
|
|
explorerOpen ? onExplorerResetClicked : onResetClicked
|
|
|
}
|
|
@@ -615,26 +614,25 @@ const Search = (props: CollectionDataProps) => {
|
|
|
{btnTrans('reset')}
|
|
|
</CustomButton>
|
|
|
</div>
|
|
|
- </section>
|
|
|
+ </Toolbar>
|
|
|
|
|
|
{explorerOpen ? (
|
|
|
- <div className={classes.explorer}>
|
|
|
+ <Explorer>
|
|
|
<DataExplorer
|
|
|
data={searchParams.graphData}
|
|
|
onNodeClick={onNodeClicked}
|
|
|
/>
|
|
|
- <CustomButton
|
|
|
+ <CloseButton
|
|
|
onClick={() => {
|
|
|
setExplorerOpen(false);
|
|
|
}}
|
|
|
size="small"
|
|
|
startIcon={<Icons.clear classes={{ root: 'icon' }} />}
|
|
|
- className={classes.closeBtn}
|
|
|
variant="contained"
|
|
|
>
|
|
|
{btnTrans('close')}
|
|
|
- </CustomButton>
|
|
|
- </div>
|
|
|
+ </CloseButton>
|
|
|
+ </Explorer>
|
|
|
) : (searchParams.searchResult &&
|
|
|
searchParams.searchResult.length > 0) ||
|
|
|
tableLoading ? (
|
|
@@ -647,17 +645,17 @@ const Search = (props: CollectionDataProps) => {
|
|
|
page={currentPage}
|
|
|
tableHeaderHeight={46}
|
|
|
rowHeight={39}
|
|
|
+ openCheckBox={false}
|
|
|
onPageChange={handlePageChange}
|
|
|
rowsPerPage={pageSize}
|
|
|
setRowsPerPage={handlePageSize}
|
|
|
- openCheckBox={false}
|
|
|
- isLoading={tableLoading}
|
|
|
+ handleSort={handleGridSort}
|
|
|
orderBy={orderBy}
|
|
|
order={order}
|
|
|
labelDisplayedRows={getLabelDisplayedRows(
|
|
|
`(${searchParams.searchLatency} ms)`
|
|
|
)}
|
|
|
- handleSort={handleGridSort}
|
|
|
+ isLoading={tableLoading}
|
|
|
/>
|
|
|
) : (
|
|
|
<EmptyCard
|
|
@@ -670,10 +668,10 @@ const Search = (props: CollectionDataProps) => {
|
|
|
}
|
|
|
/>
|
|
|
)}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ </SearchResults>
|
|
|
+ </InputArea>
|
|
|
)}
|
|
|
- </div>
|
|
|
+ </SearchRoot>
|
|
|
);
|
|
|
};
|
|
|
|