Skip to content

Commit

Permalink
feat:db delete some databases
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 committed Dec 5, 2023
1 parent d518f58 commit d85a7b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions frontend/providers/dbprovider/src/constants/db.ts
Expand Up @@ -160,10 +160,10 @@ export const DBTypeList = [
{ id: DBTypeEnum.mongodb, label: 'mongo' },
{ id: DBTypeEnum.mysql, label: 'mysql' },
{ id: DBTypeEnum.redis, label: 'redis' },
{ id: DBTypeEnum.kafka, label: 'kafka' },
{ id: DBTypeEnum.qdrant, label: 'qdrant' },
{ id: DBTypeEnum.nebula, label: 'nebula' },
{ id: DBTypeEnum.weaviate, label: 'weaviate' }
{ id: DBTypeEnum.kafka, label: 'kafka' }
// { id: DBTypeEnum.qdrant, label: 'qdrant' },
// { id: DBTypeEnum.nebula, label: 'nebula' },
// { id: DBTypeEnum.weaviate, label: 'weaviate' }
];

export const DBComponentNameMap = {
Expand Down
15 changes: 9 additions & 6 deletions frontend/providers/dbprovider/src/pages/api/delDBByName.ts
Expand Up @@ -12,6 +12,7 @@ import { DeleteJobByName, GetJobByName } from './migrate/delJobByName';
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
const { name } = req.query as { name: string };

if (!name) {
throw new Error('deploy name is empty');
}
Expand All @@ -29,13 +30,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
});

// get migrates and delete
const migrates = await getMigrateList({ migrateName: name, req });
console.log(migrates, 'migrates');
await Promise.all(
migrates.map((item) => delMigrateByName({ migrateName: item.metadata.name, req }))
).catch((error) => {
try {
const migrates = await getMigrateList({ migrateName: name, req });
await Promise.all(
migrates.map((item) => delMigrateByName({ migrateName: item.metadata.name, req }))
);
} catch (error) {
console.log(error);
});
}

// get backup and delete
const backups = await getBackups({ dbName: name, req });
Expand Down Expand Up @@ -68,6 +70,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<

jsonRes(res, { data: result?.body });
} catch (err: any) {
console.log(err, 'delete db by name err');
jsonRes(res, {
code: 500,
error: err
Expand Down
2 changes: 1 addition & 1 deletion frontend/providers/dbprovider/src/services/request.ts
Expand Up @@ -133,7 +133,7 @@ export function DELETE<T = any>(
data?: { [key: string]: any },
config?: AxiosRequestConfig
): Promise<T> {
return request.get(url, {
return request.delete(url, {
params: data,
...config
});
Expand Down

0 comments on commit d85a7b7

Please sign in to comment.