Skip to content

Commit

Permalink
fix(portal-web): 仪表盘处集群无法获取运行时不报500的错误提示和快捷方式跳转去掉basePath (#1095)
Browse files Browse the repository at this point in the history
## 说明:

![image](https://github.com/PKUHPC/SCOW/assets/74037789/9b8e501f-2da8-4cdb-bdcb-cea75d7d6046)
### CPU和GPU的利用率的保留两位小数
### 还有快捷方式跳转去掉basePath,不然url会多出basePath,与期望不符
  • Loading branch information
OYX-1 committed Jan 29, 2024
1 parent a41c45b commit f126469
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-walls-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/portal-web": patch
---

仪表盘处集群无法获取运行时不报 500 的错误提示和快捷方式跳转去掉 basePath
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { styled } from "styled-components";
export interface ClusterInfo extends PartitionInfo {
id: number;
clusterName: I18nStringType | undefined;
cpuUsage: number;
gpuUsage?: number;
cpuUsage: string;
gpuUsage?: string;
}

interface Props {
Expand All @@ -38,8 +38,8 @@ interface InfoProps {
partitionName: string;
nodeCount: number;
pendingJobCount: number;
cpuUsage: number;
gpuUsage?: number;
cpuUsage: string;
gpuUsage?: string;
usageRatePercentage: number;
partitionStatus: PartitionInfo_PartitionStatus;
}
Expand Down
7 changes: 3 additions & 4 deletions apps/portal-web/src/pageComponents/dashboard/Sortable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { join } from "path";
import { FC, useCallback, useEffect, useMemo, useState } from "react";
import { api } from "src/apis";
import { prefix, useI18n, useI18nTranslateToString } from "src/i18n";
import { publicConfig } from "src/utils/config";
import { formatEntryId, getEntryClusterName, getEntryIcon, getEntryLogoPath, getEntryName } from "src/utils/dashboard";
import { styled } from "styled-components";

Expand Down Expand Up @@ -173,16 +172,16 @@ export const Sortable: FC<Props> = ({ isEditable, isFinished, quickEntryArray, a
if (!isEditable) {
switch (item.entry?.$case) {
case "pageLink":
router.push(join(publicConfig.BASE_PATH, item.entry.pageLink.path));
router.push(item.entry.pageLink.path);
break;

case "shell":
router.push(join(publicConfig.BASE_PATH, "/shell", item.entry.shell.clusterId, item.entry.shell.loginNode));
router.push(join("/shell", item.entry.shell.clusterId, item.entry.shell.loginNode));
break;

case "app":
router.push(
join(publicConfig.BASE_PATH, "/apps", item.entry.app.clusterId, "/create", item.id.split("-")[0]));
join("/apps", item.entry.app.clusterId, "/create", item.id.split("-")[0]));
break;

default:
Expand Down
8 changes: 5 additions & 3 deletions apps/portal-web/src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ export const DashboardPage: NextPage<Props> = requireAuth(() => true)(() => {

const { data, isLoading } = useAsync({
promiseFn: useCallback(async () => {

const clusters = publicConfig.CLUSTERS;

const rawClusterInfoPromises = clusters.map((x) =>
api.getClusterRunningInfo({ query: { clusterId: x.id } }),
api.getClusterRunningInfo({ query: { clusterId: x.id } })
.httpError(500, () => {}),
);

const rawClusterInfoResults = await Promise.allSettled(rawClusterInfoPromises);
Expand All @@ -73,9 +75,9 @@ export const DashboardPage: NextPage<Props> = requireAuth(() => true)(() => {
cluster.clusterInfo.partitions.map((x) => ({
clusterName: cluster.clusterInfo.clusterName,
...x,
cpuUsage:x.runningCpuCount / x.cpuCoreCount,
cpuUsage:(x.runningCpuCount / x.cpuCoreCount).toFixed(2),
// 有些分区没有gpu就为空,前端显示'-'
...x.gpuCoreCount ? { gpuUsage:x.runningGpuCount / x.gpuCoreCount } : {},
...x.gpuCoreCount ? { gpuUsage:(x.runningGpuCount / x.gpuCoreCount).toFixed(2) } : {},
})),
);

Expand Down

0 comments on commit f126469

Please sign in to comment.