fix: resource topology ux
This commit is contained in:
@@ -60,7 +60,7 @@ const ClusterDetailModal = () => {
|
|||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
key: 'workers',
|
key: 'workers',
|
||||||
label: `Workers`,
|
label: intl.formatMessage({ id: 'resources.nodes' }),
|
||||||
icon: <IconFont type="icon-resources" />,
|
icon: <IconFont type="icon-resources" />,
|
||||||
children: (
|
children: (
|
||||||
<WorkerList clusterId={Number(id)} source="clusterDetail" />
|
<WorkerList clusterId={Number(id)} source="clusterDetail" />
|
||||||
@@ -68,7 +68,7 @@ const ClusterDetailModal = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'gpus',
|
key: 'gpus',
|
||||||
label: `GPUs`,
|
label: intl.formatMessage({ id: 'menu.resources.gpus' }),
|
||||||
icon: <IconFont type="icon-gpu1" />,
|
icon: <IconFont type="icon-gpu1" />,
|
||||||
children: <GPUList clusterId={Number(id)} source="clusterDetail" />
|
children: <GPUList clusterId={Number(id)} source="clusterDetail" />
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import { useClusterDetail } from '../../services/use-cluster-detail';
|
|||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 168px;
|
height: 146px;
|
||||||
.left {
|
.left {
|
||||||
padding: 16px 24px;
|
padding: 16px 0px;
|
||||||
width: 124px;
|
width: 124px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -56,7 +56,7 @@ const Resources = styled.div`
|
|||||||
gap: 24px;
|
gap: 24px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
margin-top: 16px;
|
margin-top: 24px;
|
||||||
.item {
|
.item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -134,7 +134,6 @@ const ClusterBasic: React.FC<{ clusterId: number }> = ({ clusterId }) => {
|
|||||||
)}
|
)}
|
||||||
</Title>
|
</Title>
|
||||||
}
|
}
|
||||||
layout="vertical"
|
|
||||||
items={items}
|
items={items}
|
||||||
/>
|
/>
|
||||||
<Resources>
|
<Resources>
|
||||||
|
|||||||
@@ -47,10 +47,21 @@ const ClusterSystemLoad: React.FC<{ clusterId: number }> = ({ clusterId }) => {
|
|||||||
}
|
}
|
||||||
}, [clusterId]);
|
}, [clusterId]);
|
||||||
|
|
||||||
|
const generateStrokeColor = (percent: number) => {
|
||||||
|
if (percent <= 50) {
|
||||||
|
return 'var(--ant-color-success)';
|
||||||
|
}
|
||||||
|
if (percent <= 80) {
|
||||||
|
return 'var(--ant-color-warning)';
|
||||||
|
}
|
||||||
|
return 'var(--ant-color-error)';
|
||||||
|
};
|
||||||
|
|
||||||
const renderStepsProgress = (
|
const renderStepsProgress = (
|
||||||
percent: number,
|
percent: number,
|
||||||
tag: { color: string; text: string }
|
tag: { color: string; text: string }
|
||||||
) => {
|
) => {
|
||||||
|
const strokeColor = generateStrokeColor(percent);
|
||||||
return (
|
return (
|
||||||
<Progress
|
<Progress
|
||||||
percent={percent}
|
percent={percent}
|
||||||
@@ -58,6 +69,7 @@ const ClusterSystemLoad: React.FC<{ clusterId: number }> = ({ clusterId }) => {
|
|||||||
size={50}
|
size={50}
|
||||||
strokeWidth={8}
|
strokeWidth={8}
|
||||||
showInfo={true}
|
showInfo={true}
|
||||||
|
strokeColor={strokeColor}
|
||||||
format={() => (
|
format={() => (
|
||||||
<Tag
|
<Tag
|
||||||
color={tag?.color || 'blue'}
|
color={tag?.color || 'blue'}
|
||||||
|
|||||||
@@ -24,15 +24,18 @@ import {
|
|||||||
ProviderValueMap
|
ProviderValueMap
|
||||||
} from '../config';
|
} from '../config';
|
||||||
import { ClusterListItem } from '../config/types';
|
import { ClusterListItem } from '../config/types';
|
||||||
|
|
||||||
const clusterActionList = [
|
const clusterActionList = [
|
||||||
{
|
{
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
label: 'common.button.edit',
|
label: 'common.button.edit',
|
||||||
|
order: 0,
|
||||||
icon: icons.EditOutlined
|
icon: icons.EditOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'resources.metrics.details',
|
label: 'resources.metrics.details',
|
||||||
key: 'metrics',
|
key: 'metrics',
|
||||||
|
order: 10,
|
||||||
icon: (
|
icon: (
|
||||||
<span className="flex-center">
|
<span className="flex-center">
|
||||||
<GrafanaIcon style={{ width: 14, height: 14 }}></GrafanaIcon>
|
<GrafanaIcon style={{ width: 14, height: 14 }}></GrafanaIcon>
|
||||||
@@ -44,6 +47,7 @@ const clusterActionList = [
|
|||||||
label: 'resources.button.create',
|
label: 'resources.button.create',
|
||||||
provider: ProviderValueMap.Docker,
|
provider: ProviderValueMap.Docker,
|
||||||
locale: true,
|
locale: true,
|
||||||
|
order: 20,
|
||||||
icon: icons.DockerOutlined
|
icon: icons.DockerOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -51,6 +55,7 @@ const clusterActionList = [
|
|||||||
label: 'clusters.button.register',
|
label: 'clusters.button.register',
|
||||||
provider: ProviderValueMap.Kubernetes,
|
provider: ProviderValueMap.Kubernetes,
|
||||||
locale: true,
|
locale: true,
|
||||||
|
order: 30,
|
||||||
icon: icons.KubernetesOutlined
|
icon: icons.KubernetesOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,16 +63,20 @@ const clusterActionList = [
|
|||||||
label: 'clusters.button.addNodePool',
|
label: 'clusters.button.addNodePool',
|
||||||
provider: ProviderValueMap.DigitalOcean,
|
provider: ProviderValueMap.DigitalOcean,
|
||||||
locale: true,
|
locale: true,
|
||||||
|
order: 40,
|
||||||
icon: icons.Catalog1
|
icon: icons.Catalog1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'isDefault',
|
key: 'isDefault',
|
||||||
label: 'clusters.form.setDefault',
|
label: 'clusters.form.setDefault',
|
||||||
|
locale: true,
|
||||||
|
order: 50,
|
||||||
icon: icons.StarOutlined
|
icon: icons.StarOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
label: 'common.button.delete',
|
label: 'common.button.delete',
|
||||||
|
order: 999,
|
||||||
icon: icons.DeleteOutlined,
|
icon: icons.DeleteOutlined,
|
||||||
props: {
|
props: {
|
||||||
danger: true
|
danger: true
|
||||||
@@ -88,11 +97,15 @@ const useClusterColumns = (
|
|||||||
// `clusterDetail.linkableName`. Without a plugin we render the
|
// `clusterDetail.linkableName`. Without a plugin we render the
|
||||||
// name as plain text (matches the pre-restore behaviour); with one
|
// name as plain text (matches the pre-restore behaviour); with one
|
||||||
// we use Typography.Link wired to the parent's `onCellClick`.
|
// we use Typography.Link wired to the parent's `onCellClick`.
|
||||||
const nameLinkable: boolean =
|
|
||||||
!!getGPUStackPlugin()?.clusterDetail?.linkableName;
|
const { linkableName: nameLinkable, useGenerateActions } =
|
||||||
|
getGPUStackPlugin()?.clusterDetail || {};
|
||||||
|
|
||||||
|
const actionList =
|
||||||
|
useGenerateActions?.({ actions: clusterActionList }) || clusterActionList;
|
||||||
|
|
||||||
const setActionsItems = (row: ClusterListItem) => {
|
const setActionsItems = (row: ClusterListItem) => {
|
||||||
return clusterActionList.filter((item) => {
|
return actionList.filter((item: any) => {
|
||||||
if (item.provider) {
|
if (item.provider) {
|
||||||
return item.provider === row.provider;
|
return item.provider === row.provider;
|
||||||
}
|
}
|
||||||
@@ -182,7 +195,7 @@ const useClusterColumns = (
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'menu.resources.gpus' }),
|
title: intl.formatMessage({ id: 'dashboard.totalgpus' }),
|
||||||
dataIndex: 'gpus',
|
dataIndex: 'gpus',
|
||||||
span: 2,
|
span: 2,
|
||||||
sorter: tableSorter(3),
|
sorter: tableSorter(3),
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ export interface ListItem extends FormData {
|
|||||||
updated_at: string;
|
updated_at: string;
|
||||||
deleted_at?: string | null;
|
deleted_at?: string | null;
|
||||||
creator_id?: number | null;
|
creator_id?: number | null;
|
||||||
|
clusterId: number;
|
||||||
status?: InstanceStatus | null;
|
status?: InstanceStatus | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user