fix: cluster apis
This commit is contained in:
+12
-2
@@ -155,17 +155,27 @@ export default [
|
|||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/cluster-management',
|
path: '/cluster-management',
|
||||||
redirect: '/cluster-management/clusters'
|
redirect: '/cluster-management/clusters/list'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'clusters',
|
name: 'clusters',
|
||||||
path: '/cluster-management/clusters',
|
path: '/cluster-management/clusters/list',
|
||||||
key: 'clusters',
|
key: 'clusters',
|
||||||
icon: 'icon-cluster2-outline',
|
icon: 'icon-cluster2-outline',
|
||||||
selectedIcon: 'icon-cluster2-filled',
|
selectedIcon: 'icon-cluster2-filled',
|
||||||
defaultIcon: 'icon-cluster2-outline',
|
defaultIcon: 'icon-cluster2-outline',
|
||||||
component: './cluster-management/clusters'
|
component: './cluster-management/clusters'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'clusterDetail',
|
||||||
|
path: '/cluster-management/cluster/detail',
|
||||||
|
key: 'clusterDetail',
|
||||||
|
icon: 'icon-cluster2-outline',
|
||||||
|
selectedIcon: 'icon-cluster2-filled',
|
||||||
|
defaultIcon: 'icon-cluster2-outline',
|
||||||
|
hideInMenu: true,
|
||||||
|
component: './cluster-management/cluster-detail'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'credentials',
|
name: 'credentials',
|
||||||
path: '/cluster-management/credentials',
|
path: '/cluster-management/credentials',
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
title,
|
title,
|
||||||
legendOptions,
|
legendOptions,
|
||||||
gridOptions,
|
gridOptions,
|
||||||
titleOptions
|
titleOptions,
|
||||||
|
showArea
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
grid,
|
grid,
|
||||||
@@ -100,19 +101,21 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
lineStyle: {
|
lineStyle: {
|
||||||
...lineItemConfig.lineStyle,
|
...lineItemConfig.lineStyle,
|
||||||
color: item.color
|
color: item.color
|
||||||
|
},
|
||||||
|
areaStyle: showArea
|
||||||
|
? {
|
||||||
|
color: new LinearGradient(0, 0, 0, 1, [
|
||||||
|
{
|
||||||
|
offset: 0,
|
||||||
|
color: colors[0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
offset: 1,
|
||||||
|
color: colors[1]
|
||||||
}
|
}
|
||||||
// areaStyle: {
|
])
|
||||||
// color: new LinearGradient(0, 0, 0, 1, [
|
}
|
||||||
// {
|
: null
|
||||||
// offset: 0,
|
|
||||||
// color: colors[0]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// offset: 1,
|
|
||||||
// color: colors[1]
|
|
||||||
// }
|
|
||||||
// ])
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
export interface ChartProps {
|
export interface ChartProps {
|
||||||
seriesData: any[];
|
seriesData: any[];
|
||||||
showEmpty?: boolean;
|
showEmpty?: boolean;
|
||||||
|
showArea?: boolean;
|
||||||
xAxisData: string[];
|
xAxisData: string[];
|
||||||
legendData?: LegendComponentOption['data'];
|
legendData?: LegendComponentOption['data'];
|
||||||
legendOptions?: {
|
legendOptions?: {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
gap: 5px;
|
||||||
|
|
||||||
&.err {
|
&.err {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ type StatusTagProps = {
|
|||||||
download?: {
|
download?: {
|
||||||
percent: number;
|
percent: number;
|
||||||
};
|
};
|
||||||
|
suffix?: React.ReactNode;
|
||||||
maxTooltipWidth?: number;
|
maxTooltipWidth?: number;
|
||||||
extra?: React.ReactNode;
|
extra?: React.ReactNode;
|
||||||
actions?: {
|
actions?: {
|
||||||
@@ -46,7 +47,7 @@ const StatusTag: React.FC<StatusTagProps> = ({
|
|||||||
extra,
|
extra,
|
||||||
actions = [],
|
actions = [],
|
||||||
maxTooltipWidth = 250,
|
maxTooltipWidth = 250,
|
||||||
type = 'tag'
|
suffix
|
||||||
}) => {
|
}) => {
|
||||||
const { text, status } = statusValue;
|
const { text, status } = statusValue;
|
||||||
|
|
||||||
@@ -140,6 +141,7 @@ const StatusTag: React.FC<StatusTagProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}, [statusValue]);
|
}, [statusValue]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={classNames('status-tag', {
|
className={classNames('status-tag', {
|
||||||
@@ -161,14 +163,16 @@ const StatusTag: React.FC<StatusTagProps> = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="txt err">
|
<span className="txt err">
|
||||||
<span className="m-r-5">
|
|
||||||
<InfoCircleOutlined />
|
<InfoCircleOutlined />
|
||||||
</span>
|
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
|
{suffix && <span>{suffix}</span>}
|
||||||
</span>
|
</span>
|
||||||
</TooltipOverlayScroller>
|
</TooltipOverlayScroller>
|
||||||
) : (
|
) : (
|
||||||
<span className="txt">{renderContent()}</span>
|
<span className="txt">
|
||||||
|
{renderContent()}
|
||||||
|
{suffix && <span>{suffix}</span>}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,18 @@ export default {
|
|||||||
'clusters.edit.cluster': 'Edit {cluster}',
|
'clusters.edit.cluster': 'Edit {cluster}',
|
||||||
'clusters.provider.custom': 'Custom',
|
'clusters.provider.custom': 'Custom',
|
||||||
'clusters.button.register': 'Register Cluster',
|
'clusters.button.register': 'Register Cluster',
|
||||||
'clusters.button.addNodePool': 'Add Node Pool',
|
'clusters.button.addNodePool': 'Add Worker Pool',
|
||||||
'clusters.button.add.credential': 'Add {provider} Credential'
|
'clusters.button.add.credential': 'Add {provider} Credential',
|
||||||
|
'clusters.credential.title': 'Credential',
|
||||||
|
'clusters.credential.token': 'Access Token',
|
||||||
|
'clusters.workerpool.region': 'Region',
|
||||||
|
'clusters.workerpool.zone': 'Zone',
|
||||||
|
'clusters.workerpool.instanceType': 'Instance Type',
|
||||||
|
'clusters.workerpool.replicas': 'Replicas',
|
||||||
|
'clusters.workerpool.batchSize': 'Batch Size',
|
||||||
|
'clusters.workerpool.osImage': 'OS Image',
|
||||||
|
'clusters.workerpool.volumes': 'Volumes',
|
||||||
|
'clusters.workerpool.format': 'Format',
|
||||||
|
'clusters.workerpool.size': 'Size (GiB)',
|
||||||
|
'clusters.workerpool.title': 'Worker Pools'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -92,5 +92,6 @@ export default {
|
|||||||
'Download and install the <a href={url} target="_blank">installer</a>. Only supported: {versions}.',
|
'Download and install the <a href={url} target="_blank">installer</a>. Only supported: {versions}.',
|
||||||
'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
||||||
'resource.register.windows.support': 'win 10, win 11',
|
'resource.register.windows.support': 'win 10, win 11',
|
||||||
'resources.model.instance': 'Model Instance'
|
'resources.model.instance': 'Model Instance',
|
||||||
|
'resources.worker.download.privatekey': 'Download Private Key'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,8 +10,20 @@ export default {
|
|||||||
'clusters.edit.cluster': 'Edit {cluster}',
|
'clusters.edit.cluster': 'Edit {cluster}',
|
||||||
'clusters.provider.custom': 'Custom',
|
'clusters.provider.custom': 'Custom',
|
||||||
'clusters.button.register': 'Register Cluster',
|
'clusters.button.register': 'Register Cluster',
|
||||||
'clusters.button.addNodePool': 'Add Node Pool',
|
'clusters.button.addNodePool': 'Add Worker Pool',
|
||||||
'clusters.button.add.credential': 'Add {provider} Credential'
|
'clusters.button.add.credential': 'Add {provider} Credential',
|
||||||
|
'clusters.credential.title': 'Credential',
|
||||||
|
'clusters.credential.token': 'Access Token',
|
||||||
|
'clusters.workerpool.region': 'Region',
|
||||||
|
'clusters.workerpool.zone': 'Zone',
|
||||||
|
'clusters.workerpool.instanceType': 'Instance Type',
|
||||||
|
'clusters.workerpool.replicas': 'Replicas',
|
||||||
|
'clusters.workerpool.batchSize': 'Batch Size',
|
||||||
|
'clusters.workerpool.osImage': 'OS Image',
|
||||||
|
'clusters.workerpool.volumes': 'Volumes',
|
||||||
|
'clusters.workerpool.format': 'Format',
|
||||||
|
'clusters.workerpool.size': 'Size (GiB)',
|
||||||
|
'clusters.workerpool.title': 'Worker Pools'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -26,6 +38,18 @@ export default {
|
|||||||
// 9. 'clusters.edit.cluster': 'Edit {cluster}',
|
// 9. 'clusters.edit.cluster': 'Edit {cluster}',
|
||||||
// 10. 'clusters.provider.custom': 'Custom',
|
// 10. 'clusters.provider.custom': 'Custom',
|
||||||
// 11. 'clusters.button.register': 'Register Cluster',
|
// 11. 'clusters.button.register': 'Register Cluster',
|
||||||
// 12. 'clusters.button.addNodePool': 'Add Node Pool',
|
// 12. 'clusters.button.addNodePool': 'Add Worker Pool',
|
||||||
// 13. 'clusters.button.add.credential': 'Add {provider} Credential'
|
// 13. 'clusters.button.add.credential': 'Add {provider} Credential',
|
||||||
|
// 14. 'clusters.credential.token': 'Access Token',
|
||||||
|
// 15. 'clusters.workerpool.region': 'Region',
|
||||||
|
// 16. 'clusters.workerpool.zone': 'Zone',
|
||||||
|
// 17. 'clusters.workerpool.instanceType': 'Instance Type',
|
||||||
|
// 18. 'clusters.workerpool.replicas': 'Replicas',
|
||||||
|
// 19. 'clusters.workerpool.batchSize': 'Batch Size',
|
||||||
|
// 20. 'clusters.workerpool.osImage': 'OS Image',
|
||||||
|
// 21. 'clusters.workerpool.volumes': 'Volumes',
|
||||||
|
// 22. 'clusters.workerpool.format': 'Format',
|
||||||
|
// 23. 'clusters.workerpool.size': 'Size (GiB)',
|
||||||
|
// 24. 'clusters.credential.title': 'Credential',
|
||||||
|
// 25. 'clusters.workerpool.title': 'Worker Pools'
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ export default {
|
|||||||
'Download and install the <a href={url} target="_blank">installer</a>. Only supported: {versions}.',
|
'Download and install the <a href={url} target="_blank">installer</a>. Only supported: {versions}.',
|
||||||
'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
||||||
'resource.register.windows.support': 'win 10, win 11',
|
'resource.register.windows.support': 'win 10, win 11',
|
||||||
'resources.model.instance': 'Model Instance'
|
'resources.model.instance': 'Model Instance',
|
||||||
|
'resources.worker.download.privatekey': 'Download Private Key'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -109,5 +110,6 @@ export default {
|
|||||||
// 10. 'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
// 10. 'resource.register.maos.support': 'Apple Silicon (M series), macOS 14+',
|
||||||
// 11. 'resource.register.windows.support': 'win 10, win 11',
|
// 11. 'resource.register.windows.support': 'win 10, win 11',
|
||||||
// 12. 'resources.filter.status': 'Filter by Status',
|
// 12. 'resources.filter.status': 'Filter by Status',
|
||||||
// 13. 'resources.model.instance': 'Model Instance'
|
// 13. 'resources.model.instance': 'Model Instance',
|
||||||
|
// 14. 'resources.worker.download.privatekey': 'Download Private Key'
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -10,8 +10,20 @@ export default {
|
|||||||
'clusters.edit.cluster': 'Edit {cluster}',
|
'clusters.edit.cluster': 'Edit {cluster}',
|
||||||
'clusters.provider.custom': 'Custom',
|
'clusters.provider.custom': 'Custom',
|
||||||
'clusters.button.register': 'Register Cluster',
|
'clusters.button.register': 'Register Cluster',
|
||||||
'clusters.button.addNodePool': 'Add Node Pool',
|
'clusters.button.addNodePool': 'Add Worker Pool',
|
||||||
'clusters.button.add.credential': 'Add {provider} Credential'
|
'clusters.button.add.credential': 'Add {provider} Credential',
|
||||||
|
'clusters.credential.title': 'Credential',
|
||||||
|
'clusters.credential.token': 'Access Token',
|
||||||
|
'clusters.workerpool.region': 'Region',
|
||||||
|
'clusters.workerpool.zone': 'Zone',
|
||||||
|
'clusters.workerpool.instanceType': 'Instance Type',
|
||||||
|
'clusters.workerpool.replicas': 'Replicas',
|
||||||
|
'clusters.workerpool.batchSize': 'Batch Size',
|
||||||
|
'clusters.workerpool.osImage': 'OS Image',
|
||||||
|
'clusters.workerpool.volumes': 'Volumes',
|
||||||
|
'clusters.workerpool.format': 'Format',
|
||||||
|
'clusters.workerpool.size': 'Size (GiB)',
|
||||||
|
'clusters.workerpool.title': 'Worker Pools'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -26,6 +38,18 @@ export default {
|
|||||||
// 9. 'clusters.edit.cluster': 'Edit {cluster}',
|
// 9. 'clusters.edit.cluster': 'Edit {cluster}',
|
||||||
// 10. 'clusters.provider.custom': 'Custom',
|
// 10. 'clusters.provider.custom': 'Custom',
|
||||||
// 11. 'clusters.button.register': 'Register Cluster',
|
// 11. 'clusters.button.register': 'Register Cluster',
|
||||||
// 12. 'clusters.button.addNodePool': 'Add Node Pool',
|
// 12. 'clusters.button.addNodePool': 'Add Worker Pool',
|
||||||
// 13. 'clusters.button.add.credential': 'Add {provider} Credential'
|
// 13. 'clusters.button.add.credential': 'Add {provider} Credential'
|
||||||
|
// 14. 'clusters.credential.title': 'Credential',
|
||||||
|
// 15. 'clusters.credential.token': 'Access Token',
|
||||||
|
// 16. 'clusters.workerpool.region': 'Region',
|
||||||
|
// 17. 'clusters.workerpool.zone': 'Zone',
|
||||||
|
// 18. 'clusters.workerpool.instanceType': 'Instance Type',
|
||||||
|
// 19. 'clusters.workerpool.replicas': 'Replicas',
|
||||||
|
// 20. 'clusters.workerpool.batchSize': 'Batch Size',
|
||||||
|
// 21. 'clusters.workerpool.osImage': 'OS Image',
|
||||||
|
// 22. 'clusters.workerpool.volumes': 'Volumes',
|
||||||
|
// 23. 'clusters.workerpool.format': 'Format',
|
||||||
|
// 24. 'clusters.workerpool.size': 'Size (GiB)',
|
||||||
|
// 25. 'clusters.workerpool.title': 'Worker Pools'
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ export default {
|
|||||||
'Скачайте и установите <a href={url} target="_blank">инсталлятор</a>. Поддерживаемые версии: {versions}.',
|
'Скачайте и установите <a href={url} target="_blank">инсталлятор</a>. Поддерживаемые версии: {versions}.',
|
||||||
'resource.register.maos.support': 'Apple Silicon (серия M), macOS 14+',
|
'resource.register.maos.support': 'Apple Silicon (серия M), macOS 14+',
|
||||||
'resource.register.windows.support': 'Windows 10, Windows 11',
|
'resource.register.windows.support': 'Windows 10, Windows 11',
|
||||||
'resources.model.instance': 'Модель экземпляра'
|
'resources.model.instance': 'Модель экземпляра',
|
||||||
|
'resources.worker.download.privatekey': 'Скачать приватный ключ'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
|
|||||||
@@ -11,5 +11,17 @@ export default {
|
|||||||
'clusters.provider.custom': '自定义',
|
'clusters.provider.custom': '自定义',
|
||||||
'clusters.button.register': '注册集群',
|
'clusters.button.register': '注册集群',
|
||||||
'clusters.button.addNodePool': '添加节点池',
|
'clusters.button.addNodePool': '添加节点池',
|
||||||
'clusters.button.add.credential': '添加 {provider} 凭证'
|
'clusters.button.add.credential': '添加 {provider} 凭证',
|
||||||
|
'clusters.credential.title': '凭证',
|
||||||
|
'clusters.credential.token': '访问令牌',
|
||||||
|
'clusters.workerpool.region': '区域',
|
||||||
|
'clusters.workerpool.zone': '可用区',
|
||||||
|
'clusters.workerpool.instanceType': '实例类型',
|
||||||
|
'clusters.workerpool.replicas': '副本数',
|
||||||
|
'clusters.workerpool.batchSize': '批大小',
|
||||||
|
'clusters.workerpool.osImage': '操作系统镜像',
|
||||||
|
'clusters.workerpool.volumes': '存储卷',
|
||||||
|
'clusters.workerpool.format': '文件系统格式',
|
||||||
|
'clusters.workerpool.size': '容量(GiB)',
|
||||||
|
'clusters.workerpool.title': '节点池'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -90,5 +90,6 @@ export default {
|
|||||||
'下载并安装<a href={url} target="_blank">安装包</a>,仅支持 {versions}。',
|
'下载并安装<a href={url} target="_blank">安装包</a>,仅支持 {versions}。',
|
||||||
'resource.register.maos.support': 'M 芯片,macOS 14+',
|
'resource.register.maos.support': 'M 芯片,macOS 14+',
|
||||||
'resource.register.windows.support': 'win 10, win 11',
|
'resource.register.windows.support': 'win 10, win 11',
|
||||||
'resources.model.instance': '模型实例'
|
'resources.model.instance': '模型实例',
|
||||||
|
'resources.worker.download.privatekey': '下载私钥'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ export async function deleteCluster(id: number) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function queryClusterDetail(params: { cluster_id: number }) {
|
export async function queryClusterDetail(params: {
|
||||||
|
cluster_id: number | string;
|
||||||
|
}) {
|
||||||
return request(`${DASHBOARD_API}`, {
|
return request(`${DASHBOARD_API}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params
|
params
|
||||||
@@ -113,7 +115,7 @@ export async function queryWorkerPools(
|
|||||||
|
|
||||||
export async function createWorkerPool(params: {
|
export async function createWorkerPool(params: {
|
||||||
data: NodePoolFormData;
|
data: NodePoolFormData;
|
||||||
clusterId: number;
|
clusterId: number | string;
|
||||||
}) {
|
}) {
|
||||||
return request(`${CLUSTERS_API}/${params.clusterId}${WORKER_POOLS_API}`, {
|
return request(`${CLUSTERS_API}/${params.clusterId}${WORKER_POOLS_API}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
|
import { useSearchParams } from '@umijs/max';
|
||||||
|
import ClusterMetrics from './components/cluster-metrics';
|
||||||
|
import WorkerPools from './components/worker-pools';
|
||||||
|
import { ProviderValueMap } from './config';
|
||||||
|
|
||||||
|
const ClusterDetailModal = () => {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const provider = searchParams.get('provider');
|
||||||
|
const clusterName = searchParams.get('name');
|
||||||
|
return (
|
||||||
|
<PageContainer
|
||||||
|
ghost
|
||||||
|
header={{
|
||||||
|
title: (
|
||||||
|
<span className="flex-center">
|
||||||
|
<span>{clusterName}</span>
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
style: {
|
||||||
|
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
||||||
|
},
|
||||||
|
breadcrumb: {}
|
||||||
|
}}
|
||||||
|
extra={[]}
|
||||||
|
>
|
||||||
|
<ClusterMetrics />
|
||||||
|
{provider === ProviderValueMap.DigitalOcean && <WorkerPools />}
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ClusterDetailModal;
|
||||||
@@ -5,7 +5,7 @@ import type { PageActionType } from '@/config/types';
|
|||||||
import useTableFetch from '@/hooks/use-table-fetch';
|
import useTableFetch from '@/hooks/use-table-fetch';
|
||||||
import AddWorker from '@/pages/resources/components/add-worker';
|
import AddWorker from '@/pages/resources/components/add-worker';
|
||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl, useNavigate, useSearchParams } from '@umijs/max';
|
||||||
import { useMemoizedFn } from 'ahooks';
|
import { useMemoizedFn } from 'ahooks';
|
||||||
import { Table, message } from 'antd';
|
import { Table, message } from 'antd';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
} from './apis';
|
} from './apis';
|
||||||
import AddCluster from './components/add-cluster';
|
import AddCluster from './components/add-cluster';
|
||||||
import AddPool from './components/add-pool';
|
import AddPool from './components/add-pool';
|
||||||
import ClusterDetailModal from './components/cluster-detail-modal';
|
|
||||||
import RegisterCluster from './components/register-cluster';
|
import RegisterCluster from './components/register-cluster';
|
||||||
import { ProviderLabelMap, ProviderValueMap, addActions } from './config';
|
import { ProviderLabelMap, ProviderValueMap, addActions } from './config';
|
||||||
import {
|
import {
|
||||||
@@ -49,6 +48,8 @@ const Credentials: React.FC = () => {
|
|||||||
contentForDelete: 'menu.clusterManagement.clusters'
|
contentForDelete: 'menu.clusterManagement.clusters'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [registerClusterStatus, setRegisterClusterStatus] = useState<{
|
const [registerClusterStatus, setRegisterClusterStatus] = useState<{
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -67,13 +68,7 @@ const Credentials: React.FC = () => {
|
|||||||
cluster_id: 0
|
cluster_id: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const [openClusterDetail, setOpenClusterDetail] = useState<{
|
|
||||||
open: boolean;
|
|
||||||
currentData: ListItem | null;
|
|
||||||
}>({
|
|
||||||
open: false,
|
|
||||||
currentData: {} as ListItem
|
|
||||||
});
|
|
||||||
const [openAddWorker, setOpenAddWorker] = useState<{
|
const [openAddWorker, setOpenAddWorker] = useState<{
|
||||||
open: boolean;
|
open: boolean;
|
||||||
registrationInfo: {
|
registrationInfo: {
|
||||||
@@ -144,7 +139,7 @@ const Credentials: React.FC = () => {
|
|||||||
setAddPoolStatus({
|
setAddPoolStatus({
|
||||||
open: true,
|
open: true,
|
||||||
action: PageAction.CREATE,
|
action: PageAction.CREATE,
|
||||||
title: `Add Node Pool`,
|
title: intl.formatMessage({ id: 'clusters.button.addNodePool' }),
|
||||||
provider: row.provider,
|
provider: row.provider,
|
||||||
clusterId: row.id
|
clusterId: row.id
|
||||||
});
|
});
|
||||||
@@ -245,11 +240,6 @@ const Credentials: React.FC = () => {
|
|||||||
handleAddWorker(row);
|
handleAddWorker(row);
|
||||||
} else if (val === 'addPool') {
|
} else if (val === 'addPool') {
|
||||||
handleAddPool(row);
|
handleAddPool(row);
|
||||||
} else if (val === 'details') {
|
|
||||||
setOpenClusterDetail({
|
|
||||||
open: true,
|
|
||||||
currentData: row
|
|
||||||
});
|
|
||||||
} else if (val === 'register_cluster') {
|
} else if (val === 'register_cluster') {
|
||||||
handleRegisterCluster(row);
|
handleRegisterCluster(row);
|
||||||
}
|
}
|
||||||
@@ -355,13 +345,6 @@ const Credentials: React.FC = () => {
|
|||||||
}
|
}
|
||||||
registrationInfo={openAddWorker.registrationInfo}
|
registrationInfo={openAddWorker.registrationInfo}
|
||||||
></AddWorker>
|
></AddWorker>
|
||||||
<ClusterDetailModal
|
|
||||||
open={openClusterDetail.open}
|
|
||||||
currentData={openClusterDetail.currentData}
|
|
||||||
onClose={() =>
|
|
||||||
setOpenClusterDetail({ open: false, currentData: {} as ListItem })
|
|
||||||
}
|
|
||||||
></ClusterDetailModal>
|
|
||||||
<RegisterCluster
|
<RegisterCluster
|
||||||
title={intl.formatMessage({ id: 'clusters.button.register' })}
|
title={intl.formatMessage({ id: 'clusters.button.register' })}
|
||||||
open={registerClusterStatus.open}
|
open={registerClusterStatus.open}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ScrollerModal from '@/components/scroller-modal';
|
|||||||
import SealInput from '@/components/seal-form/seal-input';
|
import SealInput from '@/components/seal-form/seal-input';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
|
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';
|
||||||
@@ -32,6 +33,7 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const { getRuleMessage } = useAppUtils();
|
||||||
|
|
||||||
const handleSumit = () => {
|
const handleSumit = () => {
|
||||||
form.submit();
|
form.submit();
|
||||||
@@ -93,12 +95,12 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: action === PageAction.CREATE,
|
required: action === PageAction.CREATE,
|
||||||
message: 'Access Token is required'
|
message: getRuleMessage('input', 'clusters.credential.token')
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInput.Password
|
<SealInput.Password
|
||||||
label="Access Token"
|
label={intl.formatMessage({ id: 'clusters.credential.token' })}
|
||||||
required={action === PageAction.CREATE}
|
required={action === PageAction.CREATE}
|
||||||
></SealInput.Password>
|
></SealInput.Password>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import ModalFooter from '@/components/modal-footer';
|
|||||||
import ScrollerModal from '@/components/scroller-modal';
|
import ScrollerModal from '@/components/scroller-modal';
|
||||||
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 { PageAction } from '@/config';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
|
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 _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -33,6 +35,7 @@ const AddCluster: React.FC<AddModalProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const { getRuleMessage } = useAppUtils();
|
||||||
|
|
||||||
const handleSumit = () => {
|
const handleSumit = () => {
|
||||||
form.submit();
|
form.submit();
|
||||||
@@ -97,17 +100,17 @@ const AddCluster: React.FC<AddModalProps> = ({
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: intl.formatMessage(
|
message: getRuleMessage(
|
||||||
{ id: 'common.form.rule.input' },
|
'input',
|
||||||
{
|
'clusters.workerpool.instanceType'
|
||||||
name: intl.formatMessage({ id: 'common.table.name' })
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInput.Input
|
<SealInput.Input
|
||||||
label={intl.formatMessage({ id: 'common.table.name' })}
|
label={intl.formatMessage({
|
||||||
|
id: 'clusters.workerpool.instanceType'
|
||||||
|
})}
|
||||||
required
|
required
|
||||||
></SealInput.Input>
|
></SealInput.Input>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@@ -116,49 +119,45 @@ const AddCluster: React.FC<AddModalProps> = ({
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: intl.formatMessage(
|
message: getRuleMessage('input', 'clusters.workerpool.replicas')
|
||||||
{ id: 'common.form.rule.input' },
|
|
||||||
{
|
|
||||||
name: 'Replicas'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInputNumber label="Replicas" required></SealInputNumber>
|
<SealInputNumber
|
||||||
|
label={intl.formatMessage({ id: 'clusters.workerpool.replicas' })}
|
||||||
|
required
|
||||||
|
></SealInputNumber>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="batch_size"
|
name="batch_size"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: intl.formatMessage(
|
message: getRuleMessage('input', 'clusters.workerpool.batchSize')
|
||||||
{ id: 'common.form.rule.input' },
|
|
||||||
{
|
|
||||||
name: 'Batch Size'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInputNumber label="Batch Size" required></SealInputNumber>
|
<SealInputNumber
|
||||||
|
label={intl.formatMessage({ id: 'clusters.workerpool.batchSize' })}
|
||||||
|
required
|
||||||
|
></SealInputNumber>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="os_image"
|
name="os_image"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: intl.formatMessage(
|
message: getRuleMessage('input', 'clusters.workerpool.osImage')
|
||||||
{ id: 'common.form.rule.input' },
|
|
||||||
{
|
|
||||||
name: 'OS Image'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInput.Input label={'OS Image'} required></SealInput.Input>
|
<SealInput.Input
|
||||||
|
disabled={action === PageAction.EDIT}
|
||||||
|
label={intl.formatMessage({ id: 'clusters.workerpool.osImage' })}
|
||||||
|
required
|
||||||
|
></SealInput.Input>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="labels"
|
name="labels"
|
||||||
rules={[
|
rules={[
|
||||||
@@ -184,9 +183,9 @@ const AddCluster: React.FC<AddModalProps> = ({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<LabelSelector
|
<LabelSelector
|
||||||
label="Labels"
|
label={intl.formatMessage({ id: 'resources.table.labels' })}
|
||||||
labels={form.getFieldValue('labels') || {}}
|
labels={form.getFieldValue('labels') || {}}
|
||||||
btnText="Add Label"
|
btnText={intl.formatMessage({ id: 'common.button.addLabel' })}
|
||||||
></LabelSelector>
|
></LabelSelector>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import SealSelect from '@/components/seal-form/seal-select';
|
import SealSelect from '@/components/seal-form/seal-select';
|
||||||
|
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 _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -11,6 +12,7 @@ type OptionData = {
|
|||||||
label: string;
|
label: string;
|
||||||
datacenter: string;
|
datacenter: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
icon: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const OptionItem = styled.div`
|
const OptionItem = styled.div`
|
||||||
@@ -30,6 +32,9 @@ const OptionItem = styled.div`
|
|||||||
.value {
|
.value {
|
||||||
color: var(--ant-color-text-secondary);
|
color: var(--ant-color-text-secondary);
|
||||||
}
|
}
|
||||||
|
.icon {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface CloudProviderProps {
|
interface CloudProviderProps {
|
||||||
@@ -50,6 +55,7 @@ const optionRender = (
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<OptionItem className="flex-center">
|
<OptionItem className="flex-center">
|
||||||
|
<span className="icon">{data.icon}</span>
|
||||||
<span className="label">{data.label}</span> <span className="dot"></span>
|
<span className="label">{data.label}</span> <span className="dot"></span>
|
||||||
<span className="datacenter">{data.datacenter}</span>{' '}
|
<span className="datacenter">{data.datacenter}</span>{' '}
|
||||||
<span className="dot"></span>{' '}
|
<span className="dot"></span>{' '}
|
||||||
@@ -65,6 +71,7 @@ const labelRender = (props: {
|
|||||||
const data = regionList.find((item) => item.value === props.value);
|
const data = regionList.find((item) => item.value === props.value);
|
||||||
return (
|
return (
|
||||||
<OptionItem className="flex-center">
|
<OptionItem className="flex-center">
|
||||||
|
<span className="icon">{data?.icon}</span>
|
||||||
<span className="label">{data?.label}</span> <span className="dot"></span>
|
<span className="label">{data?.label}</span> <span className="dot"></span>
|
||||||
<span className="datacenter">{data?.datacenter}</span>{' '}
|
<span className="datacenter">{data?.datacenter}</span>{' '}
|
||||||
<span className="dot"></span>
|
<span className="dot"></span>
|
||||||
@@ -76,6 +83,7 @@ const labelRender = (props: {
|
|||||||
const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
||||||
const { credentialList } = props;
|
const { credentialList } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const { getRuleMessage } = useAppUtils();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -94,7 +102,7 @@ const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
label="Credential"
|
label={intl.formatMessage({ id: 'clusters.credential.title' })}
|
||||||
required
|
required
|
||||||
options={credentialList}
|
options={credentialList}
|
||||||
></SealSelect>
|
></SealSelect>
|
||||||
@@ -104,17 +112,12 @@ const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: intl.formatMessage(
|
message: getRuleMessage('input', 'clusters.workerpool.region')
|
||||||
{ id: 'common.form.rule.input' },
|
|
||||||
{
|
|
||||||
name: 'Region'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
label="Region"
|
label={intl.formatMessage({ id: 'clusters.workerpool.region' })}
|
||||||
required
|
required
|
||||||
options={regionList}
|
options={regionList}
|
||||||
labelRender={labelRender}
|
labelRender={labelRender}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import GSDrawer from '@/components/scroller-modal/gs-drawer';
|
import GSDrawer from '@/components/scroller-modal/gs-drawer';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ClusterListItem } from '../config/types';
|
import { ClusterListItem } from '../config/types';
|
||||||
import ClusterDetailContent from './cluster-detail-content';
|
import ClusterDetailContent from './cluster-metrics';
|
||||||
|
|
||||||
interface ClusterDetailModalProps {
|
interface ClusterDetailModalProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
|
|||||||
+12
-25
@@ -1,15 +1,13 @@
|
|||||||
import GaugeChart from '@/components/echarts/gauge';
|
import GaugeChart from '@/components/echarts/gauge';
|
||||||
import Card from '@/components/templates/card';
|
import Card from '@/components/templates/card';
|
||||||
import { PageAction } from '@/config';
|
import { useSearchParams } from '@umijs/max';
|
||||||
import { Col, Row } from 'antd';
|
import { Col, Row } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { queryClusterDetail } from '../apis';
|
import { queryClusterDetail } from '../apis';
|
||||||
import { ProviderValueMap } from '../config';
|
import { ClusterListItem } from '../config/types';
|
||||||
import { ClusterListItem, NodePoolListItem } from '../config/types';
|
|
||||||
import TrendChart from './trend-chart';
|
import TrendChart from './trend-chart';
|
||||||
import WorkerPools from './worker-pools';
|
|
||||||
|
|
||||||
const metricsMap = {
|
const metricsMap = {
|
||||||
cpu: {
|
cpu: {
|
||||||
@@ -81,17 +79,11 @@ const formatValue = (value: number) => {
|
|||||||
|
|
||||||
const CardHeight = 336;
|
const CardHeight = 336;
|
||||||
|
|
||||||
const ClusterDetail: React.FC<ClusterDetailProps> = ({ data }) => {
|
const ClusterMetrics = () => {
|
||||||
const chartHeight = 160;
|
const chartHeight = 160;
|
||||||
const [show, setShow] = React.useState(false);
|
const [searchParams] = useSearchParams();
|
||||||
const [addPoolStatus, setAddPoolStatus] = React.useState({
|
const id = searchParams.get('id');
|
||||||
open: false,
|
const provider = searchParams.get('provider');
|
||||||
action: PageAction.CREATE,
|
|
||||||
title: '',
|
|
||||||
provider: ProviderValueMap.DigitalOcean,
|
|
||||||
currentData: null as NodePoolListItem | null,
|
|
||||||
clusterId: 0
|
|
||||||
});
|
|
||||||
const [detailContent, setDetailContent] = useState<{
|
const [detailContent, setDetailContent] = useState<{
|
||||||
current: {
|
current: {
|
||||||
cpu: number;
|
cpu: number;
|
||||||
@@ -111,12 +103,12 @@ const ClusterDetail: React.FC<ClusterDetailProps> = ({ data }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getClusterDetail = async () => {
|
const getClusterDetail = async () => {
|
||||||
if (!data) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await queryClusterDetail({
|
const response = await queryClusterDetail({
|
||||||
cluster_id: data!.id
|
cluster_id: id
|
||||||
});
|
});
|
||||||
setDetailContent({
|
setDetailContent({
|
||||||
current: response.system_load?.current,
|
current: response.system_load?.current,
|
||||||
@@ -137,10 +129,10 @@ const ClusterDetail: React.FC<ClusterDetailProps> = ({ data }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.id) {
|
if (id) {
|
||||||
getClusterDetail();
|
getClusterDetail();
|
||||||
}
|
}
|
||||||
}, [data?.id]);
|
}, [id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -225,13 +217,8 @@ const ClusterDetail: React.FC<ClusterDetailProps> = ({ data }) => {
|
|||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{data?.provider === ProviderValueMap.DigitalOcean && (
|
|
||||||
<>
|
|
||||||
<WorkerPools clusterData={data} height={'auto'} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ClusterDetail;
|
export default ClusterMetrics;
|
||||||
@@ -63,6 +63,7 @@ const TrendChart: React.FC<TrendChartProps> = ({
|
|||||||
<LineChart
|
<LineChart
|
||||||
height={320}
|
height={320}
|
||||||
title={title}
|
title={title}
|
||||||
|
showArea={false}
|
||||||
seriesData={generateData.seriesData}
|
seriesData={generateData.seriesData}
|
||||||
legendData={generateData.legendData}
|
legendData={generateData.legendData}
|
||||||
xAxisData={generateData.xAxisData}
|
xAxisData={generateData.xAxisData}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import DeleteModal from '@/components/delete-modal';
|
import DeleteModal from '@/components/delete-modal';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import { FilterBar } from '@/components/page-tools';
|
||||||
import LabelsCell from '@/components/label-cell';
|
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import useTableFetch from '@/hooks/use-table-fetch';
|
import useTableFetch from '@/hooks/use-table-fetch';
|
||||||
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
|
import { useIntl, useSearchParams } from '@umijs/max';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useMemoizedFn } from 'ahooks';
|
||||||
import { message, Table } from 'antd';
|
import { message, Table } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import {
|
import {
|
||||||
@@ -18,10 +16,10 @@ import {
|
|||||||
} from '../apis';
|
} from '../apis';
|
||||||
import { ProviderValueMap } from '../config';
|
import { ProviderValueMap } from '../config';
|
||||||
import {
|
import {
|
||||||
ClusterListItem,
|
|
||||||
NodePoolListItem as ListItem,
|
NodePoolListItem as ListItem,
|
||||||
NodePoolFormData
|
NodePoolFormData
|
||||||
} from '../config/types';
|
} from '../config/types';
|
||||||
|
import usePoolsColumns from '../hooks/use-pools-columns';
|
||||||
import AddPool from './add-pool';
|
import AddPool from './add-pool';
|
||||||
|
|
||||||
const SubTitle = styled.div`
|
const SubTitle = styled.div`
|
||||||
@@ -31,39 +29,14 @@ const SubTitle = styled.div`
|
|||||||
margin-block: 24px 16px;
|
margin-block: 24px 16px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const actionItems = [
|
const WorkerPools = () => {
|
||||||
{
|
const [searchParams] = useSearchParams();
|
||||||
key: 'edit',
|
|
||||||
label: 'common.button.edit',
|
|
||||||
icon: <EditOutlined />
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
key: 'delete',
|
|
||||||
label: 'common.button.delete',
|
|
||||||
icon: <DeleteOutlined />,
|
|
||||||
props: {
|
|
||||||
danger: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
interface WorkerPoolsProps {
|
|
||||||
loading?: boolean;
|
|
||||||
height?: string | number;
|
|
||||||
clusterData: ClusterListItem | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|
||||||
loading = false,
|
|
||||||
clusterData,
|
|
||||||
height = 'auto'
|
|
||||||
}) => {
|
|
||||||
const {
|
const {
|
||||||
dataSource,
|
dataSource,
|
||||||
rowSelection,
|
rowSelection,
|
||||||
queryParams,
|
queryParams,
|
||||||
modalRef,
|
modalRef,
|
||||||
|
sortOrder,
|
||||||
fetchData,
|
fetchData,
|
||||||
handleDelete,
|
handleDelete,
|
||||||
handleDeleteBatch,
|
handleDeleteBatch,
|
||||||
@@ -77,9 +50,9 @@ const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|||||||
deleteAPI: deleteWorkerPool,
|
deleteAPI: deleteWorkerPool,
|
||||||
API: WORKER_POOLS_API,
|
API: WORKER_POOLS_API,
|
||||||
watch: false,
|
watch: false,
|
||||||
contentForDelete: 'resources.modelfiles.modelfile',
|
contentForDelete: 'clusters.workerpool.title',
|
||||||
defaultQueryParams: {
|
defaultQueryParams: {
|
||||||
cluster_id: clusterData!.id
|
cluster_id: searchParams.get('id') || undefined
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -89,7 +62,7 @@ const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|||||||
title: '',
|
title: '',
|
||||||
provider: ProviderValueMap.DigitalOcean,
|
provider: ProviderValueMap.DigitalOcean,
|
||||||
currentData: null as ListItem | null,
|
currentData: null as ListItem | null,
|
||||||
clusterId: 0
|
clusterId: 0 as number | string
|
||||||
});
|
});
|
||||||
|
|
||||||
// pool action handler
|
// pool action handler
|
||||||
@@ -98,29 +71,43 @@ const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|||||||
setAddPoolStatus({
|
setAddPoolStatus({
|
||||||
open: true,
|
open: true,
|
||||||
action: PageAction.EDIT,
|
action: PageAction.EDIT,
|
||||||
title: 'Edit Worker Pool',
|
title: intl.formatMessage(
|
||||||
provider: clusterData!.provider,
|
{ id: 'common.button.edit.item' },
|
||||||
|
{ name: record.instance_type }
|
||||||
|
),
|
||||||
|
provider: searchParams.get('provider') || '',
|
||||||
currentData: record,
|
currentData: record,
|
||||||
clusterId: clusterData!.id
|
clusterId: searchParams.get('id') || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (key: string, record: ListItem) => {
|
const handleAddPool = (row: ListItem) => {
|
||||||
|
setAddPoolStatus({
|
||||||
|
open: true,
|
||||||
|
action: PageAction.CREATE,
|
||||||
|
title: intl.formatMessage({ id: 'clusters.button.addNodePool' }),
|
||||||
|
provider: searchParams.get('provider') || '',
|
||||||
|
clusterId: searchParams.get('id') || 0,
|
||||||
|
currentData: null
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSelect = useMemoizedFn((key: string, record: ListItem) => {
|
||||||
if (key === 'delete') {
|
if (key === 'delete') {
|
||||||
handleDelete({ ...record, name: record.instance_type });
|
handleDelete({ ...record, name: record.instance_type });
|
||||||
}
|
}
|
||||||
if (key === 'edit') {
|
if (key === 'edit') {
|
||||||
handleEdit(key, record);
|
handleEdit(key, record);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
const handleSubmitWorkerPool = async (formdata: NodePoolFormData) => {
|
const handleSubmitWorkerPool = async (formdata: NodePoolFormData) => {
|
||||||
try {
|
try {
|
||||||
if (addPoolStatus.action === PageAction.CREATE) {
|
if (addPoolStatus.action === PageAction.CREATE) {
|
||||||
await createWorkerPool({
|
await createWorkerPool({
|
||||||
data: formdata,
|
data: formdata,
|
||||||
clusterId: clusterData!.id
|
clusterId: searchParams.get('id') || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (addPoolStatus.action === PageAction.EDIT) {
|
if (addPoolStatus.action === PageAction.EDIT) {
|
||||||
@@ -140,61 +127,45 @@ const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = usePoolsColumns(sortOrder, onSelect);
|
||||||
{
|
|
||||||
title: 'Instance Type',
|
|
||||||
dataIndex: 'instance_type',
|
|
||||||
key: 'instance_type'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Replicas',
|
|
||||||
dataIndex: 'replicas',
|
|
||||||
key: 'replicas'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Batch Size',
|
|
||||||
dataIndex: 'batch_size',
|
|
||||||
key: 'batch_size'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Labels',
|
|
||||||
dataIndex: 'labels',
|
|
||||||
key: 'labels',
|
|
||||||
render: (text: string, record: ListItem) => (
|
|
||||||
<LabelsCell labels={record.labels}></LabelsCell>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Create Time',
|
|
||||||
dataIndex: 'create_at',
|
|
||||||
key: 'created_at',
|
|
||||||
render: (text: string) => dayjs(text).format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Operations',
|
|
||||||
key: 'operations',
|
|
||||||
render: (text: string, record: ListItem) => (
|
|
||||||
<DropdownButtons
|
|
||||||
items={actionItems}
|
|
||||||
onSelect={(key) => onSelect?.(key, record)}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SubTitle>
|
<SubTitle>
|
||||||
<span>Worker Pools</span>
|
<span>{intl.formatMessage({ id: 'clusters.workerpool.title' })}</span>
|
||||||
</SubTitle>
|
</SubTitle>
|
||||||
<div style={{ height: height, overflow: 'hidden' }}>
|
<FilterBar
|
||||||
|
showSelect={false}
|
||||||
|
showPrimaryButton={true}
|
||||||
|
showDeleteButton={true}
|
||||||
|
marginBottom={22}
|
||||||
|
marginTop={22}
|
||||||
|
width={{ input: 300 }}
|
||||||
|
buttonText={intl.formatMessage({ id: 'clusters.button.addNodePool' })}
|
||||||
|
rowSelection={rowSelection}
|
||||||
|
handleInputChange={handleNameChange}
|
||||||
|
handleSearch={handleSearch}
|
||||||
|
handleDeleteByBatch={handleDeleteBatch}
|
||||||
|
handleClickPrimary={handleAddPool}
|
||||||
|
></FilterBar>
|
||||||
<Table
|
<Table
|
||||||
dataSource={dataSource.dataList}
|
|
||||||
columns={columns}
|
|
||||||
loading={loading}
|
|
||||||
pagination={false}
|
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
/>
|
tableLayout="fixed"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
onChange={handleTableChange}
|
||||||
|
dataSource={dataSource.dataList}
|
||||||
|
loading={dataSource.loading}
|
||||||
|
rowSelection={rowSelection}
|
||||||
|
columns={columns}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
pageSize: queryParams.perPage,
|
||||||
|
current: queryParams.page,
|
||||||
|
total: dataSource.total,
|
||||||
|
hideOnSinglePage: queryParams.perPage === 10,
|
||||||
|
onChange: handlePageChange
|
||||||
|
}}
|
||||||
|
></Table>
|
||||||
<AddPool
|
<AddPool
|
||||||
provider={addPoolStatus.provider}
|
provider={addPoolStatus.provider}
|
||||||
open={addPoolStatus.open}
|
open={addPoolStatus.open}
|
||||||
@@ -214,7 +185,6 @@ const WorkerPools: React.FC<WorkerPoolsProps> = ({
|
|||||||
onOk={handleSubmitWorkerPool}
|
onOk={handleSubmitWorkerPool}
|
||||||
></AddPool>
|
></AddPool>
|
||||||
<DeleteModal ref={modalRef}></DeleteModal>
|
<DeleteModal ref={modalRef}></DeleteModal>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ export const clusterActionList = [
|
|||||||
label: 'common.button.edit',
|
label: 'common.button.edit',
|
||||||
icon: icons.EditOutlined
|
icon: icons.EditOutlined
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'details',
|
|
||||||
label: 'common.button.detail',
|
|
||||||
icon: icons.FileTextOutlined
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'add_worker',
|
key: 'add_worker',
|
||||||
label: 'resources.button.create',
|
label: 'resources.button.create',
|
||||||
@@ -127,20 +122,36 @@ export const regionList: {
|
|||||||
label: string;
|
label: string;
|
||||||
datacenter: string;
|
datacenter: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
icon: string;
|
||||||
}[] = [
|
}[] = [
|
||||||
{ label: 'New York', datacenter: 'Datacenter 1', value: 'nyc1' },
|
{ label: 'New York', datacenter: 'Datacenter 1', value: 'nyc1', icon: '🇺🇸' },
|
||||||
{ label: 'New York', datacenter: 'Datacenter 2', value: 'nyc2' },
|
{ label: 'New York', datacenter: 'Datacenter 2', value: 'nyc2', icon: '🇺🇸' },
|
||||||
{ label: 'New York', datacenter: 'Datacenter 3', value: 'nyc3' },
|
{ label: 'New York', datacenter: 'Datacenter 3', value: 'nyc3', icon: '🇺🇸' },
|
||||||
{ label: 'Toronto', datacenter: 'Datacenter 1', value: 'tor1' },
|
{ label: 'Toronto', datacenter: 'Datacenter 1', value: 'tor1', icon: '🇨🇦' },
|
||||||
{ label: 'San Francisco', datacenter: 'Datacenter 1', value: 'sfo1' },
|
{
|
||||||
{ label: 'San Francisco', datacenter: 'Datacenter 2', value: 'sfo2' },
|
label: 'San Francisco',
|
||||||
{ label: 'San Francisco', datacenter: 'Datacenter 3', value: 'sfo3' },
|
datacenter: 'Datacenter 1',
|
||||||
{ label: 'Atlanta', datacenter: 'Datacenter 1', value: 'atl1' },
|
value: 'sfo1',
|
||||||
{ label: 'Singapore', datacenter: 'Datacenter 1', value: 'sgp1' },
|
icon: '🇺🇸'
|
||||||
{ label: 'Bangalore', datacenter: 'Datacenter 1', value: 'blr1' },
|
},
|
||||||
{ label: 'London', datacenter: 'Datacenter 1', value: 'lon1' },
|
{
|
||||||
{ label: 'Amsterdam', datacenter: 'Datacenter 2', value: 'ams2' },
|
label: 'San Francisco',
|
||||||
{ label: 'Amsterdam', datacenter: 'Datacenter 3', value: 'ams3' },
|
datacenter: 'Datacenter 2',
|
||||||
{ label: 'Frankfurt', datacenter: 'Datacenter 1', value: 'fra1' },
|
value: 'sfo2',
|
||||||
{ label: 'Sydney', datacenter: 'Datacenter 1', value: 'syd1' }
|
icon: '🇺🇸'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'San Francisco',
|
||||||
|
datacenter: 'Datacenter 3',
|
||||||
|
value: 'sfo3',
|
||||||
|
icon: '🇺🇸'
|
||||||
|
},
|
||||||
|
{ label: 'Atlanta', datacenter: 'Datacenter 1', value: 'atl1', icon: '🇺🇸' },
|
||||||
|
{ label: 'Singapore', datacenter: 'Datacenter 1', value: 'sgp1', icon: '🇸🇬' },
|
||||||
|
{ label: 'Bangalore', datacenter: 'Datacenter 1', value: 'blr1', icon: '🇮🇳' },
|
||||||
|
{ label: 'London', datacenter: 'Datacenter 1', value: 'lon1', icon: '🇬🇧' },
|
||||||
|
{ label: 'Amsterdam', datacenter: 'Datacenter 2', value: 'ams2', icon: '🇳🇱' },
|
||||||
|
{ label: 'Amsterdam', datacenter: 'Datacenter 3', value: 'ams3', icon: '🇳🇱' },
|
||||||
|
{ label: 'Frankfurt', datacenter: 'Datacenter 1', value: 'fra1', icon: '🇩🇪' },
|
||||||
|
{ label: 'Sydney', datacenter: 'Datacenter 1', value: 'syd1', icon: '🇦🇺' }
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
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 StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { useIntl } from '@umijs/max';
|
import { Link, useIntl } from '@umijs/max';
|
||||||
import { ColumnsType } from 'antd/es/table';
|
import { ColumnsType } from 'antd/es/table';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
@@ -14,25 +14,34 @@ import {
|
|||||||
} from '../config';
|
} from '../config';
|
||||||
import { ClusterListItem } from '../config/types';
|
import { ClusterListItem } from '../config/types';
|
||||||
|
|
||||||
const useClusterColumns = (
|
const setActionsItems = (row: ClusterListItem) => {
|
||||||
handleSelect: (val: string, record: ClusterListItem) => void
|
|
||||||
): ColumnsType<ClusterListItem> => {
|
|
||||||
const intl = useIntl();
|
|
||||||
const setActionsItems = (row: ClusterListItem) => {
|
|
||||||
return clusterActionList.filter((item) => {
|
return clusterActionList.filter((item) => {
|
||||||
if (item.provider) {
|
if (item.provider) {
|
||||||
return item.provider === row.provider;
|
return item.provider === row.provider;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const useClusterColumns = (
|
||||||
|
handleSelect: (val: string, record: ClusterListItem) => void
|
||||||
|
): ColumnsType<ClusterListItem> => {
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'common.table.name' }),
|
title: intl.formatMessage({ id: 'common.table.name' }),
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
render: (text: string) => <AutoTooltip ghost>{text}</AutoTooltip>
|
render: (text: string, record: ClusterListItem) => (
|
||||||
|
<AutoTooltip ghost>
|
||||||
|
<Link
|
||||||
|
to={`/cluster-management/cluster/detail?id=${record.id}&provider=${record.provider}&name=${record.name}`}
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</Link>
|
||||||
|
</AutoTooltip>
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'clusters.table.provider' }),
|
title: intl.formatMessage({ id: 'clusters.table.provider' }),
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
|
import LabelsCell from '@/components/label-cell';
|
||||||
|
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { ColumnsType } from 'antd/es/table';
|
||||||
|
import type { SortOrder } from 'antd/es/table/interface';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import { NodePoolListItem as ListItem } from '../config/types';
|
||||||
|
|
||||||
|
const actionItems = [
|
||||||
|
{
|
||||||
|
key: 'edit',
|
||||||
|
label: 'common.button.edit',
|
||||||
|
icon: <EditOutlined />
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
key: 'delete',
|
||||||
|
label: 'common.button.delete',
|
||||||
|
icon: <DeleteOutlined />,
|
||||||
|
props: {
|
||||||
|
danger: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const usePoolsColumns = (
|
||||||
|
sortOrder: SortOrder,
|
||||||
|
handleSelect: (val: string, record: ListItem) => void
|
||||||
|
): ColumnsType<ListItem> => {
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
return useMemo(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'clusters.workerpool.instanceType' }),
|
||||||
|
dataIndex: 'instance_type',
|
||||||
|
key: 'instance_type',
|
||||||
|
ellipsis: {
|
||||||
|
showTitle: false
|
||||||
|
},
|
||||||
|
render: (text: string) => (
|
||||||
|
<AutoTooltip title={text} ghost minWidth={20}>
|
||||||
|
{text}
|
||||||
|
</AutoTooltip>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'clusters.workerpool.replicas' }),
|
||||||
|
dataIndex: 'replicas',
|
||||||
|
key: 'replicas'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'clusters.workerpool.batchSize' }),
|
||||||
|
dataIndex: 'batch_size',
|
||||||
|
key: 'batch_size'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'clusters.workerpool.osImage' }),
|
||||||
|
dataIndex: 'os_image',
|
||||||
|
key: 'os_image',
|
||||||
|
ellipsis: {
|
||||||
|
showTitle: false
|
||||||
|
},
|
||||||
|
render: (text: string) => (
|
||||||
|
<AutoTooltip title={text} ghost minWidth={20}>
|
||||||
|
{text}
|
||||||
|
</AutoTooltip>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'resources.table.labels' }),
|
||||||
|
dataIndex: 'labels',
|
||||||
|
key: 'labels',
|
||||||
|
width: 200,
|
||||||
|
render: (text: string, record: ListItem) => (
|
||||||
|
<LabelsCell labels={record.labels}></LabelsCell>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'common.table.createTime' }),
|
||||||
|
dataIndex: 'create_at',
|
||||||
|
key: 'created_at',
|
||||||
|
showSorterTooltip: false,
|
||||||
|
defaultSortOrder: 'descend',
|
||||||
|
sortOrder: sortOrder,
|
||||||
|
sorter: false,
|
||||||
|
ellipsis: {
|
||||||
|
showTitle: false
|
||||||
|
},
|
||||||
|
render: (text: string) => dayjs(text).format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'common.table.operation' }),
|
||||||
|
key: 'operations',
|
||||||
|
render: (text: string, record: ListItem) => (
|
||||||
|
<DropdownButtons
|
||||||
|
items={actionItems}
|
||||||
|
onSelect={(key) => handleSelect?.(key, record)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}, [sortOrder, handleSelect]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default usePoolsColumns;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Outlet } from '@umijs/max';
|
||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
const ListLayout: React.FC = () => {
|
||||||
|
const [listParams, setListParams] = useState({ page: 1, keyword: '' });
|
||||||
|
const scrollRef = useRef<number>(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('cluster layout:');
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{/* 提供上下文给子路由:ListPage & DetailPage */}
|
||||||
|
<Outlet context={{ listParams, setListParams, scrollRef }} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ListLayout;
|
||||||
@@ -146,9 +146,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
onValuesChange?.(changedValues, allValues);
|
onValuesChange?.(changedValues, allValues);
|
||||||
};
|
};
|
||||||
|
|
||||||
useImperativeHandle(
|
useImperativeHandle(ref, () => {
|
||||||
ref,
|
|
||||||
() => {
|
|
||||||
return {
|
return {
|
||||||
form: form,
|
form: form,
|
||||||
submit: handleSumit,
|
submit: handleSumit,
|
||||||
@@ -171,9 +169,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
getGPUOptionList(params);
|
getGPUOptionList(params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
}, []);
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormInnerContext.Provider
|
<FormInnerContext.Provider
|
||||||
@@ -252,14 +248,14 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: getRuleMessage('select', 'Cluster', false)
|
message: getRuleMessage('select', 'clusters.title')
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
<SealSelect
|
<SealSelect
|
||||||
onChange={handleClusterChange}
|
onChange={handleClusterChange}
|
||||||
label="Cluster"
|
label={intl.formatMessage({ id: 'clusters.title' })}
|
||||||
options={clusterList}
|
options={clusterList}
|
||||||
required
|
required
|
||||||
></SealSelect>
|
></SealSelect>
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ export const WORKERS_API = '/workers';
|
|||||||
export const GPU_DEVICES_API = '/gpu-devices';
|
export const GPU_DEVICES_API = '/gpu-devices';
|
||||||
export const MODEL_FILES_API = '/model-files';
|
export const MODEL_FILES_API = '/model-files';
|
||||||
|
|
||||||
|
export async function downloadWorkerPrivateKey(id: string | number) {
|
||||||
|
return request(`${WORKERS_API}/${id}/privatekey`, {
|
||||||
|
method: 'GET'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function queryWorkersList<T extends Record<string, any>>(
|
export async function queryWorkersList<T extends Record<string, any>>(
|
||||||
params: Global.SearchParams & T
|
params: Global.SearchParams & T
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
|
|||||||
return commandCode?.registerWorker({
|
return commandCode?.registerWorker({
|
||||||
server: registrationInfo.server_url || origin,
|
server: registrationInfo.server_url || origin,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
|
image: registrationInfo.image,
|
||||||
token: registrationInfo.token || '${token}',
|
token: registrationInfo.token || '${token}',
|
||||||
workerip: '${workerip}'
|
workerip: '${workerip}'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
WORKERS_API,
|
WORKERS_API,
|
||||||
deleteWorker,
|
deleteWorker,
|
||||||
|
downloadWorkerPrivateKey,
|
||||||
queryWorkersList,
|
queryWorkersList,
|
||||||
updateWorker
|
updateWorker
|
||||||
} from '../apis';
|
} from '../apis';
|
||||||
@@ -144,6 +145,9 @@ const Workers: React.FC = () => {
|
|||||||
if (val === 'details') {
|
if (val === 'details') {
|
||||||
handleViewDetail(record);
|
handleViewDetail(record);
|
||||||
}
|
}
|
||||||
|
if (val === 'download_ssh_key') {
|
||||||
|
downloadWorkerPrivateKey(record.id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderEmpty = (type?: string) => {
|
const renderEmpty = (type?: string) => {
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ export const WorkerStatusMap = {
|
|||||||
not_ready: 'not_ready',
|
not_ready: 'not_ready',
|
||||||
unreachable: 'unreachable',
|
unreachable: 'unreachable',
|
||||||
provisioning: 'provisioning',
|
provisioning: 'provisioning',
|
||||||
deleting: 'deleting'
|
deleting: 'deleting',
|
||||||
|
error: 'error'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WorkerStatusMapValue = {
|
export const WorkerStatusMapValue = {
|
||||||
@@ -13,7 +14,8 @@ export const WorkerStatusMapValue = {
|
|||||||
[WorkerStatusMap.not_ready]: 'Not Ready',
|
[WorkerStatusMap.not_ready]: 'Not Ready',
|
||||||
[WorkerStatusMap.unreachable]: 'Unreachable',
|
[WorkerStatusMap.unreachable]: 'Unreachable',
|
||||||
[WorkerStatusMap.provisioning]: 'Provisioning',
|
[WorkerStatusMap.provisioning]: 'Provisioning',
|
||||||
[WorkerStatusMap.deleting]: 'Deleting'
|
[WorkerStatusMap.deleting]: 'Deleting',
|
||||||
|
[WorkerStatusMap.error]: 'Error'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const status: any = {
|
export const status: any = {
|
||||||
@@ -21,21 +23,22 @@ export const status: any = {
|
|||||||
[WorkerStatusMap.not_ready]: StatusMaps.error,
|
[WorkerStatusMap.not_ready]: StatusMaps.error,
|
||||||
[WorkerStatusMap.unreachable]: StatusMaps.error,
|
[WorkerStatusMap.unreachable]: StatusMaps.error,
|
||||||
[WorkerStatusMap.provisioning]: StatusMaps.transitioning,
|
[WorkerStatusMap.provisioning]: StatusMaps.transitioning,
|
||||||
[WorkerStatusMap.deleting]: StatusMaps.warning
|
[WorkerStatusMap.deleting]: StatusMaps.warning,
|
||||||
|
[WorkerStatusMap.error]: StatusMaps.error
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addWorkerGuide: Record<string, any> = {
|
export const addWorkerGuide: Record<string, any> = {
|
||||||
mac: {
|
mac: {
|
||||||
getToken: 'cat /var/lib/gpustack/token',
|
getToken: 'cat /var/lib/gpustack/token',
|
||||||
registerWorker(params: { server: string; token: string }) {
|
registerWorker(params: { server: string; token: string }) {
|
||||||
return `curl -sfL https://get.gpustack.ai | sh -s - --server-url ${params.server} --registration ${params.token}`;
|
return `curl -sfL https://get.gpustack.ai | sh -s - --server-url ${params.server} --registration-token ${params.token}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
win: {
|
win: {
|
||||||
getToken:
|
getToken:
|
||||||
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
|
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
|
||||||
registerWorker(params: { server: string; token: string }) {
|
registerWorker(params: { server: string; token: string }) {
|
||||||
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration '${params.token}'"`;
|
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration-token '${params.token}'"`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cuda: {
|
cuda: {
|
||||||
@@ -45,6 +48,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
server: string;
|
server: string;
|
||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
|
image: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
@@ -53,8 +57,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--network=host \\
|
--network=host \\
|
||||||
--ipc=host \\
|
--ipc=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
npu: {
|
npu: {
|
||||||
@@ -65,6 +69,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
@@ -81,8 +86,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--network=host \\
|
--network=host \\
|
||||||
--ipc=host \\
|
--ipc=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
npu310p: {
|
npu310p: {
|
||||||
@@ -93,6 +98,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
@@ -109,8 +115,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--network=host \\
|
--network=host \\
|
||||||
--ipc=host \\
|
--ipc=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag}-310p \\
|
${params.image} -310p \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
musa: {
|
musa: {
|
||||||
@@ -121,14 +127,15 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
--network=host \\
|
--network=host \\
|
||||||
--ipc=host \\
|
--ipc=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cpu: {
|
cpu: {
|
||||||
@@ -139,13 +146,14 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
--network=host \\
|
--network=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rocm: {
|
rocm: {
|
||||||
@@ -154,6 +162,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
@@ -165,8 +174,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--cap-add=SYS_PTRACE \\
|
--cap-add=SYS_PTRACE \\
|
||||||
--security-opt seccomp=unconfined \\
|
--security-opt seccomp=unconfined \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dcu: {
|
dcu: {
|
||||||
@@ -175,6 +184,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
--restart=unless-stopped \\
|
--restart=unless-stopped \\
|
||||||
@@ -188,8 +198,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--cap-add=SYS_PTRACE \\
|
--cap-add=SYS_PTRACE \\
|
||||||
--security-opt seccomp=unconfined \\
|
--security-opt seccomp=unconfined \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
corex: {
|
corex: {
|
||||||
@@ -198,6 +208,7 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
tag: string;
|
tag: string;
|
||||||
token: string;
|
token: string;
|
||||||
workerip: string;
|
workerip: string;
|
||||||
|
image: string;
|
||||||
}) {
|
}) {
|
||||||
return `docker run -d --name gpustack \\
|
return `docker run -d --name gpustack \\
|
||||||
-v /lib/modules:/lib/modules \\
|
-v /lib/modules:/lib/modules \\
|
||||||
@@ -209,8 +220,8 @@ export const addWorkerGuide: Record<string, any> = {
|
|||||||
--network=host \\
|
--network=host \\
|
||||||
--ipc=host \\
|
--ipc=host \\
|
||||||
-v gpustack-data:/var/lib/gpustack \\
|
-v gpustack-data:/var/lib/gpustack \\
|
||||||
gpustack/gpustack:${params.tag} \\
|
${params.image} \\
|
||||||
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
|
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
container: {
|
container: {
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ export interface ListItem {
|
|||||||
ip: string;
|
ip: string;
|
||||||
cluster_id: number;
|
cluster_id: number;
|
||||||
state_message: string;
|
state_message: string;
|
||||||
|
ssh_key_id: string;
|
||||||
|
progress: string;
|
||||||
status: {
|
status: {
|
||||||
cpu: {
|
cpu: {
|
||||||
total: number;
|
total: number;
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
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 LabelsCell from '@/components/label-cell';
|
import LabelsCell from '@/components/label-cell';
|
||||||
import ProgressBar from '@/components/progress-bar';
|
import ProgressBar from '@/components/progress-bar';
|
||||||
import InfoColumn from '@/components/simple-table/info-column';
|
import InfoColumn from '@/components/simple-table/info-column';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize } from '@/utils';
|
||||||
import {
|
import {
|
||||||
CodeOutlined,
|
|
||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
|
DownloadOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
FileTextOutlined,
|
FileTextOutlined,
|
||||||
InfoCircleOutlined
|
InfoCircleOutlined
|
||||||
@@ -18,7 +17,7 @@ import { Tooltip } from 'antd';
|
|||||||
import { ColumnsType } from 'antd/lib/table';
|
import { ColumnsType } from 'antd/lib/table';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { WorkerStatusMap, WorkerStatusMapValue, status } from '../config';
|
import { WorkerStatusMapValue, status } from '../config';
|
||||||
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
|
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
|
||||||
|
|
||||||
const ActionList = [
|
const ActionList = [
|
||||||
@@ -29,12 +28,17 @@ const ActionList = [
|
|||||||
icon: <FileTextOutlined></FileTextOutlined>
|
icon: <FileTextOutlined></FileTextOutlined>
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'common.button.logs',
|
label: 'resources.worker.download.privatekey',
|
||||||
locale: false,
|
key: 'download_ssh_key',
|
||||||
key: 'logs',
|
icon: <DownloadOutlined />
|
||||||
icon: <IconFont type="icon-logs" />
|
|
||||||
},
|
},
|
||||||
{ label: 'Terminal', locale: false, key: 'terminal', icon: <CodeOutlined /> },
|
// {
|
||||||
|
// label: 'common.button.logs',
|
||||||
|
// locale: false,
|
||||||
|
// key: 'logs',
|
||||||
|
// icon: <IconFont type="icon-logs" />
|
||||||
|
// },
|
||||||
|
// { label: 'Terminal', locale: false, key: 'terminal', icon: <CodeOutlined /> },
|
||||||
{
|
{
|
||||||
label: 'common.button.delete',
|
label: 'common.button.delete',
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
@@ -45,8 +49,8 @@ const ActionList = [
|
|||||||
|
|
||||||
const setActions = (row: ListItem) => {
|
const setActions = (row: ListItem) => {
|
||||||
return ActionList.filter((action) => {
|
return ActionList.filter((action) => {
|
||||||
if (action.key === 'details' && row.state === WorkerStatusMap.ready) {
|
if (action.key === 'download_ssh_key') {
|
||||||
return true;
|
return !!row.ssh_key_id;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -224,6 +228,7 @@ const useWorkerColumns = ({
|
|||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<StatusTag
|
<StatusTag
|
||||||
maxTooltipWidth={400}
|
maxTooltipWidth={400}
|
||||||
|
suffix={record.progress}
|
||||||
statusValue={{
|
statusValue={{
|
||||||
status: status[record.state] as any,
|
status: status[record.state] as any,
|
||||||
text: WorkerStatusMapValue[record.state],
|
text: WorkerStatusMapValue[record.state],
|
||||||
|
|||||||
Reference in New Issue
Block a user