fix: windows path style
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
import { useMemo } from 'react';
|
import DropDownActions from '@/components/drop-down-actions';
|
||||||
|
import {
|
||||||
|
DeleteOutlined,
|
||||||
|
DownOutlined,
|
||||||
|
PlusOutlined,
|
||||||
|
SyncOutlined
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { Button, Input, Select, Space } from 'antd';
|
||||||
|
import React, { useMemo } from 'react';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
type PageToolsProps = {
|
type PageToolsProps = {
|
||||||
@@ -36,4 +45,136 @@ const PageTools: React.FC<PageToolsProps> = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface ActionItem {
|
||||||
|
label: string;
|
||||||
|
locale: boolean;
|
||||||
|
value: string;
|
||||||
|
key: string;
|
||||||
|
icon: React.ReactNode;
|
||||||
|
}
|
||||||
|
interface FilterBarProps {
|
||||||
|
handleInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||||
|
handleSelectChange?: (value: any) => void;
|
||||||
|
handleSearch: () => void;
|
||||||
|
handleDeleteByBatch: () => void;
|
||||||
|
handleClickPrimary: (item: any) => void;
|
||||||
|
rowSelection: any;
|
||||||
|
actionItems: ActionItem[];
|
||||||
|
selectOptions?: Global.BaseListItem<string>[];
|
||||||
|
showSelect?: boolean;
|
||||||
|
buttonText: string;
|
||||||
|
buttonIcon?: React.ReactNode;
|
||||||
|
marginBottom?: number;
|
||||||
|
marginTop?: number;
|
||||||
|
inputHolder: string;
|
||||||
|
selectHolder: string;
|
||||||
|
actionType: 'dropdown' | 'button';
|
||||||
|
width?: {
|
||||||
|
input: number;
|
||||||
|
select: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FilterBar: React.FC<FilterBarProps> = (props) => {
|
||||||
|
const {
|
||||||
|
handleInputChange,
|
||||||
|
handleSelectChange,
|
||||||
|
handleSearch,
|
||||||
|
handleDeleteByBatch,
|
||||||
|
handleClickPrimary,
|
||||||
|
rowSelection,
|
||||||
|
actionItems,
|
||||||
|
selectOptions,
|
||||||
|
showSelect,
|
||||||
|
buttonText,
|
||||||
|
buttonIcon,
|
||||||
|
actionType,
|
||||||
|
marginBottom = 10,
|
||||||
|
marginTop = 10,
|
||||||
|
inputHolder,
|
||||||
|
selectHolder,
|
||||||
|
width
|
||||||
|
} = props;
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageTools
|
||||||
|
marginBottom={marginBottom}
|
||||||
|
marginTop={marginTop}
|
||||||
|
left={
|
||||||
|
<Space>
|
||||||
|
<Input
|
||||||
|
placeholder={intl.formatMessage({
|
||||||
|
id: inputHolder
|
||||||
|
})}
|
||||||
|
style={{ width: width?.input || 230 }}
|
||||||
|
allowClear
|
||||||
|
onChange={handleInputChange}
|
||||||
|
></Input>
|
||||||
|
{showSelect && (
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
showSearch={false}
|
||||||
|
placeholder={intl.formatMessage({
|
||||||
|
id: selectHolder
|
||||||
|
})}
|
||||||
|
style={{ width: width?.select || 230 }}
|
||||||
|
size="large"
|
||||||
|
onChange={handleSelectChange}
|
||||||
|
options={selectOptions}
|
||||||
|
></Select>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
style={{ color: 'var(--ant-color-text-tertiary)' }}
|
||||||
|
onClick={handleSearch}
|
||||||
|
icon={<SyncOutlined></SyncOutlined>}
|
||||||
|
></Button>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
right={
|
||||||
|
<Space size={20}>
|
||||||
|
{actionType === 'dropdown' ? (
|
||||||
|
<DropDownActions
|
||||||
|
menu={{
|
||||||
|
items: actionItems,
|
||||||
|
onClick: handleClickPrimary
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
icon={<DownOutlined></DownOutlined>}
|
||||||
|
type="primary"
|
||||||
|
iconPosition="end"
|
||||||
|
>
|
||||||
|
{buttonText}
|
||||||
|
</Button>
|
||||||
|
</DropDownActions>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
icon={buttonIcon ?? <PlusOutlined></PlusOutlined>}
|
||||||
|
type="primary"
|
||||||
|
onClick={handleClickPrimary}
|
||||||
|
>
|
||||||
|
{buttonText}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
danger
|
||||||
|
onClick={handleDeleteByBatch}
|
||||||
|
disabled={!rowSelection.selectedRowKeys.length}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{intl?.formatMessage?.({ id: 'common.button.delete' })}
|
||||||
|
{rowSelection.selectedRowKeys.length > 0 && (
|
||||||
|
<span>({rowSelection.selectedRowKeys?.length})</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
></PageTools>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default PageTools;
|
export default PageTools;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export default function useTableFetch<ListItem>(options: {
|
|||||||
setSortOrder(sorter.order);
|
setSortOrder(sorter.order);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearch = (e: any) => {
|
const handleSearch = () => {
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ import { modelsExpandKeysAtom } from '@/atoms/models';
|
|||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import CopyButton from '@/components/copy-button';
|
import CopyButton from '@/components/copy-button';
|
||||||
import DeleteModal from '@/components/delete-modal';
|
import DeleteModal from '@/components/delete-modal';
|
||||||
import DropDownActions from '@/components/drop-down-actions';
|
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import PageTools from '@/components/page-tools';
|
import { FilterBar } from '@/components/page-tools';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import useAppUtils from '@/hooks/use-app-utils';
|
import useAppUtils from '@/hooks/use-app-utils';
|
||||||
@@ -27,19 +26,8 @@ import {
|
|||||||
} from '@/pages/llmodels/config/button-actions';
|
} from '@/pages/llmodels/config/button-actions';
|
||||||
import DownloadModal from '@/pages/llmodels/download';
|
import DownloadModal from '@/pages/llmodels/download';
|
||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize } from '@/utils';
|
||||||
import { DeleteOutlined, DownOutlined, SyncOutlined } from '@ant-design/icons';
|
|
||||||
import { useIntl, useNavigate } from '@umijs/max';
|
import { useIntl, useNavigate } from '@umijs/max';
|
||||||
import {
|
import { ConfigProvider, Empty, Table, Tag, message } from 'antd';
|
||||||
Button,
|
|
||||||
ConfigProvider,
|
|
||||||
Empty,
|
|
||||||
Input,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Table,
|
|
||||||
Tag,
|
|
||||||
message
|
|
||||||
} from 'antd';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -244,7 +232,7 @@ const ModelFiles = () => {
|
|||||||
record.ollama_library_model_name ||
|
record.ollama_library_model_name ||
|
||||||
record.model_scope_model_id ||
|
record.model_scope_model_id ||
|
||||||
record.local_path,
|
record.local_path,
|
||||||
'/'
|
/[\\/]/
|
||||||
).pop()
|
).pop()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -405,7 +393,6 @@ const ModelFiles = () => {
|
|||||||
const handleCreateModel = async (data: any) => {
|
const handleCreateModel = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const result = getSourceRepoConfigValue(openDeployModal.source, data);
|
const result = getSourceRepoConfigValue(openDeployModal.source, data);
|
||||||
|
|
||||||
const modelData = await createModel({
|
const modelData = await createModel({
|
||||||
data: {
|
data: {
|
||||||
...result.values
|
...result.values
|
||||||
@@ -530,80 +517,31 @@ const ModelFiles = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageTools
|
<FilterBar
|
||||||
marginBottom={10}
|
actionType="dropdown"
|
||||||
marginTop={10}
|
selectHolder="resources.filter.worker"
|
||||||
left={
|
inputHolder="resources.filter.source"
|
||||||
<Space>
|
buttonText={intl.formatMessage({ id: 'resources.modelfiles.download' })}
|
||||||
<Input
|
handleSelectChange={handleWorkerChange}
|
||||||
placeholder={intl.formatMessage({
|
handleDeleteByBatch={handleDeleteByBatch}
|
||||||
id: 'resources.filter.source'
|
handleClickPrimary={handleClickDropdown}
|
||||||
})}
|
handleSearch={handleSearch}
|
||||||
style={{ width: 230 }}
|
selectOptions={onLineSourceOptions}
|
||||||
allowClear
|
handleInputChange={handleNameChange}
|
||||||
onChange={handleNameChange}
|
rowSelection={rowSelection}
|
||||||
></Input>
|
actionItems={onLineSourceOptions}
|
||||||
<Select
|
showSelect={true}
|
||||||
allowClear
|
></FilterBar>
|
||||||
showSearch={false}
|
|
||||||
placeholder={intl.formatMessage({
|
|
||||||
id: 'resources.filter.worker'
|
|
||||||
})}
|
|
||||||
style={{ width: 230 }}
|
|
||||||
size="large"
|
|
||||||
onChange={handleWorkerChange}
|
|
||||||
options={workersList}
|
|
||||||
></Select>
|
|
||||||
<Button
|
|
||||||
type="text"
|
|
||||||
style={{ color: 'var(--ant-color-text-tertiary)' }}
|
|
||||||
onClick={handleSearch}
|
|
||||||
icon={<SyncOutlined></SyncOutlined>}
|
|
||||||
></Button>
|
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
right={
|
|
||||||
<Space size={20}>
|
|
||||||
<DropDownActions
|
|
||||||
menu={{
|
|
||||||
items: onLineSourceOptions,
|
|
||||||
onClick: handleClickDropdown
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
icon={<DownOutlined></DownOutlined>}
|
|
||||||
type="primary"
|
|
||||||
iconPosition="end"
|
|
||||||
>
|
|
||||||
{intl.formatMessage({ id: 'resources.modelfiles.download' })}
|
|
||||||
</Button>
|
|
||||||
</DropDownActions>
|
|
||||||
<Button
|
|
||||||
icon={<DeleteOutlined />}
|
|
||||||
danger
|
|
||||||
onClick={handleDeleteByBatch}
|
|
||||||
disabled={!rowSelection.selectedRowKeys.length}
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
{intl?.formatMessage?.({ id: 'common.button.delete' })}
|
|
||||||
{rowSelection.selectedRowKeys.length > 0 && (
|
|
||||||
<span>({rowSelection.selectedRowKeys?.length})</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
></PageTools>
|
|
||||||
<ConfigProvider renderEmpty={renderEmpty}>
|
<ConfigProvider renderEmpty={renderEmpty}>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
rowKey="id"
|
||||||
tableLayout="fixed"
|
tableLayout="fixed"
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
|
onChange={handleTableChange}
|
||||||
dataSource={dataSource.dataList}
|
dataSource={dataSource.dataList}
|
||||||
loading={dataSource.loading}
|
loading={dataSource.loading}
|
||||||
rowKey="id"
|
|
||||||
onChange={handleTableChange}
|
|
||||||
rowSelection={rowSelection}
|
rowSelection={rowSelection}
|
||||||
|
columns={columns}
|
||||||
pagination={{
|
pagination={{
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
pageSize: queryParams.perPage,
|
pageSize: queryParams.perPage,
|
||||||
@@ -616,29 +554,29 @@ const ModelFiles = () => {
|
|||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
<DeleteModal ref={modalRef}></DeleteModal>
|
<DeleteModal ref={modalRef}></DeleteModal>
|
||||||
<DownloadModal
|
<DownloadModal
|
||||||
open={downloadModalStatus.show}
|
|
||||||
title={intl.formatMessage({ id: 'resources.modelfiles.download' })}
|
|
||||||
source={downloadModalStatus.source}
|
|
||||||
width={downloadModalStatus.width}
|
|
||||||
onCancel={handleDownloadCancel}
|
onCancel={handleDownloadCancel}
|
||||||
onOk={handleDownload}
|
onOk={handleDownload}
|
||||||
|
title={intl.formatMessage({ id: 'resources.modelfiles.download' })}
|
||||||
|
open={downloadModalStatus.show}
|
||||||
|
source={downloadModalStatus.source}
|
||||||
|
width={downloadModalStatus.width}
|
||||||
workersList={workersList.filter(
|
workersList={workersList.filter(
|
||||||
(item: any) => item.state === WorkerStatusMap.ready
|
(item: any) => item.state === WorkerStatusMap.ready
|
||||||
)}
|
)}
|
||||||
></DownloadModal>
|
></DownloadModal>
|
||||||
<DeployModal
|
<DeployModal
|
||||||
deploymentType="modelFiles"
|
deploymentType="modelFiles"
|
||||||
|
title={intl.formatMessage({ id: 'models.button.deploy' })}
|
||||||
|
onCancel={handleDeployModalCancel}
|
||||||
|
onOk={handleCreateModel}
|
||||||
open={openDeployModal.show}
|
open={openDeployModal.show}
|
||||||
action={PageAction.CREATE}
|
action={PageAction.CREATE}
|
||||||
title={intl.formatMessage({ id: 'models.button.deploy' })}
|
|
||||||
source={openDeployModal.source}
|
source={openDeployModal.source}
|
||||||
width={openDeployModal.width}
|
width={openDeployModal.width}
|
||||||
gpuOptions={openDeployModal.gpuOptions}
|
gpuOptions={openDeployModal.gpuOptions}
|
||||||
modelFileOptions={openDeployModal.modelFileOptions || []}
|
modelFileOptions={openDeployModal.modelFileOptions || []}
|
||||||
initialValues={openDeployModal.initialValues}
|
initialValues={openDeployModal.initialValues}
|
||||||
isGGUF={openDeployModal.isGGUF}
|
isGGUF={openDeployModal.isGGUF}
|
||||||
onCancel={handleDeployModalCancel}
|
|
||||||
onOk={handleCreateModel}
|
|
||||||
></DeployModal>
|
></DeployModal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user