From 83f7f5468b3528ffe03d49a46ff4710235643654 Mon Sep 17 00:00:00 2001 From: GraceWalk Date: Tue, 13 Sep 2022 14:30:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9D=87=E8=A1=A1=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=A0=B7=E5=BC=8F=E9=87=8D=E6=9E=84=20&=20?= =?UTF-8?q?=E5=91=A8=E6=9C=9F=E5=9D=87=E8=A1=A1=E5=9C=BA=E6=99=AF=E5=8C=96?= =?UTF-8?q?=20&=20=E7=AB=8B=E5=8D=B3=E5=9D=87=E8=A1=A1=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=B8=A6=E5=85=A5=E5=91=A8=E6=9C=9F=E5=9D=87=E8=A1=A1=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Jobs/RebalancePlan.tsx | 6 +- .../src/pages/LoadRebalance/BalanceDrawer.tsx | 71 ++++++++++++------- .../src/pages/LoadRebalance/HistoryDrawer.tsx | 47 ++++++++++-- .../src/pages/LoadRebalance/index.less | 16 +++++ .../src/pages/LoadRebalance/index.tsx | 43 +++++------ 5 files changed, 126 insertions(+), 57 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/Jobs/RebalancePlan.tsx b/km-console/packages/layout-clusters-fe/src/pages/Jobs/RebalancePlan.tsx index 332448c9..4b11b2e7 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Jobs/RebalancePlan.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Jobs/RebalancePlan.tsx @@ -237,12 +237,12 @@ const RebalancePlan = (props: PropsType) => { {data?.replicas || '-'} - + {data?.clusterBalanceIntervalList ? data?.clusterBalanceIntervalList?.map((item: any) => { return ( - - {item.type + ':' + item.intervalPercent + '%'} + + {item.type?.slice(0, 1).toUpperCase() + item.type?.slice(1) + ':' + ' ±' + item.intervalPercent + '%'} ); }) diff --git a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/BalanceDrawer.tsx b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/BalanceDrawer.tsx index 9ed49ebf..207e3e30 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/BalanceDrawer.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/BalanceDrawer.tsx @@ -168,7 +168,6 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false, const init = () => { if (formData && Object.keys(formData).length > 0) { - console.log(formData, '有FormData'); const tableData = formData?.clusterBalanceIntervalList?.map((item: any) => { const finfIndex = BalancedDimensions.findIndex((item1) => item1?.value === item?.type); return { @@ -201,7 +200,6 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false, priority: index + 1, }; }); - console.log(res, '表单回显立即均衡'); setTableData(res); setDimension(['disk', 'bytesIn', 'bytesOut']); setNodeTargetKeys([]); @@ -220,14 +218,12 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false, throttleUnitB: values?.throttleUnitM * 1024 * 1024, }; - if (!isCycle) { - if (values?.priority === 'throughput') { - params.parallelNum = 0; - params.executionStrategy = 1; - } else if (values?.priority === 'stability') { - params.parallelNum = 1; - params.executionStrategy = 2; - } + if (values?.priority === 'throughput') { + params.parallelNum = 0; + params.executionStrategy = 1; + } else if (values?.priority === 'stability') { + params.parallelNum = 1; + params.executionStrategy = 2; } if (formData?.jobId) { @@ -382,6 +378,8 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false, const drawerClose = (isArg?: boolean) => { isArg ? onClose(isArg) : onClose(); + setParallelNum(0); + setExecutionStrategy(1); form.resetFields(); }; @@ -540,17 +538,38 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false,
运行配置
- {!isCycle && ( - - - 吞吐量优先 - 稳定性优先 - 自定义 - + {isCycle && ( + { + const valArr = value.split(' '); + if (valArr[1] === '*' || valArr[2] === '*') { + return Promise.reject(new Error('任务周期必须指定分钟、小时')); + } + return Promise.resolve(); + }, + }, + ]} + > + )} - - {!isCycle && ( + + + 吞吐量优先 + 稳定性优先 + 自定义 + + + { {({ getFieldValue }) => getFieldValue('priority') === 'custom' ? ( @@ -600,9 +619,9 @@ const BalanceDrawer: React.FC = ({ onClose, visible, isCycle = false, ) : null } - )} + } - {isCycle && ( + {/* {isCycle && ( = ({ onClose, visible, isCycle = false, > - )} + )} */} - {isCycle && ( + {/* {isCycle && ( = ({ onClose, visible, isCycle = false, > - )} + )} */} - {isCycle && ( + {/* {isCycle && ( = ({ onClose, visible, isCycle = false, 优先最小副本 - )} + )} */} = ({ onClose, visible }) => { // } // }, { - title: 'Disk均衡率', + title: ( + + Disk{'(已均衡丨未均衡)'} + + ), dataIndex: 'disk', render: (text: any, row: any) => { - return `${row?.sub?.disk?.successNu} (已均衡) / ${row?.sub?.disk?.failedNu} (未均衡)`; + // return `${row?.sub?.disk?.successNu} 丨 ${row?.sub?.disk?.failedNu}`; + return ( +
+ {row?.sub?.disk?.successNu} + + {row?.sub?.disk?.failedNu} +
+ ); }, }, { - title: 'BytesIn均衡率', + title: ( + + BytesIn{'(已均衡丨未均衡)'} + + ), dataIndex: 'bytesIn', render: (text: any, row: any) => { - return `${row?.sub?.bytesIn?.successNu} (已均衡) / ${row?.sub?.bytesIn?.failedNu} (未均衡)`; + // return `${row?.sub?.bytesIn?.successNu} 丨 ${row?.sub?.bytesIn?.failedNu}`; + return ( +
+ {row?.sub?.bytesIn?.successNu} + + {row?.sub?.bytesIn?.failedNu} +
+ ); }, }, { - title: 'BytesOut均衡率', + title: ( + + BytesOut{'(已均衡丨未均衡)'} + + ), dataIndex: 'bytesOut', render: (text: any, row: any) => { - return `${row?.sub?.bytesOut?.successNu} (已均衡) / ${row?.sub?.bytesOut?.failedNu} (未均衡)`; + // return `${row?.sub?.bytesOut?.successNu} 丨 ${row?.sub?.bytesOut?.failedNu}`; + return ( +
+ {row?.sub?.bytesOut?.successNu} + + {row?.sub?.bytesOut?.failedNu} +
+ ); }, }, { @@ -124,7 +157,7 @@ const HistoryDrawer: React.FC = ({ onClose, visible }) => { }; const onTableChange = (curPagination: any) => { - getList({ page: curPagination.current, size: curPagination.pageSize }); + getList({ pageNo: curPagination.current, pageSize: curPagination.pageSize }); }; return ( diff --git a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.less b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.less index 927a069f..648346c9 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.less +++ b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.less @@ -143,3 +143,19 @@ // margin: 0 !important; // } } + +.balance-history-column{ + display: flex; + &>span:nth-child(1){ + width: 20px; + } + &>span:nth-child(2){ + color: #74788d; + font-size: 12px; + opacity: 0.3; + } + &>span:last-child{ + width: 20px; + margin-left: 8px; + } +} diff --git a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.tsx index cc0a6c02..2ff2b960 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.tsx @@ -8,6 +8,7 @@ import api from '../../api'; import './index.less'; import LoadRebalanceCardBar from '@src/components/CardBar/LoadRebalanceCardBar'; import { BalanceFilter } from './BalanceFilter'; +import { ClustersPermissionMap } from '../CommonConfig'; const Balance_Status_OPTIONS = [ { @@ -288,21 +289,17 @@ const LoadBalance: React.FC = (props: any) => { setVisible(false); }; - const balanceClick = (val: boolean = false) => { - if (val) { - Utils.request(api.getBalanceForm(global?.clusterInfo?.id), { - method: 'GET', + const balanceClick = (val: boolean) => { + Utils.request(api.getBalanceForm(global?.clusterInfo?.id), { + method: 'GET', + }) + .then((res: any) => { + const dataDe = res || {}; + setCircleFormData(dataDe); }) - .then((res: any) => { - const dataDe = res || {}; - setCircleFormData(dataDe); - }) - .catch(() => { - setCircleFormData(null); - }); - } else { - setCircleFormData(null); - } + .catch(() => { + setCircleFormData(null); + }); setIsCycle(val); setVisible(true); }; @@ -365,19 +362,23 @@ const LoadBalance: React.FC = (props: any) => { value: searchValue, onChange: setSearchValue, placeholder: '请输入 Host', - style: { width: '210px' }, + style: { width: '248px' }, maxLength: 128, }} /> - - + {global.hasPermission(ClustersPermissionMap.REBALANCE_CYCLE) && ( + + )} + {global.hasPermission(ClustersPermissionMap.REBALANCE_IMMEDIATE) && ( + + )} {filterList && filterList.length > 0 && (