style: endpoint selection
This commit is contained in:
@@ -57,7 +57,7 @@ const MetadataList: React.FC<MetadataListProps> = ({
|
|||||||
>
|
>
|
||||||
{dataList.map((item, index) => (
|
{dataList.map((item, index) => (
|
||||||
<ItemContainer key={index}>
|
<ItemContainer key={index}>
|
||||||
{children ? children(item, index) : null}
|
{children?.(item, index)}
|
||||||
{!disabled && (
|
{!disabled && (
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ const SealInputNumber: React.FC<InputNumberProps & SealFormItemProps> = (
|
|||||||
>
|
>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
{...rest}
|
{...rest}
|
||||||
|
placeholder={placeholder}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
onFocus={handleOnFocus}
|
onFocus={handleOnFocus}
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ const SealCascader: React.FC<
|
|||||||
>
|
>
|
||||||
<Cascader
|
<Cascader
|
||||||
{...rest}
|
{...rest}
|
||||||
|
placeholder={placeholder}
|
||||||
suffixIcon={<IconFont type="icon-down"></IconFont>}
|
suffixIcon={<IconFont type="icon-down"></IconFont>}
|
||||||
optionRender={
|
optionRender={
|
||||||
optionNode
|
optionNode
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ const InputWrapper = styled.div`
|
|||||||
.ant-input-textarea-allow-clear.ant-input-affix-wrapper {
|
.ant-input-textarea-allow-clear.ant-input-affix-wrapper {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
.ant-input-number-input:placeholder-shown {
|
||||||
|
font-size: var(--ant-font-size);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default InputWrapper;
|
export default InputWrapper;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ const SelectWrapper = styled.div`
|
|||||||
&.dropdown-visible {
|
&.dropdown-visible {
|
||||||
.__wrapper__ {
|
.__wrapper__ {
|
||||||
.ant-cascader.ant-select.ant-select-outlined {
|
.ant-cascader.ant-select.ant-select-outlined {
|
||||||
|
border-color: var(--ant-input-active-border-color) !important;
|
||||||
|
outline: 0;
|
||||||
|
background-color: var(--ant-input-active-bg);
|
||||||
border-bottom: none !important;
|
border-bottom: none !important;
|
||||||
border-radius: ${BORDERRADIUS}px ${BORDERRADIUS}px 0 0;
|
border-radius: ${BORDERRADIUS}px ${BORDERRADIUS}px 0 0;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
@@ -82,7 +85,7 @@ const SelectWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ant-select .ant-select-input {
|
.ant-select .ant-select-input {
|
||||||
top: 5px !important;
|
top: 5px;
|
||||||
}
|
}
|
||||||
.ant-select-placeholder {
|
.ant-select-placeholder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -93,6 +96,14 @@ const SelectWrapper = styled.div`
|
|||||||
.ant-select .ant-select-content {
|
.ant-select .ant-select-content {
|
||||||
padding-block: 0px 0;
|
padding-block: 0px 0;
|
||||||
}
|
}
|
||||||
|
.ant-select.ant-cascader {
|
||||||
|
.ant-select-placeholder {
|
||||||
|
top: 0px !important;
|
||||||
|
}
|
||||||
|
.ant-select-input {
|
||||||
|
top: -6px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ant-select-selection-overflow-item > span {
|
.ant-select-selection-overflow-item > span {
|
||||||
|
|||||||
@@ -1,19 +1,91 @@
|
|||||||
import LabelSelector from '@/components/label-selector';
|
|
||||||
import { LabelSelectorContext } from '@/components/label-selector/context';
|
import { LabelSelectorContext } from '@/components/label-selector/context';
|
||||||
|
import MetadataList from '@/components/metadata-list';
|
||||||
|
import SealCascader from '@/components/seal-form/seal-cascader';
|
||||||
|
import SealInput from '@/components/seal-form/seal-input';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { useState } from 'react';
|
||||||
import { FormData } from '../config/types';
|
import { FormData } from '../config/types';
|
||||||
|
|
||||||
|
const providerModelList = [
|
||||||
|
{
|
||||||
|
label: 'Deployments',
|
||||||
|
value: 'deployments',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
label: 'qwen3-0.6b',
|
||||||
|
value: 'qwen3-0.6b',
|
||||||
|
key: '1',
|
||||||
|
provider_id: 1,
|
||||||
|
model_id: 101
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'deepseek',
|
||||||
|
value: 'deepseek',
|
||||||
|
key: '2',
|
||||||
|
provider_id: 1,
|
||||||
|
model_id: 102
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Doubao',
|
||||||
|
value: 'doubao',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
label: 'qwen3-0.6b',
|
||||||
|
value: 'qwen3-0.6b',
|
||||||
|
key: '3',
|
||||||
|
provider_id: 2,
|
||||||
|
model_id: 201
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'deepseek',
|
||||||
|
value: 'deepseek',
|
||||||
|
key: '4',
|
||||||
|
provider_id: 2,
|
||||||
|
model_id: 202
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const Endpoints = () => {
|
const Endpoints = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const form = Form.useFormInstance<FormData>();
|
const form = Form.useFormInstance<FormData>();
|
||||||
const endpoints = Form.useWatch('endpoints', form);
|
const endpoints = Form.useWatch('endpoints', form);
|
||||||
|
const [dataList, setDataList] = useState<
|
||||||
|
{
|
||||||
|
provider_model_name: string;
|
||||||
|
weight: number;
|
||||||
|
model_id: number;
|
||||||
|
provider_id: number;
|
||||||
|
}[]
|
||||||
|
>(endpoints || []);
|
||||||
|
|
||||||
const handleEndpointsChange = (labels: Record<string, any>) => {
|
const handleEndpointsChange = (labels: Record<string, any>) => {
|
||||||
form.setFieldValue('endpoints', labels);
|
form.setFieldValue('endpoints', labels);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOnAdd = () => {
|
||||||
|
const newDataList = [
|
||||||
|
...dataList,
|
||||||
|
{
|
||||||
|
provider_model_name: '',
|
||||||
|
weight: 1,
|
||||||
|
model_id: 0,
|
||||||
|
provider_id: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
|
setDataList(newDataList);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleOnDelete = (index: number, item: any) => {
|
||||||
|
const newDataList = dataList.filter((_, i) => i !== index);
|
||||||
|
setDataList(newDataList);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LabelSelectorContext.Provider
|
<LabelSelectorContext.Provider
|
||||||
@@ -58,13 +130,39 @@ const Endpoints = () => {
|
|||||||
})
|
})
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<LabelSelector
|
<MetadataList
|
||||||
isAutoComplete
|
|
||||||
label={'Endpoints'}
|
label={'Endpoints'}
|
||||||
labels={endpoints}
|
dataList={dataList}
|
||||||
btnText="Add Endpoint"
|
btnText="Add Endpoint"
|
||||||
onChange={handleEndpointsChange}
|
onAdd={handleOnAdd}
|
||||||
></LabelSelector>
|
onDelete={handleOnDelete}
|
||||||
|
>
|
||||||
|
{(item, index) => (
|
||||||
|
<>
|
||||||
|
<SealCascader
|
||||||
|
required
|
||||||
|
showSearch
|
||||||
|
expandTrigger="hover"
|
||||||
|
multiple={false}
|
||||||
|
classNames={{
|
||||||
|
popup: {
|
||||||
|
root: 'cascader-popup-wrapper gpu-selector'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
maxTagCount={1}
|
||||||
|
placeholder="provider/model"
|
||||||
|
options={providerModelList}
|
||||||
|
showCheckedStrategy="SHOW_CHILD"
|
||||||
|
getPopupContainer={(triggerNode) => triggerNode.parentNode}
|
||||||
|
></SealCascader>
|
||||||
|
<span className="seprator">:</span>
|
||||||
|
<SealInput.Number
|
||||||
|
style={{ flex: 60 }}
|
||||||
|
placeholder="weight"
|
||||||
|
></SealInput.Number>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</MetadataList>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LabelSelectorContext.Provider>
|
</LabelSelectorContext.Provider>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user