Skip to content

Commit

Permalink
update create collection dialog UI
Browse files Browse the repository at this point in the history
Signed-off-by: shanghaikid <[email protected]>
  • Loading branch information
shanghaikid committed Dec 22, 2024
1 parent ace4f9e commit d18419e
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 74 deletions.
2 changes: 1 addition & 1 deletion client/src/i18n/cn/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const collectionTrans = {
modifyReplicaTooltip: '调整副本数量',

// create dialog
createTitle: '创建Collection',
createTitle: '创建Collection {{name}}',
idAndVectorFields: 'ID、向量或可用 BM25 算法处理的文本字段',
scalarFields: '标量字段',
schema: 'schema',
Expand Down
4 changes: 2 additions & 2 deletions client/src/i18n/en/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const collectionTrans = {
modifyReplicaTooltip: 'Modify Replica Number',

// create dialog
createTitle: 'Create Collection',
idAndVectorFields: 'ID, Vector, or VarChar Fields for BM25 Processing',
createTitle: 'Create Collection {{name}}',
idAndVectorFields: 'Primary Key, Vector, or BM25(VarChar) Fields',
scalarFields: 'Scalar Fields',
schema: 'Schema',
consistency: 'Consistency',
Expand Down
15 changes: 13 additions & 2 deletions client/src/pages/databases/collections/schema/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import AttuGrid from '@/components/grid/Grid';
import { ColDefinitionsType } from '@/components/grid/Types';
import { useTranslation } from 'react-i18next';
import Icons from '@/components/icons/Icons';
import { formatFieldType, formatNumber, findKeyValue } from '@/utils';
import {
formatFieldType,
formatNumber,
findKeyValue,
isVectorType,
} from '@/utils';
import { dataContext, rootContext, systemContext } from '@/context';
import IndexTypeElement from './IndexTypeElement';
import { getLabelDisplayedRows } from '@/pages/search/Utils';
Expand Down Expand Up @@ -144,7 +149,13 @@ const Overview = () => {
align: 'left',
disablePadding: false,
formatter(f) {
return formatFieldType(f);
return (
<Chip
className={`${classes.chip} ${classes.dataTypeChip}`}
size="small"
label={formatFieldType(f)}
/>
);
},
label: collectionTrans('fieldType'),
},
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/databases/collections/schema/Styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export const useStyles = makeStyles((theme: Theme) => ({
chip: {
fontSize: '12px',
color: theme.palette.text.primary,
border: 'none',
cursor: 'normal',
marginRight: 4,
marginLeft: 4,
},
dataTypeChip: {
backgroundColor: theme.palette.background.grey,
},
featureChip: {
border: 'none',
marginLeft: 0,
Expand Down
154 changes: 89 additions & 65 deletions client/src/pages/dialogs/CreateCollectionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DialogTemplate from '@/components/customDialog/DialogTemplate';
import CustomInput from '@/components/customInput/CustomInput';
import CustomSelector from '@/components/customSelector/CustomSelector';
import { ITextfieldConfig } from '@/components/customInput/Types';
import CustomToolTip from '@/components/customToolTip/CustomToolTip';
import { rootContext, dataContext } from '@/context';
import { useFormValidation } from '@/hooks';
import { formatForm, getAnalyzerParams, TypeEnum } from '@/utils';
Expand All @@ -24,36 +25,49 @@ import { CONSISTENCY_LEVEL_OPTIONS } from './create/Constants';
import { makeStyles } from '@mui/styles';

const useStyles = makeStyles((theme: Theme) => ({
fieldset: {
width: '100%',
dialog: {
minWidth: 880,
},
container: {
display: 'flex',
alignItems: 'center',
'&:nth-last-child(3)': {
flexDirection: 'column',
alignItems: 'flex-start',
marginBottom: '0',
},
'& legend': {
lineHeight: '20px',
fontSize: '14px',
flexDirection: 'column',

'& section': {
display: 'flex',
'& fieldset': {},
},
},
generalInfo: {
'& fieldset': {
gap: 16,
display: 'flex',
width: '100%',
},
},
schemaInfo: {
background: theme.palette.background.grey,
padding: '16px',
borderRadius: 8,
},
extraInfo: {
marginTop: theme.spacing(2),
display: 'flex',
flexDirection: 'column',
gap: 8,

'& input': {
marginLeft: 0,
},
},
input: {
width: '100%',
},
select: {
'&:first-child': {
marginLeft: 0,
},
dynamicField: {
fontSize: 14,
marginLeft: -8,
},
consistencySelect: {
marginTop: theme.spacing(2),
},
dialog: {
minWidth: 880,
width: '50%',
},
}));

Expand Down Expand Up @@ -307,7 +321,7 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {

return (
<DialogTemplate
title={collectionTrans('createTitle')}
title={collectionTrans('createTitle', { name: form.collection_name })}
handleClose={() => {
handleCloseDialog();
}}
Expand All @@ -316,52 +330,62 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {
confirmDisabled={disabled || !allFieldsValid}
dialogClass={classes.dialog}
>
<>
<fieldset className={`${classes.fieldset} ${classes.generalInfo}`}>
{generalInfoConfigs.map(config => (
<CustomInput
key={config.key}
type="text"
textConfig={config}
checkValid={checkIsValid}
validInfo={validation}
<div className={classes.container}>
<section className={classes.generalInfo}>
<fieldset>
{generalInfoConfigs.map(config => (
<CustomInput
key={config.key}
type="text"
textConfig={config}
checkValid={checkIsValid}
validInfo={validation}
/>
))}
</fieldset>
</section>

<section className={classes.schemaInfo}>
<fieldset>
{/* <legend>{collectionTrans('schema')}</legend> */}
<CreateFields
fields={fields}
setFields={setFields}
setFieldsValidation={setFieldsValidation}
autoID={form.autoID}
setAutoID={changeIsAutoID}
/>
</fieldset>
</section>

<section className={classes.extraInfo}>
<fieldset>
<CustomSelector
wrapperClass={classes.consistencySelect}
size="small"
options={CONSISTENCY_LEVEL_OPTIONS}
onChange={e => {
setConsistencyLevel(e.target.value as ConsistencyLevelEnum);
}}
label={collectionTrans('consistency')}
value={consistencyLevel}
variant="filled"
/>
))}
</fieldset>

<fieldset className={classes.fieldset}>
{/* <legend>{collectionTrans('schema')}</legend> */}
<CreateFields
fields={fields}
setFields={setFields}
setFieldsValidation={setFieldsValidation}
autoID={form.autoID}
setAutoID={changeIsAutoID}
/>
</fieldset>
<fieldset className={classes.fieldset}>
<FormControlLabel
checked={form.enableDynamicField}
control={<Checkbox size="small" />}
onChange={changeEnableDynamicField}
label={collectionTrans('enableDynamicSchema')}
/>
</fieldset>

<fieldset className={classes.fieldset}>
<CustomSelector
wrapperClass={`${classes.select} ${classes.consistencySelect}`}
size="small"
options={CONSISTENCY_LEVEL_OPTIONS}
onChange={e => {
setConsistencyLevel(e.target.value as ConsistencyLevelEnum);
}}
label={collectionTrans('consistency')}
value={consistencyLevel}
variant="filled"
/>
</fieldset>
</>
</fieldset>
<fieldset className={classes.dynamicField}>
<CustomToolTip title={collectionTrans('partitionKeyTooltip')}>
<>
<Checkbox
checked={!!form.enableDynamicField}
size="small"
onChange={changeEnableDynamicField}
/>
{collectionTrans('enableDynamicSchema')}
</>
</CustomToolTip>
</fieldset>
</section>
</div>
</DialogTemplate>
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/dialogs/create/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const VECTOR_FIELDS_OPTIONS: LabelValuePair[] = [
value: DataTypeEnum.SparseFloatVector,
},
{
label: 'VarChar(BM25)',
label: 'BM25(VarChar)',
value: DataTypeEnum.VarCharBM25,
},
];
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/dialogs/create/CreateFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const useStyles = makeStyles((theme: Theme) => ({
overflowY: 'auto',
},
title: {
marginTop: theme.spacing(2),
'& button': {
position: 'relative',
top: '-1px',
Expand Down Expand Up @@ -365,7 +366,7 @@ const CreateFields: FC<CreateFieldsProps> = ({
};

const generateDimension = (field: FieldType) => {
// sparse dont support dimension
// sparse doesn't support dimension
if (field.data_type === DataTypeEnum.SparseFloatVector) {
return null;
}
Expand Down
13 changes: 12 additions & 1 deletion client/src/styles/theme.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { PaletteMode } from '@mui/material';
import { grey } from '@mui/material/colors';

declare module '@mui/material/Typography' {
interface TypographyPropsVariantOverrides {
mono: true; // Custom variant
}
}

declare module '@mui/material/styles' {
interface TypeBackground {
light?: string; // Adding the light property to the TypeBackground interface
grey?: string;
}
interface Palette {
background: TypeBackground; // Ensure the background interface uses the updated TypeBackground
}
}

const getCommonThemes = (mode: PaletteMode) => ({
typography: {
fontFamily: [
Expand Down Expand Up @@ -41,7 +52,7 @@ const getCommonThemes = (mode: PaletteMode) => ({
background: {
default: mode === 'light' ? '#f5f5f5' : '#121212',
paper: mode === 'light' ? '#ffffff' : '#1e1e1e',
light: mode === 'light' ? '#f5f5f5' : '#121212',
grey: mode === 'light' ? grey[200] : grey[800],
},
},
spacing: (factor: number) => `${8 * factor}px`,
Expand Down

0 comments on commit d18419e

Please sign in to comment.