style: change select to radio group
This commit is contained in:
@@ -6,7 +6,7 @@ const Wrapper: React.FC<{
|
|||||||
label?: string;
|
label?: string;
|
||||||
description?: React.ReactNode;
|
description?: React.ReactNode;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}> = ({ children, label, description }) => {
|
}> = ({ children, label, description, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<div className={styles['wrapper']}>
|
<div className={styles['wrapper']}>
|
||||||
{label && (
|
{label && (
|
||||||
@@ -14,7 +14,9 @@ const Wrapper: React.FC<{
|
|||||||
<LabelInfo label={label} description={description}></LabelInfo>
|
<LabelInfo label={label} description={description}></LabelInfo>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{children}
|
{React.isValidElement(children)
|
||||||
|
? React.cloneElement(children, { ...rest })
|
||||||
|
: children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,13 +77,6 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
fitAddonRef.current = new FitAddon();
|
fitAddonRef.current = new FitAddon();
|
||||||
termRef.current.loadAddon(fitAddonRef.current);
|
termRef.current.loadAddon(fitAddonRef.current);
|
||||||
termRef.current.open(termwrapRef.current);
|
termRef.current.open(termwrapRef.current);
|
||||||
|
|
||||||
// add event
|
|
||||||
// termRef.current.onLineFeed((e: any) => {
|
|
||||||
// if (cacheDataRef.current) {
|
|
||||||
// throttleScroll();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResize = _.throttle(() => {
|
const handleResize = _.throttle(() => {
|
||||||
|
|||||||
@@ -51,6 +51,19 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
|||||||
return pattern.test(url);
|
return pattern.test(url);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const generateImgSrc = useCallback(
|
||||||
|
(src: string | null) => {
|
||||||
|
if (!src) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (generateImgLink) {
|
||||||
|
return isValidURL(src) ? src : generateImgLink(src);
|
||||||
|
}
|
||||||
|
return src;
|
||||||
|
},
|
||||||
|
[generateImgLink]
|
||||||
|
);
|
||||||
|
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
(token: any, render: any) => {
|
(token: any, render: any) => {
|
||||||
if (!reDefineTypes.includes(token.type)) {
|
if (!reDefineTypes.includes(token.type)) {
|
||||||
@@ -97,10 +110,7 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token.type === 'image') {
|
if (token.type === 'image') {
|
||||||
let href = token.href;
|
let href = generateImgSrc(token.href);
|
||||||
if (!isValidURL(token.href)) {
|
|
||||||
href = generateImgLink ? generateImgLink(token.href) : token.href;
|
|
||||||
}
|
|
||||||
htmlstr = (
|
htmlstr = (
|
||||||
<Image
|
<Image
|
||||||
src={href}
|
src={href}
|
||||||
@@ -149,7 +159,7 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
|||||||
|
|
||||||
return htmlstr;
|
return htmlstr;
|
||||||
},
|
},
|
||||||
[generateImgLink]
|
[generateImgSrc]
|
||||||
);
|
);
|
||||||
const renderTokens = (tokens: TokensList): any => {
|
const renderTokens = (tokens: TokensList): any => {
|
||||||
return tokens?.map((token: any, index: number) => {
|
return tokens?.map((token: any, index: number) => {
|
||||||
@@ -164,11 +174,9 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
|||||||
const imgs = document.querySelectorAll('.markdown-viewer img');
|
const imgs = document.querySelectorAll('.markdown-viewer img');
|
||||||
imgs.forEach((img) => {
|
imgs.forEach((img) => {
|
||||||
const src = img.getAttribute('src');
|
const src = img.getAttribute('src');
|
||||||
if (src && !isValidURL(src)) {
|
img.setAttribute('src', generateImgSrc(src));
|
||||||
img.setAttribute('src', generateImgLink ? generateImgLink(src) : src);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, [content, generateImgLink]);
|
}, [content, generateImgSrc]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ interface WrapperProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
description?: string;
|
description?: React.ReactNode;
|
||||||
variant?: string;
|
variant?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
|||||||
@@ -444,6 +444,16 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.user-menu-collapsed {
|
&.user-menu-collapsed {
|
||||||
|
.ant-menu-submenu-title {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: var(--color-text-1) !important;
|
||||||
|
padding-inline: unset !important;
|
||||||
|
width: 100%;
|
||||||
|
margin-inline: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.user-avatar.ant-menu-submenu {
|
.user-avatar.ant-menu-submenu {
|
||||||
.ant-menu-submenu-title {
|
.ant-menu-submenu-title {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
|
|||||||
@@ -225,6 +225,9 @@ export default (props: any) => {
|
|||||||
layout="side"
|
layout="side"
|
||||||
disableMobile={true}
|
disableMobile={true}
|
||||||
siderWidth={220}
|
siderWidth={220}
|
||||||
|
onCollapse={(collapsed) => {
|
||||||
|
setCollapsed(collapsed);
|
||||||
|
}}
|
||||||
onMenuHeaderClick={(e) => {
|
onMenuHeaderClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -99,11 +99,6 @@ export const getRightRenderContent = (opts: {
|
|||||||
icon: <InfoCircleOutlined />,
|
icon: <InfoCircleOutlined />,
|
||||||
label: intl.formatMessage({ id: 'common.button.version' })
|
label: intl.formatMessage({ id: 'common.button.version' })
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
// key: 'shortcuts',
|
|
||||||
// icon: <IconFont type="icon-keyboard"></IconFont>,
|
|
||||||
// label: intl.formatMessage({ id: 'common.button.shortcut' })
|
|
||||||
// }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const helpMenu = {
|
const helpMenu = {
|
||||||
@@ -113,7 +108,7 @@ export const getRightRenderContent = (opts: {
|
|||||||
: 'user-menu-container',
|
: 'user-menu-container',
|
||||||
mode: 'vertical',
|
mode: 'vertical',
|
||||||
expandIcon: false,
|
expandIcon: false,
|
||||||
inlineCollapsed: collapsed,
|
// inlineCollapsed: collapsed,
|
||||||
triggerSubMenuAction: 'hover',
|
triggerSubMenuAction: 'hover',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@@ -163,7 +158,7 @@ export const getRightRenderContent = (opts: {
|
|||||||
: 'user-menu-container',
|
: 'user-menu-container',
|
||||||
mode: 'vertical',
|
mode: 'vertical',
|
||||||
expandIcon: false,
|
expandIcon: false,
|
||||||
inlineCollapsed: collapsed,
|
// inlineCollapsed: collapsed,
|
||||||
triggerSubMenuAction: 'hover',
|
triggerSubMenuAction: 'hover',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@@ -196,7 +191,7 @@ export const getRightRenderContent = (opts: {
|
|||||||
: 'user-menu-container',
|
: 'user-menu-container',
|
||||||
mode: 'vertical',
|
mode: 'vertical',
|
||||||
expandIcon: false,
|
expandIcon: false,
|
||||||
inlineCollapsed: collapsed,
|
// inlineCollapsed: collapsed,
|
||||||
triggerSubMenuAction: 'hover',
|
triggerSubMenuAction: 'hover',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@@ -263,19 +258,19 @@ export const getRightRenderContent = (opts: {
|
|||||||
<Menu
|
<Menu
|
||||||
{...helpMenu}
|
{...helpMenu}
|
||||||
style={{
|
style={{
|
||||||
width: collapsed ? 64 : `calc(${siderWidth}px - 16px)`
|
width: collapsed ? 40 : `calc(${siderWidth}px - 16px)`
|
||||||
}}
|
}}
|
||||||
></Menu>
|
></Menu>
|
||||||
<Menu
|
<Menu
|
||||||
{...langMenu}
|
{...langMenu}
|
||||||
style={{
|
style={{
|
||||||
width: collapsed ? 64 : `calc(${siderWidth}px - 16px)`
|
width: collapsed ? 40 : `calc(${siderWidth}px - 16px)`
|
||||||
}}
|
}}
|
||||||
></Menu>
|
></Menu>
|
||||||
<Menu
|
<Menu
|
||||||
{...userMenu}
|
{...userMenu}
|
||||||
style={{
|
style={{
|
||||||
width: collapsed ? 64 : `calc(${siderWidth}px - 16px)`,
|
width: collapsed ? 40 : `calc(${siderWidth}px - 16px)`,
|
||||||
marginTop: 20
|
marginTop: 20
|
||||||
}}
|
}}
|
||||||
></Menu>
|
></Menu>
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import LabelSelector from '@/components/label-selector';
|
import LabelSelector from '@/components/label-selector';
|
||||||
|
import FieldWrapper from '@/components/label-selector/wrapper';
|
||||||
import ListInput from '@/components/list-input';
|
import ListInput from '@/components/list-input';
|
||||||
import SealSelect from '@/components/seal-form/seal-select';
|
import SealSelect from '@/components/seal-form/seal-select';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
import { InfoCircleOutlined, RightOutlined } from '@ant-design/icons';
|
import { InfoCircleOutlined, RightOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Collapse,
|
Collapse,
|
||||||
Form,
|
Form,
|
||||||
FormInstance,
|
FormInstance,
|
||||||
|
Radio,
|
||||||
Select,
|
Select,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Typography
|
Typography
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import { backendOptionsMap, placementStrategyOptions } from '../config';
|
import { backendOptionsMap } from '../config';
|
||||||
import llamaConfig from '../config/llama-config';
|
import llamaConfig from '../config/llama-config';
|
||||||
import { FormData } from '../config/types';
|
import { FormData } from '../config/types';
|
||||||
import vllmConfig from '../config/vllm-config';
|
import vllmConfig from '../config/vllm-config';
|
||||||
@@ -116,7 +119,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
const children = (
|
const children = (
|
||||||
<>
|
<>
|
||||||
<Form.Item name="scheduleType">
|
<Form.Item name="scheduleType">
|
||||||
<SealSelect
|
{/* <SealSelect
|
||||||
label={intl.formatMessage({ id: 'models.form.scheduletype' })}
|
label={intl.formatMessage({ id: 'models.form.scheduletype' })}
|
||||||
description={renderSelectTips(scheduleTypeTips)}
|
description={renderSelectTips(scheduleTypeTips)}
|
||||||
options={[
|
options={[
|
||||||
@@ -133,18 +136,46 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
value: 'manual'
|
value: 'manual'
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
></SealSelect>
|
></SealSelect> */}
|
||||||
|
<FieldWrapper
|
||||||
|
label={intl.formatMessage({ id: 'models.form.scheduletype' })}
|
||||||
|
description={renderSelectTips(scheduleTypeTips)}
|
||||||
|
>
|
||||||
|
<Radio.Group style={{ marginTop: 5 }}>
|
||||||
|
<Radio value="auto">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: 'models.form.scheduletype.auto'
|
||||||
|
})}
|
||||||
|
</Radio>
|
||||||
|
<Radio value="manual">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: 'models.form.scheduletype.manual'
|
||||||
|
})}
|
||||||
|
</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</FieldWrapper>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{scheduleType === 'auto' && (
|
{scheduleType === 'auto' && (
|
||||||
<>
|
<>
|
||||||
<Form.Item<FormData> name="placement_strategy">
|
<Form.Item<FormData> name="placement_strategy">
|
||||||
<SealSelect
|
{/* <SealSelect
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'resources.form.placementStrategy'
|
id: 'resources.form.placementStrategy'
|
||||||
})}
|
})}
|
||||||
options={placementStrategyOptions}
|
options={placementStrategyOptions}
|
||||||
description={renderSelectTips(placementStrategyTips)}
|
description={renderSelectTips(placementStrategyTips)}
|
||||||
></SealSelect>
|
></SealSelect> */}
|
||||||
|
<FieldWrapper
|
||||||
|
label={intl.formatMessage({
|
||||||
|
id: 'resources.form.placementStrategy'
|
||||||
|
})}
|
||||||
|
description={renderSelectTips(placementStrategyTips)}
|
||||||
|
>
|
||||||
|
<Radio.Group style={{ marginTop: 5 }}>
|
||||||
|
<Radio value="spread">Spread</Radio>
|
||||||
|
<Radio value="binpack">Binpack</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</FieldWrapper>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="worker_selector"
|
name="worker_selector"
|
||||||
@@ -219,7 +250,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<Form.Item name="backend">
|
<Form.Item name="backend">
|
||||||
<SealSelect
|
{/* <SealSelect
|
||||||
label={intl.formatMessage({ id: 'models.form.backend' })}
|
label={intl.formatMessage({ id: 'models.form.backend' })}
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
@@ -234,7 +265,25 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
disabled={action === PageAction.EDIT}
|
disabled={action === PageAction.EDIT}
|
||||||
></SealSelect>
|
></SealSelect> */}
|
||||||
|
<FieldWrapper
|
||||||
|
label={intl.formatMessage({ id: 'models.form.backend' })}
|
||||||
|
>
|
||||||
|
<Radio.Group>
|
||||||
|
<Radio
|
||||||
|
value={backendOptionsMap.llamaBox}
|
||||||
|
disabled={!isGGUF || action === PageAction.EDIT}
|
||||||
|
>
|
||||||
|
llama-box(llama.cpp)
|
||||||
|
</Radio>
|
||||||
|
<Radio
|
||||||
|
value={backendOptionsMap.vllm}
|
||||||
|
disabled={isGGUF || action === PageAction.EDIT}
|
||||||
|
>
|
||||||
|
vLLM
|
||||||
|
</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</FieldWrapper>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData> name="backend_parameters">
|
<Form.Item<FormData> name="backend_parameters">
|
||||||
<ListInput
|
<ListInput
|
||||||
|
|||||||
@@ -72,33 +72,21 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
setGpuOptions(list);
|
setGpuOptions(list);
|
||||||
};
|
};
|
||||||
|
|
||||||
const initFormValue = () => {
|
const initFormValue = useMemo(() => {
|
||||||
if (action === PageAction.CREATE && open) {
|
const result = setSourceRepoConfigValue(
|
||||||
form.setFieldsValue({
|
props.data?.source || '',
|
||||||
source: modelSourceMap.huggingface_value,
|
props.data
|
||||||
replicas: 1
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
if (action === PageAction.EDIT && open) {
|
|
||||||
const result = setSourceRepoConfigValue(
|
|
||||||
props.data?.source || '',
|
|
||||||
props.data
|
|
||||||
);
|
|
||||||
|
|
||||||
form.setFieldsValue({
|
return {
|
||||||
...result.values,
|
...result.values,
|
||||||
..._.omit(props.data, result.omits),
|
..._.omit(props.data, result.omits),
|
||||||
scheduleType: props.data?.gpu_selector ? 'manual' : 'auto',
|
scheduleType: props.data?.gpu_selector ? 'manual' : 'auto',
|
||||||
gpu_selector: props.data?.gpu_selector
|
gpu_selector: props.data?.gpu_selector
|
||||||
? `${props.data?.gpu_selector.worker_name}-${props.data?.gpu_selector.gpu_name}-${props.data?.gpu_selector.gpu_index}`
|
? `${props.data?.gpu_selector.worker_name}-${props.data?.gpu_selector.gpu_name}-${props.data?.gpu_selector.gpu_index}`
|
||||||
: null
|
: null
|
||||||
});
|
};
|
||||||
}
|
}, [props.data]);
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
initFormValue();
|
|
||||||
}, [open]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsGGUF(props.data?.backend === backendOptionsMap.llamaBox);
|
setIsGGUF(props.data?.backend === backendOptionsMap.llamaBox);
|
||||||
@@ -306,6 +294,9 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
padding: 'var(--ant-modal-content-padding)',
|
padding: 'var(--ant-modal-content-padding)',
|
||||||
paddingBlock: 0
|
paddingBlock: 0
|
||||||
}}
|
}}
|
||||||
|
initialValues={{
|
||||||
|
...initFormValue
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="name"
|
name="name"
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
|||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
<span className="flex flex-center">
|
<span className="flex flex-center">
|
||||||
<span> {intl.formatMessage({ id: 'common.button.viewlog' })}</span>
|
<span style={{ fontWeight: 'var(--font-weight-bold)' }}>
|
||||||
|
{' '}
|
||||||
|
{intl.formatMessage({ id: 'common.button.viewlog' })}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
open={open}
|
open={open}
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ const ContentItem: React.FC<MessageItemProps> = ({
|
|||||||
|
|
||||||
const handleUpdateImgList = useCallback(
|
const handleUpdateImgList = useCallback(
|
||||||
(list: { uid: number | string; dataUrl: string }[]) => {
|
(list: { uid: number | string; dataUrl: string }[]) => {
|
||||||
console.log('list===========', data.imgs, list);
|
|
||||||
updateMessage?.({
|
updateMessage?.({
|
||||||
role: data.role,
|
role: data.role,
|
||||||
content: data.content,
|
content: data.content,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
.role {
|
.role {
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
border-radius: var(--border-radius-mini);
|
border-radius: var(--border-radius-mini);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user