mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-14 05:31:40 +00:00
Native data AI application framework based on AWEL+AGENT (#1152)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com> Co-authored-by: licunxing <864255598@qq.com> Co-authored-by: Aralhi <xiaoping0501@gmail.com> Co-authored-by: xuyuan23 <643854343@qq.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: hzh97 <2976151305@qq.com>
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { useAsyncEffect } from 'ahooks';
|
||||
import { Badge, Button, Card, Drawer, Empty, Modal, Spin, message } from 'antd';
|
||||
import { Badge, Button, Card, Drawer, Empty, Modal, message } from 'antd';
|
||||
import FormDialog from '@/components/database/form-dialog';
|
||||
import { apiInterceptors, getDbList, getDbSupportType, postDbDelete } from '@/client/api';
|
||||
import DBCard from '@/components/database/db-card';
|
||||
import { DeleteFilled, EditFilled, PlusOutlined } from '@ant-design/icons';
|
||||
import { DBOption, DBType, DbListResponse, DbSupportTypeResponse } from '@/types/db';
|
||||
import MuiLoading from '@/components/common/loading';
|
||||
import { dbMapper } from '@/utils';
|
||||
import GPTCard from '@/components/common/gpt-card';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type DBItem = DbListResponse[0];
|
||||
|
||||
@@ -18,6 +17,8 @@ export function isFileDb(dbTypeList: DBOption[], dbType: DBType) {
|
||||
}
|
||||
|
||||
function Database() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [dbList, setDbList] = useState<DbListResponse>([]);
|
||||
const [dbSupportList, setDbSupportList] = useState<DbSupportTypeResponse>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -25,13 +26,13 @@ function Database() {
|
||||
const [draw, setDraw] = useState<{ open: boolean; dbList?: DbListResponse; name?: string; type?: DBType }>({ open: false });
|
||||
|
||||
const getDbSupportList = async () => {
|
||||
const [_, data] = await apiInterceptors(getDbSupportType());
|
||||
const [, data] = await apiInterceptors(getDbSupportType());
|
||||
setDbSupportList(data ?? []);
|
||||
};
|
||||
|
||||
const refreshDbList = async () => {
|
||||
setLoading(true);
|
||||
const [_, data] = await apiInterceptors(getDbList());
|
||||
const [, data] = await apiInterceptors(getDbList());
|
||||
setDbList(data ?? []);
|
||||
setLoading(false);
|
||||
};
|
||||
@@ -95,7 +96,7 @@ function Database() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="relative p-4 md:p-6 bg-[#FAFAFA] dark:bg-transparent min-h-full overflow-y-auto">
|
||||
<div className="relative p-4 md:p-6 min-h-full overflow-y-auto">
|
||||
<MuiLoading visible={loading} />
|
||||
<div className="mb-4">
|
||||
<Button
|
||||
@@ -106,15 +107,20 @@ function Database() {
|
||||
setModal({ open: true });
|
||||
}}
|
||||
>
|
||||
Create
|
||||
{t('create')}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2 md:gap-4">
|
||||
{dbTypeList.map((item) => (
|
||||
<Badge key={item.value} count={dbListByType[item.value].length}>
|
||||
<DBCard
|
||||
info={item}
|
||||
<Badge key={item.value} count={dbListByType[item.value].length} className="min-h-fit">
|
||||
<GPTCard
|
||||
className="h-full"
|
||||
title={item.label}
|
||||
desc={item.desc ?? ''}
|
||||
disabled={item.disabled}
|
||||
icon={item.icon}
|
||||
onClick={() => {
|
||||
if (item.disabled) return;
|
||||
handleDbTypeClick(item);
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user