style: providers selection, remove fallback form
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ export const StatusColorMap: Record<
|
|||||||
},
|
},
|
||||||
inactive: {
|
inactive: {
|
||||||
text: `var(--ant-color-text-tertiary)`,
|
text: `var(--ant-color-text-tertiary)`,
|
||||||
border: `rgba(200,200,200,1)`,
|
border: `var(--ant-color-border)`,
|
||||||
bg: `var(--ant-color-fill)`
|
bg: `var(--ant-color-fill)`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export default {
|
|||||||
'accesses.title': 'Accesses',
|
'accesses.title': 'Accesses',
|
||||||
'accesses.button.add': 'Add Access',
|
'accesses.button.add': 'Add Access',
|
||||||
'accesses.table.accessPoints': 'Access Points',
|
'accesses.table.accessPoints': 'Access Points',
|
||||||
'accesses.table.traffic': 'Traffic Share'
|
'accesses.table.traffic': 'Traffic Share',
|
||||||
|
'accesses.table.setAsFallback': 'Set as Fallback'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export default {
|
|||||||
'accesses.title': 'Accesses',
|
'accesses.title': 'Accesses',
|
||||||
'accesses.button.add': 'Add Access',
|
'accesses.button.add': 'Add Access',
|
||||||
'accesses.table.accessPoints': 'Access Points',
|
'accesses.table.accessPoints': 'Access Points',
|
||||||
'accesses.table.traffic': 'Traffic Share'
|
'accesses.table.traffic': 'Traffic Share',
|
||||||
|
'accesses.table.setAsFallback': 'Set as Fallback'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export default {
|
|||||||
'accesses.title': 'Accesses',
|
'accesses.title': 'Accesses',
|
||||||
'accesses.button.add': 'Add Access',
|
'accesses.button.add': 'Add Access',
|
||||||
'accesses.table.accessPoints': 'Access Points',
|
'accesses.table.accessPoints': 'Access Points',
|
||||||
'accesses.table.traffic': 'Traffic Share'
|
'accesses.table.traffic': 'Traffic Share',
|
||||||
|
'accesses.table.setAsFallback': 'Set as Fallback'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export default {
|
|||||||
'accesses.title': '接入',
|
'accesses.title': '接入',
|
||||||
'accesses.button.add': '添加接入',
|
'accesses.button.add': '添加接入',
|
||||||
'accesses.table.accessPoints': '接入点',
|
'accesses.table.accessPoints': '接入点',
|
||||||
'accesses.table.traffic': '流量'
|
'accesses.table.traffic': '流量',
|
||||||
|
'accesses.table.setAsFallback': '设为备选'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import { modelCategoriesMap } from '@/pages/llmodels/config';
|
import { modelCategoriesMap } from '@/pages/llmodels/config';
|
||||||
import {
|
import {
|
||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
@@ -54,17 +55,28 @@ const ProviderModels: React.FC<ProviderModelProps> = () => {
|
|||||||
<Tag
|
<Tag
|
||||||
key={model.name}
|
key={model.name}
|
||||||
icon={iconsMap[model.status]}
|
icon={iconsMap[model.status]}
|
||||||
|
variant="outlined"
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
}
|
||||||
|
}}
|
||||||
color={
|
color={
|
||||||
model.status === 'accessible'
|
model.status === 'accessible'
|
||||||
? 'success'
|
? 'success'
|
||||||
: model.status === 'inaccessible'
|
: model.status === 'inaccessible'
|
||||||
? 'red'
|
? 'red'
|
||||||
: 'gray'
|
: 'default'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{model.name}
|
<span className="flex-center">
|
||||||
<span style={{ marginLeft: 8 }}>
|
<AutoTooltip ghost maxWidth={'120px'}>
|
||||||
{categoryConfig[model.type]?.icon}
|
{model.name}
|
||||||
|
</AutoTooltip>
|
||||||
|
<span style={{ marginLeft: 8 }}>
|
||||||
|
{categoryConfig[model.type]?.icon}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</Tag>
|
</Tag>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,47 +1,12 @@
|
|||||||
import icons from '@/components/icon-font/icons';
|
import icons from '@/components/icon-font/icons';
|
||||||
import { StatusMaps } from '@/config';
|
import { StatusMaps } from '@/config';
|
||||||
import { StatusType } from '@/config/types';
|
import { StatusType } from '@/config/types';
|
||||||
|
import { ProviderEnum } from './providers';
|
||||||
|
export { maasProviderLabelMap, maasProviderOptions } from './providers';
|
||||||
|
|
||||||
export type maasProviderType =
|
export type maasProviderType = ProviderEnum[keyof ProviderEnum];
|
||||||
| 'doubao'
|
|
||||||
| 'qwen'
|
|
||||||
| 'openai'
|
|
||||||
| 'deepseek'
|
|
||||||
| 'anthropic';
|
|
||||||
|
|
||||||
export const maasProviderValueMap = {
|
export const maasProviderValueMap = ProviderEnum;
|
||||||
Doubao: 'doubao',
|
|
||||||
Qwen: 'qwen',
|
|
||||||
OpenAI: 'openai',
|
|
||||||
Deepseek: 'deepseek',
|
|
||||||
Anthropic: 'anthropic'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const maasProviderLabelMap = {
|
|
||||||
[maasProviderValueMap.Doubao]: 'Doubao',
|
|
||||||
[maasProviderValueMap.Qwen]: 'Qwen',
|
|
||||||
[maasProviderValueMap.OpenAI]: 'OpenAI',
|
|
||||||
[maasProviderValueMap.Deepseek]: 'DeepSeek',
|
|
||||||
[maasProviderValueMap.Anthropic]: 'Anthropic'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const providerIconsMap = {
|
|
||||||
[maasProviderValueMap.Doubao]: 'icon-doubao',
|
|
||||||
[maasProviderValueMap.Qwen]: 'icon-qwen',
|
|
||||||
[maasProviderValueMap.OpenAI]: 'icon-openai',
|
|
||||||
[maasProviderValueMap.Deepseek]: 'icon-deepseek',
|
|
||||||
[maasProviderValueMap.Anthropic]: 'icon-anthropic'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const maasProviderOptions = Object.entries(maasProviderValueMap).map(
|
|
||||||
([key, value]) => ({
|
|
||||||
label: maasProviderLabelMap[value],
|
|
||||||
value: value,
|
|
||||||
key: value,
|
|
||||||
locale: false,
|
|
||||||
icon: providerIconsMap[value]
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ProviderStatusValueMap: Record<string, string> = {
|
export const ProviderStatusValueMap: Record<string, string> = {
|
||||||
Ready: 'ready',
|
Ready: 'ready',
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export const mockDataList: MaasProviderItem[] = [
|
|||||||
models: 5,
|
models: 5,
|
||||||
state_message: '',
|
state_message: '',
|
||||||
provider: 'doubao',
|
provider: 'doubao',
|
||||||
proxy_config: {},
|
api_tokens: ['token1', 'token2'],
|
||||||
|
proxy_url: 'http://proxy.example.com',
|
||||||
builtIn: false
|
builtIn: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -19,7 +20,8 @@ export const mockDataList: MaasProviderItem[] = [
|
|||||||
state: 'inactive',
|
state: 'inactive',
|
||||||
state_message: 'Provider is inactive',
|
state_message: 'Provider is inactive',
|
||||||
provider: 'qwen',
|
provider: 'qwen',
|
||||||
proxy_config: false,
|
proxy_url: 'http://proxy2.example.com',
|
||||||
|
|
||||||
builtIn: true
|
builtIn: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -28,7 +30,8 @@ export const mockDataList: MaasProviderItem[] = [
|
|||||||
name: 'OpenAI',
|
name: 'OpenAI',
|
||||||
state: 'ready',
|
state: 'ready',
|
||||||
state_message: '',
|
state_message: '',
|
||||||
proxy_config: null,
|
proxy_url: null,
|
||||||
|
api_tokens: ['tokenA'],
|
||||||
provider: 'openai',
|
provider: 'openai',
|
||||||
builtIn: false
|
builtIn: false
|
||||||
},
|
},
|
||||||
@@ -39,7 +42,8 @@ export const mockDataList: MaasProviderItem[] = [
|
|||||||
state: 'ready',
|
state: 'ready',
|
||||||
state_message: '',
|
state_message: '',
|
||||||
provider: 'deepseek',
|
provider: 'deepseek',
|
||||||
proxy_config: null,
|
proxy_url: null,
|
||||||
|
api_tokens: ['tokenX', 'tokenY'],
|
||||||
builtIn: false
|
builtIn: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -49,7 +53,7 @@ export const mockDataList: MaasProviderItem[] = [
|
|||||||
state: 'inactive',
|
state: 'inactive',
|
||||||
state_message: 'Provider is inactive',
|
state_message: 'Provider is inactive',
|
||||||
provider: 'anthropic',
|
provider: 'anthropic',
|
||||||
proxy_config: {},
|
proxy_url: {},
|
||||||
builtIn: true
|
builtIn: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
export enum ProviderEnum {
|
||||||
|
AI360 = 'ai360',
|
||||||
|
AZURE = 'azure',
|
||||||
|
BAICHUAN = 'baichuan',
|
||||||
|
BAIDU = 'baidu',
|
||||||
|
BEDROCK = 'bedrock',
|
||||||
|
CLAUDE = 'claude',
|
||||||
|
CLOUDFLARE = 'cloudflare',
|
||||||
|
COHERE = 'cohere',
|
||||||
|
COZE = 'coze',
|
||||||
|
DEEPL = 'deepl',
|
||||||
|
DEEPSEEK = 'deepseek',
|
||||||
|
DIFY = 'dify',
|
||||||
|
DOUBAO = 'doubao',
|
||||||
|
FIREWORKS = 'fireworks',
|
||||||
|
GEMINI = 'gemini',
|
||||||
|
GITHUB = 'github',
|
||||||
|
GROK = 'grok',
|
||||||
|
GROQ = 'groq',
|
||||||
|
HUNYUAN = 'hunyuan',
|
||||||
|
LONGCAT = 'longcat',
|
||||||
|
MINIMAX = 'minimax',
|
||||||
|
MISTRAL = 'mistral',
|
||||||
|
MOONSHOT = 'moonshot',
|
||||||
|
OLLAMA = 'ollama',
|
||||||
|
OPENAI = 'openai',
|
||||||
|
OPENROUTER = 'openrouter',
|
||||||
|
QWEN = 'qwen',
|
||||||
|
SPARK = 'spark',
|
||||||
|
STEPFUN = 'stepfun',
|
||||||
|
TOGETHERAI = 'together-ai',
|
||||||
|
TRITON = 'triton',
|
||||||
|
YI = 'yi',
|
||||||
|
ZHIPUAI = 'zhipuai'
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate provider list: {label: string;value:string}[]
|
||||||
|
export const maasProviderOptions = Object.entries(ProviderEnum).map(
|
||||||
|
([key, value]) => ({
|
||||||
|
locale: false,
|
||||||
|
label: key,
|
||||||
|
value: value,
|
||||||
|
key: value
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// generate provider value to label map
|
||||||
|
export const maasProviderLabelMap: Record<string, string> = Object.entries(
|
||||||
|
ProviderEnum
|
||||||
|
).reduce(
|
||||||
|
(acc, [key, value]) => {
|
||||||
|
acc[value] = key;
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string>
|
||||||
|
);
|
||||||
@@ -2,15 +2,31 @@ import { maasProviderType } from '.';
|
|||||||
|
|
||||||
export interface MaasProviderItem {
|
export interface MaasProviderItem {
|
||||||
id: number;
|
id: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
deleted_at: string;
|
||||||
name: string;
|
name: string;
|
||||||
models?: number;
|
description: string;
|
||||||
state: string;
|
api_tokens: string[];
|
||||||
state_message: string;
|
timeout: number;
|
||||||
provider: maasProviderType;
|
config: {
|
||||||
proxy_config?: any;
|
type: maasProviderType;
|
||||||
builtIn: boolean;
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
support_models: unknown[];
|
||||||
|
proxy_url: string;
|
||||||
|
proxy_timeout: number;
|
||||||
|
builtin: boolean;
|
||||||
|
provider_model_count: number;
|
||||||
|
api_token_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
|
api_tokens: string[];
|
||||||
|
config: {
|
||||||
|
type: maasProviderType;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import SealInput from '@/components/seal-form/seal-input';
|
import SealInput from '@/components/seal-form/seal-input';
|
||||||
|
import SealSelect from '@/components/seal-form/seal-select';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
|
import { maasProviderOptions } from '../config/providers';
|
||||||
import { FormData } from '../config/types';
|
import { FormData } from '../config/types';
|
||||||
|
|
||||||
const Basic = () => {
|
const Basic = () => {
|
||||||
@@ -8,7 +10,7 @@ const Basic = () => {
|
|||||||
const form = Form.useFormInstance<FormData>();
|
const form = Form.useFormInstance<FormData>();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form.Item name="name" data-field="name">
|
<Form.Item<FormData> name="name" data-field="name">
|
||||||
<SealInput.Input
|
<SealInput.Input
|
||||||
required
|
required
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
@@ -16,14 +18,15 @@ const Basic = () => {
|
|||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="provider" hidden>
|
<Form.Item<FormData> name={['config', 'type']}>
|
||||||
<SealInput.Input
|
<SealSelect
|
||||||
|
options={maasProviderOptions}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'providers.table.providerName'
|
id: 'providers.table.providerName'
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="description">
|
<Form.Item<FormData> name="description">
|
||||||
<SealInput.TextArea
|
<SealInput.TextArea
|
||||||
scaleSize={true}
|
scaleSize={true}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
// columns.ts
|
// columns.ts
|
||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import IconFont from '@/components/icon-font';
|
|
||||||
import { SealColumnProps } from '@/components/seal-table/types';
|
import { SealColumnProps } from '@/components/seal-table/types';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
|
import { StatusMaps } from '@/config';
|
||||||
import { tableSorter } from '@/config/settings';
|
import { tableSorter } from '@/config/settings';
|
||||||
|
import { CheckCircleOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Tag } from 'antd';
|
import { Tag } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import {
|
import { maasProviderLabelMap, rowActionList } from '../config';
|
||||||
maasProviderLabelMap,
|
|
||||||
providerIconsMap,
|
|
||||||
ProviderStatus,
|
|
||||||
rowActionList
|
|
||||||
} from '../config';
|
|
||||||
import { MaasProviderItem } from '../config/types';
|
import { MaasProviderItem } from '../config/types';
|
||||||
|
|
||||||
const useProviderColumns = (
|
const useProviderColumns = (
|
||||||
@@ -35,7 +31,7 @@ const useProviderColumns = (
|
|||||||
<AutoTooltip ghost title={text}>
|
<AutoTooltip ghost title={text}>
|
||||||
{text}
|
{text}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
{record.builtIn && (
|
{record.builtin && (
|
||||||
<Tag color="blue" style={{ marginLeft: 8 }}>
|
<Tag color="blue" style={{ marginLeft: 8 }}>
|
||||||
BuiltIn
|
BuiltIn
|
||||||
</Tag>
|
</Tag>
|
||||||
@@ -50,10 +46,6 @@ const useProviderColumns = (
|
|||||||
span: 4,
|
span: 4,
|
||||||
render: (value: string) => (
|
render: (value: string) => (
|
||||||
<>
|
<>
|
||||||
<IconFont
|
|
||||||
type={providerIconsMap[value]}
|
|
||||||
style={{ marginRight: 8, fontSize: 16 }}
|
|
||||||
></IconFont>
|
|
||||||
<AutoTooltip ghost minWidth={20}>
|
<AutoTooltip ghost minWidth={20}>
|
||||||
{maasProviderLabelMap[value]}
|
{maasProviderLabelMap[value]}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
@@ -69,19 +61,30 @@ const useProviderColumns = (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'providers.table.proxy' }),
|
title: intl.formatMessage({ id: 'providers.table.proxy' }),
|
||||||
dataIndex: 'proxy_config',
|
dataIndex: 'proxy_url',
|
||||||
span: 3,
|
span: 3,
|
||||||
render: (value: number) => <span>{value ? 'Configured' : 'None'}</span>
|
render: (value: number) => (
|
||||||
|
<span>
|
||||||
|
{value ? (
|
||||||
|
<CheckCircleOutlined
|
||||||
|
style={{ color: 'var(--ant-color-success)' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Token Settings',
|
title: 'Token Settings',
|
||||||
dataIndex: 'tokens',
|
dataIndex: 'api_tokens',
|
||||||
span: 3,
|
span: 3,
|
||||||
render: (value: string, record: MaasProviderItem) => (
|
render: (value: string, record: MaasProviderItem) => (
|
||||||
<StatusTag
|
<StatusTag
|
||||||
statusValue={{
|
statusValue={{
|
||||||
status: ProviderStatus['ready'],
|
status:
|
||||||
text: 'Configured',
|
value?.length > 0 ? StatusMaps.success : StatusMaps.inactive,
|
||||||
|
text: value?.length > 0 ? 'Configured' : 'Unconfigured',
|
||||||
message: ''
|
message: ''
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ const MaasProvider: React.FC = () => {
|
|||||||
<>
|
<>
|
||||||
<PageBox>
|
<PageBox>
|
||||||
<FilterBar
|
<FilterBar
|
||||||
actionType="dropdown"
|
|
||||||
showSelect={false}
|
showSelect={false}
|
||||||
marginBottom={22}
|
marginBottom={22}
|
||||||
marginTop={30}
|
marginTop={30}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import DropdownButtons from '@/components/drop-down-buttons';
|
|||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import RowChildren from '@/components/seal-table/components/row-children';
|
import RowChildren from '@/components/seal-table/components/row-children';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { DeleteOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, StarFilled, StarOutlined } from '@ant-design/icons';
|
||||||
import { Col, Row } from 'antd';
|
import { Col, Row } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { mockAccessPointList } from '../config/mock';
|
||||||
|
|
||||||
const CellContent = styled.div`
|
const CellContent = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -35,9 +36,8 @@ export const childActionList = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'fallback',
|
key: 'fallback',
|
||||||
label: 'Fallback settings',
|
label: 'accesses.table.setAsFallback',
|
||||||
localel: false,
|
icon: <StarOutlined />
|
||||||
icon: <IconFont type="icon-captive_portal" />
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
@@ -61,6 +61,11 @@ const AccessItem: React.FC<AccessItemProps> = ({ onSelect, data }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AutoTooltip ghost>qwen3-0.6b-zduxy</AutoTooltip>
|
<AutoTooltip ghost>qwen3-0.6b-zduxy</AutoTooltip>
|
||||||
|
{data.is_fallback && (
|
||||||
|
<StarFilled
|
||||||
|
style={{ color: 'var(--ant-color-warning)', marginLeft: 8 }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</CellContent>
|
</CellContent>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={5}>
|
<Col span={5}>
|
||||||
@@ -106,11 +111,9 @@ const AccessPoints: React.FC<ProviderModelProps> = ({ dataList, onSelect }) => {
|
|||||||
console.log('AccessPoints dataList:', dataList);
|
console.log('AccessPoints dataList:', dataList);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{Array(2)
|
{mockAccessPointList.map((item, index) => (
|
||||||
.fill(1)
|
<AccessItem data={item} key={index} onSelect={onSelect}></AccessItem>
|
||||||
.map((item, index) => (
|
))}
|
||||||
<AccessItem data={item} key={index} onSelect={onSelect}></AccessItem>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AccessItem } from './types';
|
import { AccessItem, AccessPointItem } from './types';
|
||||||
|
|
||||||
// mock data for AccessItem 5 items
|
// mock data for AccessItem 5 items
|
||||||
export const mockDataList: AccessItem[] = [
|
export const mockDataList: AccessItem[] = [
|
||||||
@@ -33,3 +33,22 @@ export const mockDataList: AccessItem[] = [
|
|||||||
accessPoints: 4
|
accessPoints: 4
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// mock data for AccessPointItem 2 items
|
||||||
|
export const mockAccessPointList: AccessPointItem[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Access Point 1',
|
||||||
|
type: 'API',
|
||||||
|
is_fallback: true,
|
||||||
|
endpoint: 'https://api.example.com/endpoint1',
|
||||||
|
created_at: '2024-01-01T12:00:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Access Point 2',
|
||||||
|
type: 'SDK',
|
||||||
|
is_fallback: false,
|
||||||
|
created_at: '2024-02-01T12:00:00Z'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
export interface AccessItem {
|
export interface AccessItem {
|
||||||
id: number;
|
id: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
deleted_at: string;
|
||||||
name: string;
|
name: string;
|
||||||
source: string;
|
description: string;
|
||||||
accessPoints?: number;
|
categories: string[];
|
||||||
|
meta: Record<string, any>;
|
||||||
|
created_by_model: boolean;
|
||||||
|
endpoint_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
@@ -17,3 +23,18 @@ export interface FormData {
|
|||||||
provider_id: number;
|
provider_id: number;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AccessPointItem {
|
||||||
|
id: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
deleted_at: string;
|
||||||
|
provider_model_name: string;
|
||||||
|
weight: number;
|
||||||
|
model_id: number;
|
||||||
|
provider_id: number;
|
||||||
|
name: string;
|
||||||
|
access_id: number;
|
||||||
|
state: string;
|
||||||
|
fallback_status_codes: string[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
// columns.ts
|
// columns.ts
|
||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import IconFont from '@/components/icon-font';
|
|
||||||
import { SealColumnProps } from '@/components/seal-table/types';
|
import { SealColumnProps } from '@/components/seal-table/types';
|
||||||
import { tableSorter } from '@/config/settings';
|
import { tableSorter } from '@/config/settings';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Tag } from 'antd';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import {
|
import { maasProviderLabelMap, rowActionList } from '../config';
|
||||||
maasProviderLabelMap,
|
|
||||||
providerIconsMap,
|
|
||||||
rowActionList
|
|
||||||
} from '../config';
|
|
||||||
import { AccessItem } from '../config/types';
|
import { AccessItem } from '../config/types';
|
||||||
|
|
||||||
const useAccessColumns = (
|
const useAccessColumns = (
|
||||||
@@ -33,11 +27,6 @@ const useAccessColumns = (
|
|||||||
<AutoTooltip ghost title={text}>
|
<AutoTooltip ghost title={text}>
|
||||||
{text}
|
{text}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
{record.builtIn && (
|
|
||||||
<Tag color="blue" style={{ marginLeft: 8 }}>
|
|
||||||
BuiltIn
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -47,10 +36,6 @@ const useAccessColumns = (
|
|||||||
span: 5,
|
span: 5,
|
||||||
render: (value: string) => (
|
render: (value: string) => (
|
||||||
<>
|
<>
|
||||||
<IconFont
|
|
||||||
type={providerIconsMap[value]}
|
|
||||||
style={{ marginRight: 8, fontSize: 16 }}
|
|
||||||
></IconFont>
|
|
||||||
<AutoTooltip ghost minWidth={20}>
|
<AutoTooltip ghost minWidth={20}>
|
||||||
{maasProviderLabelMap[value]}
|
{maasProviderLabelMap[value]}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
|
|||||||
@@ -26,13 +26,11 @@ import {
|
|||||||
} from './apis';
|
} from './apis';
|
||||||
import AccessPoints from './components/access-points';
|
import AccessPoints from './components/access-points';
|
||||||
import AddAccessModal from './components/add-access-modal';
|
import AddAccessModal from './components/add-access-modal';
|
||||||
import FallbackModal from './components/fallback-modal';
|
|
||||||
import { maasProviderOptions } from './config';
|
import { maasProviderOptions } from './config';
|
||||||
import { mockDataList } from './config/mock';
|
import { mockDataList } from './config/mock';
|
||||||
import { FormData, AccessItem as ListItem } from './config/types';
|
import { FormData, AccessItem as ListItem } from './config/types';
|
||||||
import useAccessColumns from './hooks/use-access-columns';
|
import useAccessColumns from './hooks/use-access-columns';
|
||||||
import useCreateAccess from './hooks/use-create-access';
|
import useCreateAccess from './hooks/use-create-access';
|
||||||
import useFallbackSettings from './hooks/use-fallback-settings';
|
|
||||||
|
|
||||||
const Accesses: React.FC = () => {
|
const Accesses: React.FC = () => {
|
||||||
const {
|
const {
|
||||||
@@ -62,12 +60,6 @@ const Accesses: React.FC = () => {
|
|||||||
const { openAccessModalStatus, openAccessModal, closeAccessModal } =
|
const { openAccessModalStatus, openAccessModal, closeAccessModal } =
|
||||||
useCreateAccess();
|
useCreateAccess();
|
||||||
|
|
||||||
const {
|
|
||||||
openFallbackSettingsModalStatus,
|
|
||||||
openFallbackSettingsModal,
|
|
||||||
closeFallbackSettingsModal
|
|
||||||
} = useFallbackSettings();
|
|
||||||
|
|
||||||
const handleClickDropdown = () => {
|
const handleClickDropdown = () => {
|
||||||
openAccessModal(
|
openAccessModal(
|
||||||
PageAction.CREATE,
|
PageAction.CREATE,
|
||||||
@@ -147,7 +139,7 @@ const Accesses: React.FC = () => {
|
|||||||
|
|
||||||
const onChildSelect = useMemoizedFn((val: any, record: any) => {
|
const onChildSelect = useMemoizedFn((val: any, record: any) => {
|
||||||
if (val === 'fallback') {
|
if (val === 'fallback') {
|
||||||
openFallbackSettingsModal(PageAction.EDIT, 'Fallback Settings', record);
|
console.log('open fallback settings modal', record);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -247,12 +239,6 @@ const Accesses: React.FC = () => {
|
|||||||
onCancel={handleModalCancel}
|
onCancel={handleModalCancel}
|
||||||
onOk={handleModalOk}
|
onOk={handleModalOk}
|
||||||
></AddAccessModal>
|
></AddAccessModal>
|
||||||
<FallbackModal
|
|
||||||
title={openFallbackSettingsModalStatus.title}
|
|
||||||
open={openFallbackSettingsModalStatus.open}
|
|
||||||
onCancel={closeFallbackSettingsModal}
|
|
||||||
onOk={closeFallbackSettingsModal}
|
|
||||||
></FallbackModal>
|
|
||||||
<DeleteModal ref={modalRef}></DeleteModal>
|
<DeleteModal ref={modalRef}></DeleteModal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user