-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from zilliztech/database
support manage databases
- Loading branch information
Showing
25 changed files
with
654 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,5 @@ export type IconsType = | |
| 'download' | ||
| 'source' | ||
| 'edit' | ||
| 'database' | ||
| 'uploadFile'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
CreateDatabaseParams, | ||
DropDatabaseParams, | ||
} from '../pages/database/Types'; | ||
import BaseModel from './BaseModel'; | ||
|
||
export class DatabaseHttp extends BaseModel { | ||
private names!: string[]; | ||
|
||
constructor(props: {}) { | ||
super(props); | ||
Object.assign(this, props); | ||
} | ||
|
||
static DATABASE_URL = `/databases`; | ||
|
||
static getDatabases() { | ||
return super.search({ path: this.DATABASE_URL, params: {} }); | ||
} | ||
|
||
static createDatabase(data: CreateDatabaseParams) { | ||
return super.create({ path: this.DATABASE_URL, data }); | ||
} | ||
|
||
static dropDatabase(data: DropDatabaseParams) { | ||
return super.delete({ path: `${this.DATABASE_URL}/${data.db_name}` }); | ||
} | ||
|
||
get _names() { | ||
return this.names; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const databaseTrans = { | ||
createTitle: 'Create database', | ||
databases: 'Databases', | ||
deleteWarning: | ||
'You are trying to drop a database. This action cannot be undone.', | ||
databaseName: 'Database Name', | ||
confirmDatabase: 'Confirm Password', | ||
deleteTip: | ||
'Please select at least one item to drop and default_db can not be dropped.', | ||
}; | ||
|
||
export default databaseTrans; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const databaseTrans = { | ||
createTitle: 'Create Database', | ||
databases: 'Databases', | ||
database: 'Database', | ||
deleteWarning: | ||
'You are trying to drop a database. This action cannot be undone.', | ||
databaseName: 'Database Name', | ||
confirmDatabase: 'Confirm Password', | ||
deleteTip: | ||
'Please select at least one item to drop and default_db can not be dropped.', | ||
}; | ||
|
||
export default databaseTrans; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
const navTrans = { | ||
overview: 'Overview', | ||
collection: 'Collection', | ||
collection: 'Collections', | ||
console: 'Search Console', | ||
search: 'Vector Search', | ||
system: 'System View', | ||
user: 'Milvus Users', | ||
user: 'Users', | ||
database: 'Databases', | ||
}; | ||
|
||
export default navTrans; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { makeStyles, Theme } from '@material-ui/core'; | ||
import { FC, useMemo, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import DialogTemplate from '../../components/customDialog/DialogTemplate'; | ||
import CustomInput from '../../components/customInput/CustomInput'; | ||
import { ITextfieldConfig } from '../../components/customInput/Types'; | ||
import { useFormValidation } from '../../hooks/Form'; | ||
import { formatForm } from '../../utils/Form'; | ||
import { CreateDatabaseProps, CreateDatabaseParams } from './Types'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
input: { | ||
margin: theme.spacing(3, 0, 0.5), | ||
}, | ||
})); | ||
|
||
const CreateUser: FC<CreateDatabaseProps> = ({ handleCreate, handleClose }) => { | ||
const { t: databaseTrans } = useTranslation('database'); | ||
const { t: btnTrans } = useTranslation('btn'); | ||
const { t: warningTrans } = useTranslation('warning'); | ||
|
||
const [form, setForm] = useState<CreateDatabaseParams>({ | ||
db_name: '', | ||
}); | ||
const checkedForm = useMemo(() => { | ||
return formatForm(form); | ||
}, [form]); | ||
const { validation, checkIsValid, disabled } = useFormValidation(checkedForm); | ||
|
||
const classes = useStyles(); | ||
|
||
const handleInputChange = (key: 'db_name', value: string) => { | ||
setForm(v => ({ ...v, [key]: value })); | ||
}; | ||
|
||
const createConfigs: ITextfieldConfig[] = [ | ||
{ | ||
label: databaseTrans('database'), | ||
key: 'db_name', | ||
onChange: (value: string) => handleInputChange('db_name', value), | ||
variant: 'filled', | ||
className: classes.input, | ||
placeholder: databaseTrans('database'), | ||
fullWidth: true, | ||
validations: [ | ||
{ | ||
rule: 'require', | ||
errorText: warningTrans('required', { | ||
name: databaseTrans('databaseName'), | ||
}), | ||
}, | ||
], | ||
defaultValue: form.db_name, | ||
}, | ||
]; | ||
|
||
const handleCreateDatabase = () => { | ||
handleCreate(form); | ||
}; | ||
|
||
return ( | ||
<DialogTemplate | ||
title={databaseTrans('createTitle')} | ||
handleClose={handleClose} | ||
confirmLabel={btnTrans('create')} | ||
handleConfirm={handleCreateDatabase} | ||
confirmDisabled={disabled} | ||
> | ||
<> | ||
{createConfigs.map(v => ( | ||
<CustomInput | ||
type="text" | ||
textConfig={v} | ||
checkValid={checkIsValid} | ||
validInfo={validation} | ||
key={v.label} | ||
/> | ||
))} | ||
</> | ||
</DialogTemplate> | ||
); | ||
}; | ||
|
||
export default CreateUser; |
Oops, something went wrong.