fix: api key table list sort
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
import ModalFooter from '@/components/modal-footer';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { Modal, type ModalFuncProps } from 'antd';
|
||||||
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
|
const DeleteModal: React.FC<ModalFuncProps> = forwardRef((props, ref) => {
|
||||||
|
const intl = useIntl();
|
||||||
|
const { title, open, onOk, onCancel, content } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={title}
|
||||||
|
simple={true}
|
||||||
|
open={open}
|
||||||
|
centered={true}
|
||||||
|
onOk={onOk}
|
||||||
|
onCancel={onCancel}
|
||||||
|
destroyOnClose={true}
|
||||||
|
closeIcon={false}
|
||||||
|
maskClosable={false}
|
||||||
|
keyboard={false}
|
||||||
|
width={600}
|
||||||
|
styles={{}}
|
||||||
|
footer={<ModalFooter onCancel={onCancel} onOk={onOk}></ModalFooter>}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default DeleteModal;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { MoreOutlined } from '@ant-design/icons';
|
import { MoreOutlined } from '@ant-design/icons';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
|
import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
@@ -14,6 +15,7 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
|
|||||||
size = 'small',
|
size = 'small',
|
||||||
onSelect
|
onSelect
|
||||||
}) => {
|
}) => {
|
||||||
|
const intl = useIntl();
|
||||||
const handleMenuClick = useCallback((item: any) => {
|
const handleMenuClick = useCallback((item: any) => {
|
||||||
console.log('menu click', item.key);
|
console.log('menu click', item.key);
|
||||||
const selectItem = _.find(items, { key: item.key });
|
const selectItem = _.find(items, { key: item.key });
|
||||||
@@ -32,22 +34,52 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{items?.length === 1 ? (
|
{items?.length === 1 ? (
|
||||||
<Tooltip title={_.head(items)?.label}>
|
<Tooltip title={intl.formatMessage({ id: _.head(items)?.label })}>
|
||||||
<Button
|
<Button
|
||||||
{..._.head(items)}
|
{..._.head(items)}
|
||||||
icon={_.get(items, '0.icon')}
|
icon={_.get(items, '0.icon')}
|
||||||
size={size}
|
size={size}
|
||||||
|
{..._.get(items, '0.props')}
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
></Button>
|
></Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : (
|
) : (
|
||||||
<Dropdown.Button
|
<Dropdown.Button
|
||||||
menu={{
|
dropdownRender={(menus: any) => {
|
||||||
items: _.tail(items),
|
return (
|
||||||
onClick: handleMenuClick
|
<div
|
||||||
|
className="flex flex-column "
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'var(--color-white-1)',
|
||||||
|
padding: 5,
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
borderRadius: 'var(--border-radius-base)',
|
||||||
|
boxShadow: 'var(--ant-box-shadow-secondary)'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{_.map(_.tail(items), (item: any) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
{...item.props}
|
||||||
|
type="text"
|
||||||
|
size="middle"
|
||||||
|
icon={item.icon}
|
||||||
|
key={item.key}
|
||||||
|
onClick={() => handleMenuClick(item)}
|
||||||
|
style={{ width: '100%', justifyContent: 'flex-start' }}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: item.label })}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
buttonsRender={([leftButton, rightButton]) => [
|
buttonsRender={([leftButton, rightButton]) => [
|
||||||
<Tooltip title={_.head(items)?.label} key="leftButton">
|
<Tooltip
|
||||||
|
title={intl.formatMessage({ id: _.head(items)?.label })}
|
||||||
|
key="leftButton"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
size={size}
|
size={size}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { SealColumnProps } from '../types';
|
|||||||
|
|
||||||
const SealColumn: React.FC<SealColumnProps> = (props) => {
|
const SealColumn: React.FC<SealColumnProps> = (props) => {
|
||||||
const row: Record<string, any> = useContext(RowContext);
|
const row: Record<string, any> = useContext(RowContext);
|
||||||
|
console.log('seal column====', row);
|
||||||
const { dataIndex, render, align } = props;
|
const { dataIndex, render, align } = props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -43,7 +43,14 @@ const TableRow: React.FC<
|
|||||||
const childrenDataRef = useRef<any[]>([]);
|
const childrenDataRef = useRef<any[]>([]);
|
||||||
childrenDataRef.current = childrenData;
|
childrenDataRef.current = childrenData;
|
||||||
|
|
||||||
console.log('table row====', childrenData, record.name, firstLoad, expanded);
|
console.log(
|
||||||
|
'table row====',
|
||||||
|
record,
|
||||||
|
childrenData,
|
||||||
|
record.name,
|
||||||
|
firstLoad,
|
||||||
|
expanded
|
||||||
|
);
|
||||||
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
||||||
dataList: childrenData,
|
dataList: childrenData,
|
||||||
setDataList: setChildrenData
|
setDataList: setChildrenData
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { Modal, message, type ModalFuncProps } from 'antd';
|
||||||
|
import { useRef } from 'react';
|
||||||
|
|
||||||
|
export default function useDeleteModal() {
|
||||||
|
const intl = useIntl();
|
||||||
|
const modalRef = useRef<any>();
|
||||||
|
const showDeleteModal = (config: ModalFuncProps = {}) => {
|
||||||
|
modalRef.current = Modal.confirm({
|
||||||
|
...config,
|
||||||
|
okText: intl.formatMessage({
|
||||||
|
id: 'common.button.delete'
|
||||||
|
}),
|
||||||
|
onCancel: () => {
|
||||||
|
config.onCancel?.();
|
||||||
|
modalRef.current.destroy?.();
|
||||||
|
},
|
||||||
|
onOk: async () => {
|
||||||
|
await config.onOk?.();
|
||||||
|
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return { showDeleteModal };
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import PageTools from '@/components/page-tools';
|
import PageTools from '@/components/page-tools';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import type { PageActionType } from '@/config/types';
|
import type { PageActionType } from '@/config/types';
|
||||||
|
import useDeleteModal from '@/hooks/use-delete-modal';
|
||||||
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
||||||
import useTableSort from '@/hooks/use-table-sort';
|
import useTableSort from '@/hooks/use-table-sort';
|
||||||
import { handleBatchRequest } from '@/utils';
|
import { handleBatchRequest } from '@/utils';
|
||||||
import { DeleteOutlined, PlusOutlined, SyncOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, PlusOutlined, SyncOutlined } from '@ant-design/icons';
|
||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Input, Modal, Space, Table, Tooltip, message } from 'antd';
|
import { Button, Input, Space, Table, Tooltip } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
@@ -18,6 +19,7 @@ import { ListItem } from './config/types';
|
|||||||
const { Column } = Table;
|
const { Column } = Table;
|
||||||
|
|
||||||
const Models: React.FC = () => {
|
const Models: React.FC = () => {
|
||||||
|
const { showDeleteModal } = useDeleteModal();
|
||||||
const rowSelection = useTableRowSelection();
|
const rowSelection = useTableRowSelection();
|
||||||
const { sortOrder, setSortOrder } = useTableSort({
|
const { sortOrder, setSortOrder } = useTableSort({
|
||||||
defaultSortOrder: 'descend'
|
defaultSortOrder: 'descend'
|
||||||
@@ -96,7 +98,7 @@ const Models: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -105,17 +107,13 @@ const Models: React.FC = () => {
|
|||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteApisKey(row.id);
|
await deleteApisKey(row.id);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -123,12 +121,8 @@ const Models: React.FC = () => {
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteApisKey);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteApisKey);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -214,7 +208,9 @@ const Models: React.FC = () => {
|
|||||||
dataIndex="expires_at"
|
dataIndex="expires_at"
|
||||||
key="expiration"
|
key="expiration"
|
||||||
render={(text, record) => {
|
render={(text, record) => {
|
||||||
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
return text
|
||||||
|
? dayjs(text).format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
: intl.formatMessage({ id: 'apikeys.form.expiration.never' });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Column
|
<Column
|
||||||
@@ -232,7 +228,7 @@ const Models: React.FC = () => {
|
|||||||
defaultSortOrder="descend"
|
defaultSortOrder="descend"
|
||||||
sortOrder={sortOrder}
|
sortOrder={sortOrder}
|
||||||
showSorterTooltip={false}
|
showSorterTooltip={false}
|
||||||
sorter={true}
|
sorter={false}
|
||||||
render={(text, record) => {
|
render={(text, record) => {
|
||||||
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
console.log('instance item====');
|
console.log('instance item====');
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const childActionList = [
|
const childActionList = [
|
||||||
{
|
{
|
||||||
label: intl.formatMessage({ id: 'common.button.viewlog' }),
|
label: 'common.button.viewlog',
|
||||||
key: 'viewlog',
|
key: 'viewlog',
|
||||||
status: [
|
status: [
|
||||||
InstanceStatusMap.Running,
|
InstanceStatusMap.Running,
|
||||||
@@ -42,9 +43,11 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
icon: <FieldTimeOutlined />
|
icon: <FieldTimeOutlined />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: intl.formatMessage({ id: 'common.button.delete' }),
|
label: 'common.button.delete',
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
danger: true,
|
props: {
|
||||||
|
danger: true
|
||||||
|
},
|
||||||
icon: <DeleteOutlined />
|
icon: <DeleteOutlined />
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import DeleteModal from '@/components/delete-modal';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import PageTools from '@/components/page-tools';
|
import PageTools from '@/components/page-tools';
|
||||||
import SealTable from '@/components/seal-table';
|
import SealTable from '@/components/seal-table';
|
||||||
import SealColumn from '@/components/seal-table/components/seal-column';
|
import SealColumn from '@/components/seal-table/components/seal-column';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import type { PageActionType } from '@/config/types';
|
import type { PageActionType } from '@/config/types';
|
||||||
|
import useDeleteModal from '@/hooks/use-delete-modal';
|
||||||
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
|
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
|
||||||
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
||||||
import useTableSort from '@/hooks/use-table-sort';
|
import useTableSort from '@/hooks/use-table-sort';
|
||||||
@@ -20,7 +22,7 @@ import { Access, useAccess, useIntl, useNavigate } from '@umijs/max';
|
|||||||
import { Button, Input, Modal, Space, message } from 'antd';
|
import { Button, Input, Modal, Space, message } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { memo, useCallback, useState } from 'react';
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
MODELS_API,
|
MODELS_API,
|
||||||
MODEL_INSTANCE_API,
|
MODEL_INSTANCE_API,
|
||||||
@@ -60,10 +62,11 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
loading,
|
loading,
|
||||||
total
|
total
|
||||||
}) => {
|
}) => {
|
||||||
// const { modal } = App.useApp();
|
|
||||||
console.log('model list====2');
|
console.log('model list====2');
|
||||||
const access = useAccess();
|
const access = useAccess();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const [modal, contextHolder] = Modal.useModal();
|
||||||
|
const { showDeleteModal } = useDeleteModal();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const rowSelection = useTableRowSelection();
|
const rowSelection = useTableRowSelection();
|
||||||
const { handleExpandChange, updateExpandedRowKeys, expandedRowKeys } =
|
const { handleExpandChange, updateExpandedRowKeys, expandedRowKeys } =
|
||||||
@@ -79,22 +82,27 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
const [currentInstanceUrl, setCurrentInstanceUrl] = useState<string>('');
|
const [currentInstanceUrl, setCurrentInstanceUrl] = useState<string>('');
|
||||||
|
const [deleteModalVisible, setDeleteModalVisible] = useState(false);
|
||||||
|
const [deletConfig, setDeletConfig] = useState<any>({});
|
||||||
|
const modalRef = useRef<any>(null);
|
||||||
|
|
||||||
const ActionList = [
|
const ActionList = [
|
||||||
{
|
{
|
||||||
label: intl.formatMessage({ id: 'common.button.edit' }),
|
label: 'common.button.edit',
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
icon: <EditOutlined />
|
icon: <EditOutlined />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: intl.formatMessage({ id: 'models.openinplayground' }),
|
label: 'models.openinplayground',
|
||||||
key: 'chat',
|
key: 'chat',
|
||||||
icon: <WechatWorkOutlined />
|
icon: <WechatWorkOutlined />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: intl.formatMessage({ id: 'common.button.delete' }),
|
label: 'common.button.delete',
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
danger: true,
|
props: {
|
||||||
|
danger: true
|
||||||
|
},
|
||||||
icon: <DeleteOutlined />
|
icon: <DeleteOutlined />
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -144,7 +152,8 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
setOpenLogModal(false);
|
setOpenLogModal(false);
|
||||||
}, []);
|
}, []);
|
||||||
const handleDelete = async (row: any) => {
|
const handleDelete = async (row: any) => {
|
||||||
Modal.confirm({
|
console.log('handleDelete=======111', row);
|
||||||
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -152,16 +161,27 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await deleteModel(row.id);
|
await deleteModel(row.id);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
updateExpandedRowKeys([row.id]);
|
updateExpandedRowKeys([row.id]);
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// setDeleteModalVisible(true);
|
||||||
|
// setDeletConfig({
|
||||||
|
// title: '',
|
||||||
|
// content: intl.formatMessage(
|
||||||
|
// { id: 'common.delete.confirm' },
|
||||||
|
// { type: intl.formatMessage({ id: 'models.table.models' }) }
|
||||||
|
// ),
|
||||||
|
// async onOk() {
|
||||||
|
// await deleteModel(row.id);
|
||||||
|
// updateExpandedRowKeys([row.id]);
|
||||||
|
// },
|
||||||
|
// onCancel: () => {
|
||||||
|
// setDeleteModalVisible(false);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
};
|
};
|
||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -169,12 +189,8 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
updateExpandedRowKeys(rowSelection.selectedRowKeys);
|
updateExpandedRowKeys(rowSelection.selectedRowKeys);
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -192,7 +208,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleDeleteInstace = (row: any, list: ModelInstanceListItem[]) => {
|
const handleDeleteInstace = (row: any, list: ModelInstanceListItem[]) => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -200,13 +216,9 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await deleteModelInstance(row.id);
|
await deleteModelInstance(row.id);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
if (list.length === 1) {
|
if (list.length === 1) {
|
||||||
updateExpandedRowKeys([row.model_id]);
|
updateExpandedRowKeys([row.model_id]);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -234,6 +246,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
|
|
||||||
const handleSelect = useCallback((val: any, row: ListItem) => {
|
const handleSelect = useCallback((val: any, row: ListItem) => {
|
||||||
if (val === 'edit') {
|
if (val === 'edit') {
|
||||||
|
console.log('row=======', row);
|
||||||
handleEdit(row);
|
handleEdit(row);
|
||||||
}
|
}
|
||||||
if (val === 'chat') {
|
if (val === 'chat') {
|
||||||
@@ -393,12 +406,13 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
key="operation"
|
key="operation"
|
||||||
dataIndex="operation"
|
dataIndex="operation"
|
||||||
render={(text, record) => {
|
render={(text, record) => {
|
||||||
return !record.transition ? (
|
console.log('record====9999', record);
|
||||||
|
return (
|
||||||
<DropdownButtons
|
<DropdownButtons
|
||||||
items={setActionList(record)}
|
items={setActionList(record)}
|
||||||
onSelect={(val) => handleSelect(val, record)}
|
onSelect={(val) => handleSelect(val, record)}
|
||||||
></DropdownButtons>
|
></DropdownButtons>
|
||||||
) : null;
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SealTable>
|
</SealTable>
|
||||||
@@ -416,8 +430,13 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
open={openLogModal}
|
open={openLogModal}
|
||||||
onCancel={handleLogModalCancel}
|
onCancel={handleLogModalCancel}
|
||||||
></ViewLogsModal>
|
></ViewLogsModal>
|
||||||
|
<DeleteModal
|
||||||
|
open={deleteModalVisible}
|
||||||
|
{...deletConfig}
|
||||||
|
ref={modalRef}
|
||||||
|
></DeleteModal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(Models);
|
export default Models;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import PageTools from '@/components/page-tools';
|
import PageTools from '@/components/page-tools';
|
||||||
import ProgressBar from '@/components/progress-bar';
|
import ProgressBar from '@/components/progress-bar';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
|
import useDeleteModal from '@/hooks/use-delete-modal';
|
||||||
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
||||||
import useTableSort from '@/hooks/use-table-sort';
|
import useTableSort from '@/hooks/use-table-sort';
|
||||||
import { convertFileSize, handleBatchRequest } from '@/utils';
|
import { convertFileSize, handleBatchRequest } from '@/utils';
|
||||||
@@ -10,7 +11,7 @@ import {
|
|||||||
SyncOutlined
|
SyncOutlined
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Input, Modal, Space, Table, Tooltip, message } from 'antd';
|
import { Button, Input, Space, Table, Tooltip } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import { deleteWorker, queryWorkersList } from '../apis';
|
import { deleteWorker, queryWorkersList } from '../apis';
|
||||||
@@ -24,6 +25,7 @@ const Resources: React.FC = () => {
|
|||||||
const { sortOrder, setSortOrder } = useTableSort({
|
const { sortOrder, setSortOrder } = useTableSort({
|
||||||
defaultSortOrder: 'descend'
|
defaultSortOrder: 'descend'
|
||||||
});
|
});
|
||||||
|
const { showDeleteModal } = useDeleteModal();
|
||||||
const rowSelection = useTableRowSelection();
|
const rowSelection = useTableRowSelection();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
@@ -100,7 +102,7 @@ const Resources: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -109,17 +111,13 @@ const Resources: React.FC = () => {
|
|||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteWorker(row.id);
|
await deleteWorker(row.id);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -127,12 +125,8 @@ const Resources: React.FC = () => {
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-15
@@ -2,6 +2,7 @@ import DropdownButtons from '@/components/drop-down-buttons';
|
|||||||
import PageTools from '@/components/page-tools';
|
import PageTools from '@/components/page-tools';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import type { PageActionType } from '@/config/types';
|
import type { PageActionType } from '@/config/types';
|
||||||
|
import useDeleteModal from '@/hooks/use-delete-modal';
|
||||||
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
||||||
import useTableSort from '@/hooks/use-table-sort';
|
import useTableSort from '@/hooks/use-table-sort';
|
||||||
import { handleBatchRequest } from '@/utils';
|
import { handleBatchRequest } from '@/utils';
|
||||||
@@ -15,7 +16,7 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Input, Modal, Space, Table, message } from 'antd';
|
import { Button, Input, Space, Table, message } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
@@ -30,6 +31,7 @@ const Users: React.FC = () => {
|
|||||||
const { sortOrder, setSortOrder } = useTableSort({
|
const { sortOrder, setSortOrder } = useTableSort({
|
||||||
defaultSortOrder: 'descend'
|
defaultSortOrder: 'descend'
|
||||||
});
|
});
|
||||||
|
const { showDeleteModal } = useDeleteModal();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [openAddModal, setOpenAddModal] = useState(false);
|
const [openAddModal, setOpenAddModal] = useState(false);
|
||||||
@@ -49,13 +51,15 @@ const Users: React.FC = () => {
|
|||||||
const ActionList = [
|
const ActionList = [
|
||||||
{
|
{
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
label: intl.formatMessage({ id: 'common.button.edit' }),
|
label: 'common.button.edit',
|
||||||
icon: <EditOutlined></EditOutlined>
|
icon: <EditOutlined></EditOutlined>
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
danger: true,
|
props: {
|
||||||
label: intl.formatMessage({ id: 'common.button.delete' }),
|
danger: true
|
||||||
|
},
|
||||||
|
label: 'common.button.delete',
|
||||||
icon: <DeleteOutlined></DeleteOutlined>
|
icon: <DeleteOutlined></DeleteOutlined>
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -138,7 +142,7 @@ const Users: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -147,17 +151,13 @@ const Users: React.FC = () => {
|
|||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteUser(row.id);
|
await deleteUser(row.id);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
Modal.confirm({
|
showDeleteModal({
|
||||||
title: '',
|
title: '',
|
||||||
content: intl.formatMessage(
|
content: intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{ id: 'common.delete.confirm' },
|
||||||
@@ -165,12 +165,8 @@ const Users: React.FC = () => {
|
|||||||
),
|
),
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteUser);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteUser);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
fetchData();
|
fetchData();
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log('Cancel');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -295,7 +291,7 @@ const Users: React.FC = () => {
|
|||||||
defaultSortOrder="descend"
|
defaultSortOrder="descend"
|
||||||
sortOrder={sortOrder}
|
sortOrder={sortOrder}
|
||||||
showSorterTooltip={false}
|
showSorterTooltip={false}
|
||||||
sorter={true}
|
sorter={false}
|
||||||
render={(text, record) => {
|
render={(text, record) => {
|
||||||
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user