From 710669c1b1ca5247688679ae5b0233dbf3974e2c Mon Sep 17 00:00:00 2001 From: yangon <2689991790@qq.com> Date: Wed, 21 Aug 2024 15:05:22 +0800 Subject: [PATCH] dashboard 0.3.0 bugfix (#519) --- .../customModal/ModifyUnitDetailModal.tsx | 11 ++++++----- ui/src/components/customModal/ScaleModal.tsx | 5 ++--- ui/src/constants/index.ts | 4 ++-- ui/src/i18n/strings/en-US.json | 4 +++- ui/src/i18n/strings/zh-CN.json | 4 +++- ui/src/pages/Tenant/Detail/Overview/Replicas.tsx | 1 + ui/src/pages/Tenant/Detail/Overview/index.tsx | 2 +- ui/src/pages/Tenant/helper.ts | 16 +++++++--------- ui/src/services/tenant.ts | 13 ++++++++++++- 9 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ui/src/components/customModal/ModifyUnitDetailModal.tsx b/ui/src/components/customModal/ModifyUnitDetailModal.tsx index 06dadf4cc..40a045d8a 100644 --- a/ui/src/components/customModal/ModifyUnitDetailModal.tsx +++ b/ui/src/components/customModal/ModifyUnitDetailModal.tsx @@ -115,8 +115,8 @@ export default function ModifyUnitDetailModal({ newResourcePool ? 'create' : 'edit', ); const res = await obtenantPoolReq({ - ns:ns!, - name:name!, + ns: ns!, + name: name!, zoneName, ...reqData, }); @@ -158,9 +158,9 @@ export default function ModifyUnitDetailModal({ result.unitConfig = { cpuCount: zone?.minCPU, iopsWeight: zone?.iopsWeight, - logDiskSize: zone?.logDiskSize.split('Gi')[0], + logDiskSize: zone?.logDiskSize, maxIops: zone?.maxIops, - memorySize: zone?.memorySize.split('Gi')[0], + memorySize: zone?.memorySize, minIops: zone?.minIops, }; if (newResourcePool) { @@ -465,7 +465,8 @@ export default function ModifyUnitDetailModal({ () => ({ validator() { if ( - essentialParameter && selectZones.length && + essentialParameter && + selectZones.length && findMinParameter(selectZones, essentialParameter) .maxLogDisk! < minResource.minLogDisk ) { diff --git a/ui/src/components/customModal/ScaleModal.tsx b/ui/src/components/customModal/ScaleModal.tsx index 672f32ee7..289099bab 100644 --- a/ui/src/components/customModal/ScaleModal.tsx +++ b/ui/src/components/customModal/ScaleModal.tsx @@ -6,7 +6,6 @@ import { scaleObserverReportWrap } from '@/services/reportRequest/clusterReportR import { useParams } from '@umijs/max'; import { useEffect } from 'react'; - interface ScaleModalProps { params?: { zoneName?: string; @@ -59,8 +58,8 @@ export default function ScaleModal({ return ( = 4.2.3.0', + id: 'src.constants.22EDA0DC', + defaultMessage: '要求内核版本 >= 4.2.1.4 (4.2.2.x 除外)', }), }, ], diff --git a/ui/src/i18n/strings/en-US.json b/ui/src/i18n/strings/en-US.json index f719e2d40..48eb1603e 100644 --- a/ui/src/i18n/strings/en-US.json +++ b/ui/src/i18n/strings/en-US.json @@ -1138,5 +1138,7 @@ "src.pages.Alert.Shield.C4C1B8A3": "Label", "src.pages.Alert.Rules.9B28C134": "Default", "src.pages.Alert.Subscriptions.B4AB7DEF": "Create", - "src.pages.Access.B52ED09C": "Last Logon Time" + "src.pages.Access.B52ED09C": "Last login time", + "src.constants.22EDA0DC": "Requires kernel version> = 4.2.1.4 (except 4.2.2.x)", + "src.components.customModal.F7DD1D45": "Scaling Zone" } diff --git a/ui/src/i18n/strings/zh-CN.json b/ui/src/i18n/strings/zh-CN.json index ec7b3ea0a..0db28080b 100644 --- a/ui/src/i18n/strings/zh-CN.json +++ b/ui/src/i18n/strings/zh-CN.json @@ -1137,5 +1137,7 @@ "src.components.customModal.E903F734": "请输入", "src.api.855C826A": "原密码输入不正确", "src.api.1717A275": "无权限访问", - "src.pages.Access.B52ED09C": "最后一次登录时间" + "src.pages.Access.B52ED09C": "最后一次登录时间", + "src.constants.22EDA0DC": "要求内核版本 >= 4.2.1.4 (4.2.2.x 除外)", + "src.components.customModal.F7DD1D45": "扩缩容Zone" } \ No newline at end of file diff --git a/ui/src/pages/Tenant/Detail/Overview/Replicas.tsx b/ui/src/pages/Tenant/Detail/Overview/Replicas.tsx index 0b2123441..2c5537460 100644 --- a/ui/src/pages/Tenant/Detail/Overview/Replicas.tsx +++ b/ui/src/pages/Tenant/Detail/Overview/Replicas.tsx @@ -182,6 +182,7 @@ export default function Replicas({ {sortKeys(Object.keys(replica)).map((key, idx) => ( {replica[key]} + {key === 'memorySize' || key === 'logDiskSize' ? 'Gi' : null} ))} diff --git a/ui/src/pages/Tenant/Detail/Overview/index.tsx b/ui/src/pages/Tenant/Detail/Overview/index.tsx index 11a3b6cb0..34dac8e52 100644 --- a/ui/src/pages/Tenant/Detail/Overview/index.tsx +++ b/ui/src/pages/Tenant/Detail/Overview/index.tsx @@ -211,7 +211,7 @@ export default function TenantOverview() { const operateSuccess = () => { setTimeout(() => { - getTenantDetail({ ns, name }); + getTenantDetail({ ns:ns!, name:name! }); }, 1000); }; const header = () => { diff --git a/ui/src/pages/Tenant/helper.ts b/ui/src/pages/Tenant/helper.ts index 6cf20c2cb..47b7767e2 100644 --- a/ui/src/pages/Tenant/helper.ts +++ b/ui/src/pages/Tenant/helper.ts @@ -1,6 +1,6 @@ import { encryptText } from '@/hook/usePublicKey'; import dayjs from 'dayjs'; -import { clone,cloneDeep } from 'lodash'; +import { clone, cloneDeep } from 'lodash'; const isExist = (val: string | number | undefined): boolean => { if (typeof val === 'number') return true; @@ -180,9 +180,9 @@ export function checkIsSame( } /** - * The minimum value of available resources in the currently selected zone + * The minimum value of available resources in the currently selected zone * is the maximum value that can be entered in the input box. - * + * * The reason is to ensure that the input resource specifications can be created by each zone */ export function findMinParameter( @@ -307,12 +307,10 @@ export const getOriginResourceUsages = ( originResourceUsages.obZoneResourceMap[key].availableCPU += Number( current.minCPU, ); - originResourceUsages.obZoneResourceMap[key].availableLogDisk += Number( - current.logDiskSize.split('Gi')[0], - ); - originResourceUsages.obZoneResourceMap[key].availableMemory += Number( - current.memorySize.split('Gi')[0], - ); + originResourceUsages.obZoneResourceMap[key].availableLogDisk += + current.logDiskSize; + originResourceUsages.obZoneResourceMap[key].availableMemory += + current.memorySize; } }); return originResourceUsages; diff --git a/ui/src/services/tenant.ts b/ui/src/services/tenant.ts index cd57e3108..61272ee6b 100644 --- a/ui/src/services/tenant.ts +++ b/ui/src/services/tenant.ts @@ -1,4 +1,8 @@ -import { formatStatisticData, getInitialObjOfKeys } from '@/utils/helper'; +import { + floorToTwoDecimalPlaces, + formatStatisticData, + getInitialObjOfKeys, +} from '@/utils/helper'; import { request } from '@umijs/max'; const tenantPrefix = '/api/v1/obtenants'; @@ -57,6 +61,13 @@ export async function getTenant({ if (r.data.restoreSource?.until) res.source!.until = r.data.restoreSource.until; + const formatResourceAttr = ['logDiskSize', 'memorySize']; + r.data.topology.forEach((item) => { + for (const attr of formatResourceAttr) { + item[attr] = floorToTwoDecimalPlaces(item[attr] / (1 << 30)); + } + }); + res.replicas = r.data.topology; return { ...r,