Skip to content

Commit

Permalink
dashboard 0.3.0 bugfix (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 authored Aug 21, 2024
1 parent 4b195c2 commit 710669c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 23 deletions.
11 changes: 6 additions & 5 deletions ui/src/components/customModal/ModifyUnitDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -465,7 +465,8 @@ export default function ModifyUnitDetailModal({
() => ({
validator() {
if (
essentialParameter && selectZones.length &&
essentialParameter &&
selectZones.length &&
findMinParameter(selectZones, essentialParameter)
.maxLogDisk! < minResource.minLogDisk
) {
Expand Down
5 changes: 2 additions & 3 deletions ui/src/components/customModal/ScaleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { scaleObserverReportWrap } from '@/services/reportRequest/clusterReportR
import { useParams } from '@umijs/max';
import { useEffect } from 'react';


interface ScaleModalProps {
params?: {
zoneName?: string;
Expand Down Expand Up @@ -59,8 +58,8 @@ export default function ScaleModal({
return (
<CustomModal
title={intl.formatMessage({
id: 'OBDashboard.components.customModal.ScaleModal.ExpandZone',
defaultMessage: '扩容Zone',
id: 'src.components.customModal.F7DD1D45',
defaultMessage: '扩缩容Zone',
})}
isOpen={visible}
handleOk={handleSubmit}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ const MODE_MAP = new Map([
defaultMessage: 'Service模式',
}),
limit: intl.formatMessage({
id: 'Dashboard.src.constants.RequiredKernelVersion.1',
defaultMessage: '要求内核版本 >= 4.2.3.0',
id: 'src.constants.22EDA0DC',
defaultMessage: '要求内核版本 >= 4.2.1.4 (4.2.2.x 除外)',
}),
},
],
Expand Down
4 changes: 3 additions & 1 deletion ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions ui/src/pages/Tenant/Detail/Overview/Replicas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export default function Replicas({
{sortKeys(Object.keys(replica)).map((key, idx) => (
<Descriptions.Item label={LABEL_TEXT_MAP[key] || key} key={idx}>
{replica[key]}
{key === 'memorySize' || key === 'logDiskSize' ? 'Gi' : null}
</Descriptions.Item>
))}
</Descriptions>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Tenant/Detail/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default function TenantOverview() {

const operateSuccess = () => {
setTimeout(() => {
getTenantDetail({ ns, name });
getTenantDetail({ ns:ns!, name:name! });
}, 1000);
};
const header = () => {
Expand Down
16 changes: 7 additions & 9 deletions ui/src/pages/Tenant/helper.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion ui/src/services/tenant.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 710669c

Please sign in to comment.