fix: add pool not work
This commit is contained in:
@@ -101,6 +101,11 @@ const SelectWrapper = styled.div`
|
|||||||
// top: 20px !important;
|
// top: 20px !important;
|
||||||
// inset-inline-start: ${INPUT_INNER_PADDING}px;
|
// inset-inline-start: ${INPUT_INNER_PADDING}px;
|
||||||
}
|
}
|
||||||
|
&.ant-select-auto-complete {
|
||||||
|
.ant-select-selection-search {
|
||||||
|
inset-inline-start: ${INPUT_INNER_PADDING}px;
|
||||||
|
}
|
||||||
|
}
|
||||||
&.ant-select-multiple.ant-cascader .ant-select-selection-search {
|
&.ant-select-multiple.ant-cascader .ant-select-selection-search {
|
||||||
top: 0 !important;
|
top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,10 @@ export default {
|
|||||||
'clusters.create.configBasic': 'Basic Configuration',
|
'clusters.create.configBasic': 'Basic Configuration',
|
||||||
'clusters.create.execCommand': 'Execute Command',
|
'clusters.create.execCommand': 'Execute Command',
|
||||||
'clusters.create.supportedGpu': 'Supported GPUs',
|
'clusters.create.supportedGpu': 'Supported GPUs',
|
||||||
'clusters.create.skipfornow': 'Skip for now'
|
'clusters.create.skipfornow': 'Skip for now',
|
||||||
|
'clusters.create.noImages': 'No images available',
|
||||||
|
'clusters.create.noInstanceTypes': 'No instance types available',
|
||||||
|
'clusters.create.noRegions': 'No regions available',
|
||||||
|
'clusters.workerpool.batchSize.desc':
|
||||||
|
'Number of workers created simultaneously in the Worker pool'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ export default {
|
|||||||
'clusters.create.configBasic': 'Basic Configuration',
|
'clusters.create.configBasic': 'Basic Configuration',
|
||||||
'clusters.create.execCommand': 'Execute Command',
|
'clusters.create.execCommand': 'Execute Command',
|
||||||
'clusters.create.supportedGpu': 'Supported GPUs',
|
'clusters.create.supportedGpu': 'Supported GPUs',
|
||||||
'clusters.create.skipfornow': 'Skip for now'
|
'clusters.create.skipfornow': 'Skip for now',
|
||||||
|
'clusters.create.noImages': 'No images available',
|
||||||
|
'clusters.create.noInstanceTypes': 'No instance types available',
|
||||||
|
'clusters.create.noRegions': 'No regions available',
|
||||||
|
'clusters.workerpool.batchSize.desc':
|
||||||
|
'Number of workers created simultaneously in the Worker pool'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -69,6 +74,10 @@ export default {
|
|||||||
// 31. 'clusters.create.configBasic': 'Basic Configuration',
|
// 31. 'clusters.create.configBasic': 'Basic Configuration',
|
||||||
// 32. 'clusters.create.execCommand': 'Execute Command',
|
// 32. 'clusters.create.execCommand': 'Execute Command',
|
||||||
// 33. 'clusters.create.supportedGpu': 'Supported GPUs',
|
// 33. 'clusters.create.supportedGpu': 'Supported GPUs',
|
||||||
// 34. 'clusters.create.skipfornow': 'Skip for now'
|
// 34. 'clusters.create.skipfornow': 'Skip for now',
|
||||||
|
// 35. 'clusters.create.noImages': 'No images available',
|
||||||
|
// 36. 'clusters.create.noInstanceTypes': 'No instance types available',
|
||||||
|
// 37. 'clusters.create.noRegions': 'No regions available',
|
||||||
|
// 38. 'clusters.workerpool.batchSize.desc': 'Number of workers created simultaneously in the Worker pool'
|
||||||
|
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ export default {
|
|||||||
'clusters.create.configBasic': 'Basic Configuration',
|
'clusters.create.configBasic': 'Basic Configuration',
|
||||||
'clusters.create.execCommand': 'Execute Command',
|
'clusters.create.execCommand': 'Execute Command',
|
||||||
'clusters.create.supportedGpu': 'Supported GPUs',
|
'clusters.create.supportedGpu': 'Supported GPUs',
|
||||||
'clusters.create.skipfornow': 'Skip for now'
|
'clusters.create.skipfornow': 'Skip for now',
|
||||||
|
'clusters.create.noImages': 'No images available',
|
||||||
|
'clusters.create.noInstanceTypes': 'No instance types available',
|
||||||
|
'clusters.create.noRegions': 'No regions available',
|
||||||
|
'clusters.workerpool.batchSize.desc':
|
||||||
|
'Number of workers created simultaneously in the Worker pool'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -69,6 +74,10 @@ export default {
|
|||||||
// 31. 'clusters.create.configBasic': 'Basic Configuration',
|
// 31. 'clusters.create.configBasic': 'Basic Configuration',
|
||||||
// 32. 'clusters.create.execCommand': 'Execute Command',
|
// 32. 'clusters.create.execCommand': 'Execute Command',
|
||||||
// 33. 'clusters.create.supportedGpu': 'Supported GPUs',
|
// 33. 'clusters.create.supportedGpu': 'Supported GPUs',
|
||||||
// 34. 'clusters.create.skipfornow': 'Skip for now'
|
// 34. 'clusters.create.skipfornow': 'Skip for now',
|
||||||
|
// 35. 'clusters.create.noImages': 'No images available',
|
||||||
|
// 36. 'clusters.create.noInstanceTypes': 'No instance types available',
|
||||||
|
// 37. 'clusters.create.noRegions': 'No regions available',
|
||||||
|
// 38. 'clusters.workerpool.batchSize.desc': 'Number of workers created simultaneously in the Worker pool'
|
||||||
|
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -32,5 +32,9 @@ export default {
|
|||||||
'clusters.create.configBasic': '基本配置',
|
'clusters.create.configBasic': '基本配置',
|
||||||
'clusters.create.execCommand': '执行命令',
|
'clusters.create.execCommand': '执行命令',
|
||||||
'clusters.create.supportedGpu': '支持的 GPU',
|
'clusters.create.supportedGpu': '支持的 GPU',
|
||||||
'clusters.create.skipfornow': '暂时跳过'
|
'clusters.create.skipfornow': '暂时跳过',
|
||||||
|
'clusters.create.noImages': '没有可用的镜像',
|
||||||
|
'clusters.create.noInstanceTypes': '没有可用的实例类型',
|
||||||
|
'clusters.create.noRegions': '没有可用的区域',
|
||||||
|
'clusters.workerpool.batchSize.desc': 'Worker池中同时创建的worker数量'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -244,7 +244,11 @@ const ClusterCreate = () => {
|
|||||||
return moduleKeys.map((key) => {
|
return moduleKeys.map((key) => {
|
||||||
const ModuleComponent = moduleRegistry[key];
|
const ModuleComponent = moduleRegistry[key];
|
||||||
return ModuleComponent ? (
|
return ModuleComponent ? (
|
||||||
<ModuleComponent key={key} registrationInfo={registrationInfo} />
|
<ModuleComponent
|
||||||
|
key={key}
|
||||||
|
registrationInfo={registrationInfo}
|
||||||
|
provider={extraData.provider}
|
||||||
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { useAtom } from 'jotai';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
CLUSTERS_API,
|
CLUSTERS_API,
|
||||||
createCluster,
|
|
||||||
createWorkerPool,
|
createWorkerPool,
|
||||||
deleteCluster,
|
deleteCluster,
|
||||||
queryClusterList,
|
queryClusterList,
|
||||||
@@ -31,7 +30,7 @@ import AddCluster from './components/add-cluster';
|
|||||||
import AddPool from './components/add-pool';
|
import AddPool from './components/add-pool';
|
||||||
import PoolRows from './components/pool-rows';
|
import PoolRows from './components/pool-rows';
|
||||||
import RegisterCluster from './components/register-cluster';
|
import RegisterCluster from './components/register-cluster';
|
||||||
import { ProviderLabelMap, ProviderType, ProviderValueMap } from './config';
|
import { ProviderType, ProviderValueMap } from './config';
|
||||||
import {
|
import {
|
||||||
ClusterListItem,
|
ClusterListItem,
|
||||||
ClusterFormData as FormData,
|
ClusterFormData as FormData,
|
||||||
@@ -50,7 +49,6 @@ const Credentials: React.FC = () => {
|
|||||||
handleDeleteBatch,
|
handleDeleteBatch,
|
||||||
fetchData,
|
fetchData,
|
||||||
handlePageChange,
|
handlePageChange,
|
||||||
handleTableChange,
|
|
||||||
handleSearch,
|
handleSearch,
|
||||||
handleNameChange
|
handleNameChange
|
||||||
} = useTableFetch<ListItem>({
|
} = useTableFetch<ListItem>({
|
||||||
@@ -129,40 +127,24 @@ const Credentials: React.FC = () => {
|
|||||||
title: string;
|
title: string;
|
||||||
provider: ProviderType;
|
provider: ProviderType;
|
||||||
clusterId: number;
|
clusterId: number;
|
||||||
|
clusterData: ClusterListItem | null;
|
||||||
}>({
|
}>({
|
||||||
open: false,
|
open: false,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: '',
|
title: '',
|
||||||
provider: ProviderValueMap.DigitalOcean as ProviderType,
|
provider: ProviderValueMap.DigitalOcean as ProviderType,
|
||||||
clusterId: 0
|
clusterId: 0,
|
||||||
|
clusterData: null
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleAddCluster = (value: string) => {
|
|
||||||
const label = ProviderLabelMap[value];
|
|
||||||
const clusterLabel =
|
|
||||||
value === ProviderValueMap.Custom
|
|
||||||
? intl.formatMessage({ id: 'clusters.provider.custom' })
|
|
||||||
: label;
|
|
||||||
|
|
||||||
setOpenAddModal({
|
|
||||||
open: true,
|
|
||||||
action: PageAction.CREATE,
|
|
||||||
currentData: undefined,
|
|
||||||
title: intl.formatMessage(
|
|
||||||
{ id: 'clusters.add.cluster' },
|
|
||||||
{ cluster: clusterLabel }
|
|
||||||
),
|
|
||||||
provider: value as ProviderType
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAddPool = (row: ListItem) => {
|
const handleAddPool = (row: ListItem) => {
|
||||||
setAddPoolStatus({
|
setAddPoolStatus({
|
||||||
open: true,
|
open: true,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: intl.formatMessage({ id: 'clusters.button.addNodePool' }),
|
title: intl.formatMessage({ id: 'clusters.button.addNodePool' }),
|
||||||
provider: row.provider as ProviderType,
|
provider: row.provider as ProviderType,
|
||||||
clusterId: row.id
|
clusterId: row.id,
|
||||||
|
clusterData: row
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -180,27 +162,11 @@ const Credentials: React.FC = () => {
|
|||||||
data: params,
|
data: params,
|
||||||
id: openAddModal.currentData!.id
|
id: openAddModal.currentData!.id
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
await createCluster({ data: params });
|
|
||||||
}
|
}
|
||||||
fetchData();
|
fetchData();
|
||||||
setOpenAddModal({
|
|
||||||
open: false,
|
|
||||||
action: PageAction.CREATE,
|
|
||||||
currentData: undefined,
|
|
||||||
title: '',
|
|
||||||
provider: null
|
|
||||||
});
|
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
setOpenAddModal({
|
|
||||||
open: false,
|
|
||||||
action: PageAction.CREATE,
|
|
||||||
currentData: undefined,
|
|
||||||
title: '',
|
|
||||||
provider: null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleModalCancel = () => {
|
const handleModalCancel = () => {
|
||||||
@@ -377,10 +343,7 @@ const Credentials: React.FC = () => {
|
|||||||
>
|
>
|
||||||
<SealTable
|
<SealTable
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
tableLayout="fixed"
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
loadChildren={getWorkerPoolList}
|
loadChildren={getWorkerPoolList}
|
||||||
onChange={handleTableChange}
|
|
||||||
expandedRowKeys={expandedRowKeys}
|
expandedRowKeys={expandedRowKeys}
|
||||||
onExpand={handleExpandChange}
|
onExpand={handleExpandChange}
|
||||||
onExpandAll={handleToggleExpandAll}
|
onExpandAll={handleToggleExpandAll}
|
||||||
@@ -444,13 +407,15 @@ const Credentials: React.FC = () => {
|
|||||||
open={addPoolStatus.open}
|
open={addPoolStatus.open}
|
||||||
action={addPoolStatus.action}
|
action={addPoolStatus.action}
|
||||||
title={addPoolStatus.title}
|
title={addPoolStatus.title}
|
||||||
|
clusterData={addPoolStatus.clusterData}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setAddPoolStatus({
|
setAddPoolStatus({
|
||||||
open: false,
|
open: false,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: '',
|
title: '',
|
||||||
provider: ProviderValueMap.DigitalOcean as ProviderType,
|
provider: ProviderValueMap.DigitalOcean as ProviderType,
|
||||||
clusterId: 0
|
clusterId: 0,
|
||||||
|
clusterData: null
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onOk={handleSubmitWorkerPool}
|
onOk={handleSubmitWorkerPool}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import useAppUtils from '@/hooks/use-app-utils';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { ProviderValueMap } from '../config';
|
import { ProviderType, ProviderValueMap } from '../config';
|
||||||
import {
|
import {
|
||||||
CredentialFormData as FormData,
|
CredentialFormData as FormData,
|
||||||
CredentialListItem as ListItem
|
CredentialListItem as ListItem
|
||||||
@@ -20,7 +20,7 @@ type AddModalProps = {
|
|||||||
onOk: (values: FormData) => void;
|
onOk: (values: FormData) => void;
|
||||||
currentData?: ListItem;
|
currentData?: ListItem;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
provider: string; // 'kubernetes' | 'digitalocean';
|
provider: ProviderType;
|
||||||
};
|
};
|
||||||
const AddModal: React.FC<AddModalProps> = ({
|
const AddModal: React.FC<AddModalProps> = ({
|
||||||
title,
|
title,
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import ModalFooter from '@/components/modal-footer';
|
import ModalFooter from '@/components/modal-footer';
|
||||||
import ScrollerModal from '@/components/scroller-modal';
|
import ScrollerModal from '@/components/scroller-modal';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
import React, { useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { ProviderType } from '../config';
|
import { ProviderType } from '../config';
|
||||||
import {
|
import {
|
||||||
|
ClusterListItem,
|
||||||
NodePoolFormData as FormData,
|
NodePoolFormData as FormData,
|
||||||
NodePoolListItem as ListItem
|
NodePoolListItem as ListItem
|
||||||
} from '../config/types';
|
} from '../config/types';
|
||||||
|
import { useProviderRegions } from '../hooks/use-provider-regions';
|
||||||
import PoolForm from './pool-form';
|
import PoolForm from './pool-form';
|
||||||
|
|
||||||
type AddModalProps = {
|
type AddModalProps = {
|
||||||
@@ -15,6 +17,7 @@ type AddModalProps = {
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
provider: ProviderType; // 'kubernetes' | 'custom' | 'digitalocean';
|
provider: ProviderType; // 'kubernetes' | 'custom' | 'digitalocean';
|
||||||
currentData?: ListItem | null;
|
currentData?: ListItem | null;
|
||||||
|
clusterData?: ClusterListItem | null;
|
||||||
onOk: (values: FormData) => void;
|
onOk: (values: FormData) => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
};
|
};
|
||||||
@@ -25,8 +28,11 @@ const AddPool: React.FC<AddModalProps> = ({
|
|||||||
provider,
|
provider,
|
||||||
onOk,
|
onOk,
|
||||||
currentData,
|
currentData,
|
||||||
|
clusterData,
|
||||||
onCancel
|
onCancel
|
||||||
}) => {
|
}) => {
|
||||||
|
const { getInstanceTypes, getOSImages, updateInstanceTypes, updateOSImages } =
|
||||||
|
useProviderRegions();
|
||||||
const formRef = useRef<any>(null);
|
const formRef = useRef<any>(null);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
@@ -42,6 +48,18 @@ const AddPool: React.FC<AddModalProps> = ({
|
|||||||
onCancel();
|
onCancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const init = async (clusterData: ClusterListItem) => {
|
||||||
|
const allTyps = await getInstanceTypes(clusterData.credential_id);
|
||||||
|
const allImages = await getOSImages(clusterData.credential_id);
|
||||||
|
updateInstanceTypes(clusterData.region, allTyps);
|
||||||
|
updateOSImages(clusterData.region, allImages);
|
||||||
|
};
|
||||||
|
if (open && clusterData && clusterData.credential_id) {
|
||||||
|
init(clusterData);
|
||||||
|
}
|
||||||
|
}, [clusterData, open]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollerModal
|
<ScrollerModal
|
||||||
title={title}
|
title={title}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import HighlightCode from '@/components/highlight-code';
|
||||||
|
import { addWorkerGuide } from '@/pages/resources/config';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
type ViewModalProps = {
|
||||||
|
registrationInfo: {
|
||||||
|
token: string;
|
||||||
|
image: string;
|
||||||
|
server_url: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const AddWorkerCommand: React.FC<ViewModalProps> = ({ registrationInfo }) => {
|
||||||
|
const code = React.useMemo(() => {
|
||||||
|
const commandCode = addWorkerGuide['cuda'];
|
||||||
|
return commandCode?.registerWorker({
|
||||||
|
server: registrationInfo.server_url || origin,
|
||||||
|
tag: '',
|
||||||
|
image: registrationInfo.image,
|
||||||
|
token: registrationInfo.token || '${token}',
|
||||||
|
workerip: '${workerip}'
|
||||||
|
});
|
||||||
|
}, [registrationInfo]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HighlightCode
|
||||||
|
theme="dark"
|
||||||
|
code={code.replace(/\\/g, '')}
|
||||||
|
copyValue={code}
|
||||||
|
lang="bash"
|
||||||
|
></HighlightCode>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddWorkerCommand;
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { ProviderType, ProviderValueMap } from '../config';
|
||||||
|
import AddWorkerCommand from './add-worker-command';
|
||||||
import RegisterClusterInner from './register-cluster-inner';
|
import RegisterClusterInner from './register-cluster-inner';
|
||||||
import SupportedHardware from './support-hardware';
|
import SupportedHardware from './support-hardware';
|
||||||
|
|
||||||
@@ -11,6 +13,7 @@ const Title = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
type AddModalProps = {
|
type AddModalProps = {
|
||||||
|
provider: ProviderType;
|
||||||
registrationInfo: {
|
registrationInfo: {
|
||||||
token: string;
|
token: string;
|
||||||
image: string;
|
image: string;
|
||||||
@@ -18,12 +21,19 @@ type AddModalProps = {
|
|||||||
cluster_id: number;
|
cluster_id: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const AddWorkerStep: React.FC<AddModalProps> = ({ registrationInfo }) => {
|
const AddWorkerStep: React.FC<AddModalProps> = ({
|
||||||
|
provider,
|
||||||
|
registrationInfo
|
||||||
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Title>{intl.formatMessage({ id: 'clusters.create.execCommand' })}</Title>
|
<Title>{intl.formatMessage({ id: 'clusters.create.execCommand' })}</Title>
|
||||||
<RegisterClusterInner registrationInfo={registrationInfo} />
|
{provider === ProviderValueMap.Kubernetes ? (
|
||||||
|
<RegisterClusterInner registrationInfo={registrationInfo} />
|
||||||
|
) : (
|
||||||
|
<AddWorkerCommand registrationInfo={registrationInfo} />
|
||||||
|
)}
|
||||||
<Title style={{ marginTop: 32 }}>
|
<Title style={{ marginTop: 32 }}>
|
||||||
{intl.formatMessage({ id: 'clusters.create.supportedGpu' })}
|
{intl.formatMessage({ id: 'clusters.create.supportedGpu' })}
|
||||||
</Title>
|
</Title>
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ interface CloudProviderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NotFoundContent: React.FC<{ loading: boolean }> = ({ loading }) => {
|
const NotFoundContent: React.FC<{ loading: boolean }> = ({ loading }) => {
|
||||||
|
const intl = useIntl();
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<NoContent>
|
<NoContent>
|
||||||
@@ -62,7 +63,11 @@ const NotFoundContent: React.FC<{ loading: boolean }> = ({ loading }) => {
|
|||||||
</NoContent>
|
</NoContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return <NoContent>No regions available</NoContent>;
|
return (
|
||||||
|
<NoContent>
|
||||||
|
{intl.formatMessage({ id: 'clusters.create.noRegions' })}
|
||||||
|
</NoContent>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const optionRender = (
|
const optionRender = (
|
||||||
@@ -159,6 +164,7 @@ const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
|
disabled={action === PageAction.EDIT}
|
||||||
label={intl.formatMessage({ id: 'clusters.credential.title' })}
|
label={intl.formatMessage({ id: 'clusters.credential.title' })}
|
||||||
required
|
required
|
||||||
options={credentialList}
|
options={credentialList}
|
||||||
@@ -176,6 +182,7 @@ const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
|||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
showSearch
|
showSearch
|
||||||
|
disabled={action === PageAction.EDIT}
|
||||||
label={intl.formatMessage({ id: 'clusters.workerpool.region' })}
|
label={intl.formatMessage({ id: 'clusters.workerpool.region' })}
|
||||||
required
|
required
|
||||||
options={regions}
|
options={regions}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import CollapsibleContainer, {
|
|||||||
} from '@/components/collapse-container';
|
} from '@/components/collapse-container';
|
||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import LabelSelector from '@/components/label-selector';
|
import LabelSelector from '@/components/label-selector';
|
||||||
|
import AutoComplete from '@/components/seal-form/auto-complete';
|
||||||
import SealInputNumber from '@/components/seal-form/input-number';
|
import SealInputNumber from '@/components/seal-form/input-number';
|
||||||
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 SealSelect from '@/components/seal-form/seal-select';
|
||||||
@@ -76,7 +77,21 @@ const DescriptionWrapper = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const NotFoundContent = () => {
|
const NotFoundContent = () => {
|
||||||
return <NoContent>No instance type available</NoContent>;
|
const intl = useIntl();
|
||||||
|
return (
|
||||||
|
<NoContent>
|
||||||
|
{intl.formatMessage({ id: 'clusters.create.noInstanceTypes' })}
|
||||||
|
</NoContent>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const NotFoundImageContent = () => {
|
||||||
|
const intl = useIntl();
|
||||||
|
return (
|
||||||
|
<NoContent>
|
||||||
|
{intl.formatMessage({ id: 'clusters.create.noImages' })}
|
||||||
|
</NoContent>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RenderInstanceOption = (option: any) => {
|
export const RenderInstanceOption = (option: any) => {
|
||||||
@@ -171,7 +186,8 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
}, [currentData]);
|
}, [currentData]);
|
||||||
|
|
||||||
const labelRender = (data: { label: string; value: string }) => {
|
const imageLabelRender = (data: { label: string; value: string }) => {
|
||||||
|
console.log('imageLabelRender========', data);
|
||||||
if (action === PageAction.EDIT) {
|
if (action === PageAction.EDIT) {
|
||||||
return currentData?.image_name || currentData?.os_image;
|
return currentData?.image_name || currentData?.os_image;
|
||||||
}
|
}
|
||||||
@@ -187,7 +203,8 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
const handleOsImageChange = (value: string) => {
|
const handleOsImageChange = (value: string) => {
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
image_name: osImageList.find((item) => item.value === value)?.label
|
image_name:
|
||||||
|
osImageList.find((item) => item.value === value)?.label || value
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -215,6 +232,14 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filterImageOption = (inputValue: string, option: any) => {
|
||||||
|
return (
|
||||||
|
option.label.toLowerCase().includes(inputValue.toLowerCase()) ||
|
||||||
|
option.value.toLowerCase().includes(inputValue.toLowerCase()) ||
|
||||||
|
option.description.toLowerCase().includes(inputValue.toLowerCase())
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
resetFields: () => {
|
resetFields: () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
@@ -337,6 +362,9 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInputNumber
|
<SealInputNumber
|
||||||
|
description={intl.formatMessage({
|
||||||
|
id: 'clusters.workerpool.batchSize.desc'
|
||||||
|
})}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'clusters.workerpool.batchSize'
|
id: 'clusters.workerpool.batchSize'
|
||||||
})}
|
})}
|
||||||
@@ -353,18 +381,20 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<AutoComplete
|
||||||
showSearch
|
showSearch
|
||||||
|
notFoundContent={<NotFoundImageContent />}
|
||||||
onChange={handleOsImageChange}
|
onChange={handleOsImageChange}
|
||||||
|
filterOption={filterImageOption}
|
||||||
optionRender={RenderInstanceOption}
|
optionRender={RenderInstanceOption}
|
||||||
labelRender={labelRender}
|
labelRender={imageLabelRender}
|
||||||
options={osImageList}
|
options={osImageList}
|
||||||
disabled={action === PageAction.EDIT}
|
disabled={action === PageAction.EDIT}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'clusters.workerpool.osImage'
|
id: 'clusters.workerpool.osImage'
|
||||||
})}
|
})}
|
||||||
required
|
required
|
||||||
></SealSelect>
|
></AutoComplete>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
updateCredential
|
updateCredential
|
||||||
} from './apis';
|
} from './apis';
|
||||||
import AddModal from './components/add-credential';
|
import AddModal from './components/add-credential';
|
||||||
import { ProviderLabelMap, ProviderValueMap } from './config';
|
import { ProviderLabelMap, ProviderType, ProviderValueMap } from './config';
|
||||||
import {
|
import {
|
||||||
CredentialFormData as FormData,
|
CredentialFormData as FormData,
|
||||||
CredentialListItem as ListItem
|
CredentialListItem as ListItem
|
||||||
@@ -55,13 +55,13 @@ const Credentials: React.FC = () => {
|
|||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [openModalStatus, setOpenModalStatus] = useState<{
|
const [openModalStatus, setOpenModalStatus] = useState<{
|
||||||
provider: string;
|
provider: ProviderType;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
action: PageActionType;
|
action: PageActionType;
|
||||||
title: string;
|
title: string;
|
||||||
currentData: ListItem | undefined;
|
currentData: ListItem | undefined;
|
||||||
}>({
|
}>({
|
||||||
provider: '',
|
provider: null,
|
||||||
open: false,
|
open: false,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: '',
|
title: '',
|
||||||
@@ -70,7 +70,7 @@ const Credentials: React.FC = () => {
|
|||||||
|
|
||||||
const handleAddCredential = (item: { key: string; label: string }) => {
|
const handleAddCredential = (item: { key: string; label: string }) => {
|
||||||
setOpenModalStatus({
|
setOpenModalStatus({
|
||||||
provider: item.key,
|
provider: item.key as ProviderType,
|
||||||
open: true,
|
open: true,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: intl.formatMessage(
|
title: intl.formatMessage(
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// 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 { SealColumnProps } from '@/components/seal-table/types';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { Link, useIntl } from '@umijs/max';
|
import { Link, useIntl } from '@umijs/max';
|
||||||
import { ColumnsType } from 'antd/es/table';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +25,7 @@ const setActionsItems = (row: ClusterListItem) => {
|
|||||||
|
|
||||||
const useClusterColumns = (
|
const useClusterColumns = (
|
||||||
handleSelect: (val: string, record: ClusterListItem) => void
|
handleSelect: (val: string, record: ClusterListItem) => void
|
||||||
): ColumnsType<ClusterListItem & { dataIndex: string; span: number }> => {
|
): SealColumnProps[] => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export const useProviderRegions = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
setAllInstanceTypes(list);
|
setAllInstanceTypes(list);
|
||||||
|
return list;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setAllInstanceTypes([]);
|
setAllInstanceTypes([]);
|
||||||
}
|
}
|
||||||
@@ -155,18 +156,21 @@ export const useProviderRegions = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
setAllOSImageList(list);
|
setAllOSImageList(list);
|
||||||
|
return list;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateInstanceTypes = (region: string) => {
|
const updateInstanceTypes = (region: string, allTypes?: any[]) => {
|
||||||
const sizes = allInstanceTypes.filter((item) =>
|
const sizes = (allTypes || allInstanceTypes).filter((item) =>
|
||||||
item.regions.includes(region)
|
item.regions.includes(region)
|
||||||
);
|
);
|
||||||
setInstanceTypes(sizes);
|
setInstanceTypes(sizes);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateOSImages = (region: string) => {
|
const updateOSImages = (region: string, allImages?: any[]) => {
|
||||||
const list = allOSImageList.filter((item) => item.regions.includes(region));
|
const list = (allImages || allOSImageList).filter((item) =>
|
||||||
|
item.regions.includes(region)
|
||||||
|
);
|
||||||
setOSImageList(list);
|
setOSImageList(list);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
|
|
||||||
const gatherFormValues = (results: PromiseSettledResult<any>[]) => {
|
const gatherFormValues = (results: PromiseSettledResult<any>[]) => {
|
||||||
const resultList = results.map((result: PromiseSettledResult<any>) => {
|
const resultList = results.map((result: PromiseSettledResult<any>) => {
|
||||||
console.log('gatherFormValues========', results);
|
|
||||||
if (result.status === 'fulfilled') {
|
if (result.status === 'fulfilled') {
|
||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
@@ -109,8 +108,8 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
console.log('gatherFormValues========', resultList);
|
||||||
return resultList;
|
return resultList.filter((item) => item);
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateFields = async () => {
|
const validateFields = async () => {
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ export const WorkerStatusMapValue = {
|
|||||||
[WorkerStatusMap.unreachable]: 'Unreachable',
|
[WorkerStatusMap.unreachable]: 'Unreachable',
|
||||||
[WorkerStatusMap.provisioning]: 'Provisioning',
|
[WorkerStatusMap.provisioning]: 'Provisioning',
|
||||||
[WorkerStatusMap.deleting]: 'Deleting',
|
[WorkerStatusMap.deleting]: 'Deleting',
|
||||||
[WorkerStatusMap.error]: 'Error'
|
[WorkerStatusMap.error]: 'Error',
|
||||||
|
[WorkerStatusMap.provisioned]: 'Provisioned',
|
||||||
|
[WorkerStatusMap.pending]: 'Pending'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const status: any = {
|
export const status: any = {
|
||||||
|
|||||||
Reference in New Issue
Block a user