Skip to content

Commit

Permalink
merge master, resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
piccaSun committed May 8, 2024
2 parents 497fdde + 37fdf7e commit 0f2d2f8
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .changeset/grumpy-spoons-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@scow/portal-web": patch
"@scow/ai": patch
---

xterm npm 包更名
9 changes: 9 additions & 0 deletions .changeset/spotty-wombats-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@scow/portal-web": patch
"@scow/demo-vagrant": patch
"@scow/mis-web": patch
"@scow/auth": patch
"@scow/ai": patch
---

修改了 portal 中的部分 UI 样式,bannerTop 导航文字
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

"use client";

import "xterm/css/xterm.css";
import "@xterm/xterm/css/xterm.css";

import { Button, Space } from "antd";
import dynamic from "next/dynamic";
Expand Down
2 changes: 1 addition & 1 deletion apps/ai/src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function Layout(
icon={<DesktopOutlined style={{ paddingRight: 2 }} />}
link={publicConfig.PORTAL_URL}
// linkText={t("baseLayout.linkTextAI")}
linkText="SCOW HPC"
linkText="HPC"
/>
{/* {
systemLanguageConfig.isUsingI18n ? (
Expand Down
2 changes: 1 addition & 1 deletion apps/mis-web/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default {
operationLog: "Operation Log",
statistic: "Statistic",
},
navLinkTextPortal: "SCOW HPC",
navLinkTextPortal: "HPC",
navLinkTextAI: "SCOW AI",
dashboard: "Dashboard",
user: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mis-web/src/i18n/zh_cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default {
operationLog:"操作日志",
statistic: "平台数据统计",
},
navLinkTextPortal: "SCOW HPC",
navLinkTextPortal: "超算平台",
navLinkTextAI: "SCOW AI",
dashboard: "仪表盘",
user: {
Expand Down
7 changes: 5 additions & 2 deletions apps/mis-web/src/pageComponents/admin/DataBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export const DataBarChart: React.FC<Props> = ({
xLabel = "",
toolTipFormatter = (value) => value,
}) => {

const tickFormatter = (value: number) => {
const roundedValue = Number.isInteger(value) ? value : parseFloat(value.toFixed(2));
return roundedValue.toString();
};
return (
<StatisticContainer>
{isLoading ? <Spin /> : (
Expand All @@ -64,7 +67,7 @@ export const DataBarChart: React.FC<Props> = ({
label={{ value: xLabel, position: "insideBottom", offset: 0 }}
height={40}
/>
<YAxis padding={{ top: 20 }} />
<YAxis padding={{ top: 20 }} tickFormatter={tickFormatter} />
<Tooltip
formatter={toolTipFormatter}
/>
Expand Down
8 changes: 5 additions & 3 deletions apps/mis-web/src/pageComponents/admin/StatisticCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Props {
loading: boolean
icon: React.ReactNode | React.ForwardRefExoticComponent<{}>;
iconColor?: string
precision?: number | undefined
}

const Container = styled.div`
Expand All @@ -40,7 +41,8 @@ const iconToNode = (Icon: any, color?: string) => {

const p = prefix("pageComp.admin.statisticCard.");

export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalValue = 0, loading, icon, iconColor }) =>
export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0,
totalValue = 0, loading, icon, iconColor, precision = 0 }) =>
{
const t = useI18nTranslateToString();

Expand All @@ -52,7 +54,7 @@ export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalVa
<Statistic
title={title}
value={newAddValue}
precision={0}
precision={precision}
loading={loading}
valueStyle={{ color: "#94070A" }}
/>
Expand All @@ -63,7 +65,7 @@ export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalVa
title={`${t(p("total"))}${title}: `}
value={totalValue}
loading={loading}
precision={0}
precision={precision}
valueStyle={{ color: "grey", marginLeft: "10px", fontSize: 14, marginBottom: 4 }}
/>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pageComponents/common/PaymentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const PaymentTable: React.FC<Props> = ({ accountName, searchType }) => {
</Form.Item>
<Form.Item label={t(p("sum"))}>
<strong>
{data ? data.total.toFixed(3) : 0}
{data ? data.total.toFixed(2) : 0}
</strong>
</Form.Item>
<Form.Item>
Expand Down Expand Up @@ -234,7 +234,7 @@ export const PaymentTable: React.FC<Props> = ({ accountName, searchType }) => {
: undefined
}
<Table.Column dataIndex="time" title={t(p("paymentDate"))} width="13.5%" render={(v) => formatDateTime(v)} />
<Table.Column dataIndex="amount" title={t(p("paymentAmount"))} width="10%" render={(v) => v.toFixed(3)} />
<Table.Column dataIndex="amount" title={t(p("paymentAmount"))} width="10%" render={(v) => v.toFixed(2)} />
<Table.Column
dataIndex="type"
title={t(pCommon("type"))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const AccountInfoSection: React.FC<Props> = ({ info }) => {
title={t("dashboard.account.balance")}
valueStyle={{ color: minOne < 0 ? "red" : undefined }}
prefix={"¥"}
value={minOne.toFixed(3)}
value={minOne.toFixed(2)}
/>
</Row>
</StatCard>
Expand Down
2 changes: 1 addition & 1 deletion apps/mis-web/src/pageComponents/finance/ChargeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ChargeForm: React.FC = () => {
<Input />
</Form.Item>
<Form.Item name="amount" label={t(pCommon("amount"))} rules={[{ required: true }]}>
<InputNumber step={0.01} addonAfter={t(pCommon("unit"))} />
<InputNumber step={0.01} addonAfter={t(pCommon("unit"))} precision={2} />
</Form.Item>
<Form.Item
name="type"
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pageComponents/finance/ChargeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const ChargeTable: React.FC<Props> = ({
</Form.Item>
<Form.Item label={t(pCommon("sum"))}>
<strong>
{totalResultData?.totalAmount ?? 0}
{totalResultData?.totalAmount?.toFixed(2) ?? 0}
</strong>
</Form.Item>
<Form.Item>
Expand Down Expand Up @@ -300,7 +300,7 @@ export const ChargeTable: React.FC<Props> = ({
render={(_, r) => r.userId ? (`${r.userId} (${r.userName})`) : ""}
/>
<Table.Column<ChargeInfo> dataIndex="time" title={t(p("time"))} render={(v) => formatDateTime(v)} />
<Table.Column<ChargeInfo> dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(3)} />
<Table.Column<ChargeInfo> dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(2)} />
<Table.Column<ChargeInfo> dataIndex="type" title={t(pCommon("type"))} />
<Table.Column<ChargeInfo>
dataIndex="comment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const EditPriceModal: React.FC<CommonModalProps & {
<Select options={Object.values(AmountStrategy).map((x) => ({ label: x, value: x }))} />
</Form.Item>
<Form.Item label={t(p("price"))} name="price" rules={[{ required: true }]}>
<InputNumber precision={3} min={0} />
<InputNumber precision={2} min={0} />
</Form.Item>
<Form.Item label={t(pCommon("comment"))} name="description">
<Input />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const EditPriceModal: React.FC<CommonModalProps & {
/>
</Form.Item>
<Form.Item label={t(p("price"))} name="price" initialValue={0} rules={[{ required: true }]}>
<InputNumber precision={3} min={0} />
<InputNumber precision={2} min={0} />
</Form.Item>
<Form.Item label={t(pCommon("comment"))} name="description">
<Input />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const AccountWhitelistTable: React.FC<Props> = ({
<>
<Divider type="vertical" />
<span>
{t(p("debtSum"))}<strong>{getTotalDebtAmount(data).toFixed(3)} {t(pCommon("unit"))}</strong>
{t(p("debtSum"))}<strong>{getTotalDebtAmount(data).toFixed(2)} {t(pCommon("unit"))}</strong>
</span>
</>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pages/accounts/[accountName]/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export const AccountInfoPage: NextPage<Props> = requireAuth(
</Tag>
</Descriptions.Item>
<Descriptions.Item label={t("common.accountBalance")}>
{balance.toFixed(3)} {t("common.unit")}
{balance.toFixed(2)} {t("common.unit")}
</Descriptions.Item>
<Descriptions.Item label={t("common.blockThresholdAmount")}>
{blockThresholdAmount.toFixed(3)} {t("common.unit")}
{blockThresholdAmount.toFixed(2)} {t("common.unit")}
</Descriptions.Item>
</Descriptions>

Expand Down
9 changes: 5 additions & 4 deletions apps/mis-web/src/pages/admin/statistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))

return topChargeAccount?.results.map((r) => ({
x: r.accountName,
y: moneyToNumber(r.chargedAmount),
y: moneyToNumber(r.chargedAmount).toFixed(2),
})) || [];
}, [query, topChargeAccount]);

const topPayAccountData = useMemo(() => {

return topPayAccount?.results.map((r) => ({
x: r.accountName,
y: moneyToNumber(r.payAmount),
y: moneyToNumber(r.payAmount).toFixed(2),
})) || [];
}, [query, topPayAccount]);

Expand Down Expand Up @@ -383,6 +383,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
loading={totalChargeAmountLoading || dailyChargeLoading}
icon={MoneyCollectOutlined}
iconColor="#feca57"
precision={2}
/>
</Col>
<Col span={24}>
Expand Down Expand Up @@ -446,7 +447,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
<DataLineChart
data={dailyChargeData.map((d) => ({
x: d.date.format("YYYY-MM-DD"),
y: d.count,
y: d.count.toFixed(2),
}))}
title={t(p("chargeAmount"))}
isLoading={dailyChargeLoading}
Expand All @@ -468,7 +469,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
<DataLineChart
data={dailyPayData.map((d) => ({
x: d.date.format("YYYY-MM-DD"),
y: d.count,
y: d.count.toFixed(2),
}))}
title={t(p("payAmount"))}
toolTipFormatter={amountToolTipFormatter}
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pages/tenant/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export const TenantInfoPage: NextPage<Props> = requireAuth((u) => u.tenantRoles.
{userCount}
</Descriptions.Item>
<Descriptions.Item label={t("common.tenantBalance")}>
{moneyToNumber(balance).toFixed(3)} {t("common.unit")}
{moneyToNumber(balance).toFixed(2)} {t("common.unit")}
</Descriptions.Item>
<Descriptions.Item label={t("common.defaultAccountBlockThreshold")}>
<Space>
<span>
{moneyToNumber(defaultAccountBlockThreshold).toFixed(3)} {t("common.unit")}
{moneyToNumber(defaultAccountBlockThreshold).toFixed(2)} {t("common.unit")}
</span>
<ChangeDefaultAccountBlockThresholdLink
tenantName={tenantName}
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/utils/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { moneyToNumber } from "@scow/lib-decimal";
import type { Money } from "@scow/protos/build/common/money";

export function moneyToString(money: Money) {
return moneyToNumber(money).toFixed(3);
return moneyToNumber(money).toFixed(2);
}

export function nullableMoneyToString(money: Money | undefined) {
return money ? moneyToString(money) : Number.prototype.toFixed.call(0, 3);
return money ? moneyToString(money) : Number.prototype.toFixed.call(0, 2);
}
4 changes: 2 additions & 2 deletions apps/portal-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"tslib": "2.6.2",
"typescript": "5.4.3",
"ws": "8.16.0",
"xterm": "5.3.0",
"xterm-addon-fit": "0.8.0"
"@xterm/xterm": "5.5.0",
"@xterm/addon-fit": "0.10.0"
},
"devDependencies": {
"@ddadaal/next-typed-api-routes-cli": "0.9.1",
Expand Down
35 changes: 29 additions & 6 deletions apps/portal-web/src/pageComponents/dashboard/OverviewTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ export const OverviewTable: React.FC<Props> = ({ clusterInfo, failedClusters, is

const selectItem = useMemo(() => clusterInfo[selectId], [clusterInfo, selectId]);

// 定义一个函数来获取颜色,根据给定的使用率
const getColorByUsage = (usage: number) => {
if (usage >= 90) return "red";
if (usage >= 70) return "orange";
return "green";
};

return (
(isLoading || clusterInfo.length > 0) ? (
<Container>
Expand All @@ -118,7 +125,6 @@ export const OverviewTable: React.FC<Props> = ({ clusterInfo, failedClusters, is
};
}}
>

<Table.Column<TableProps>
dataIndex="clusterName"
width="15%"
Expand All @@ -145,19 +151,37 @@ export const OverviewTable: React.FC<Props> = ({ clusterInfo, failedClusters, is
title={t(p("usageRatePercentage"))}
sorter={(a, b, sortOrder) =>
compareWithUndefined(a.info?.usageRatePercentage, b.info?.usageRatePercentage, sortOrder)}
render={(_, r) => r.info?.usageRatePercentage !== undefined ? r.info?.usageRatePercentage + "%" : "-"}
render={(_, r) => (
<span style={{ color: r.info?.usageRatePercentage ?
getColorByUsage(r.info?.usageRatePercentage) : "black" }}
>
{r.info?.usageRatePercentage ? `${r.info.usageRatePercentage}%` : "-"}
</span>
)}
/>
<Table.Column<TableProps>
dataIndex="cpuUsage"
title={t(p("cpuUsage"))}
sorter={(a, b, sortOrder) => compareWithUndefined(a.info?.cpuUsage, b.info?.cpuUsage, sortOrder)}
render={(_, r) => r.info?.cpuUsage !== undefined ? r.info?.cpuUsage + "%" : "-"}
render={(_, r) => (
<span style={{ color: r.info?.cpuUsage ?
getColorByUsage(Number(r.info?.cpuUsage)) : "black" }}
>
{r.info?.cpuUsage !== undefined ? Number(r.info?.cpuUsage).toFixed(2) + "%" : "-"}
</span>
)}
/>
<Table.Column<TableProps>
dataIndex="gpuUsage"
title={t(p("gpuUsage"))}
sorter={(a, b, sortOrder) => compareWithUndefined(a.info?.gpuUsage, b.info?.gpuUsage, sortOrder) }
render={(_, r) => r.info?.gpuUsage !== undefined ? r.info?.gpuUsage + "%" : "-" }
render={(_, r) => (
<span style={{ color: r.info?.gpuUsage ?
getColorByUsage(Number(r.info?.gpuUsage)) : "black" }}
>
{r.info?.gpuUsage !== undefined ? Number(r.info?.gpuUsage).toFixed(2) + "%" : "-"}
</span>
)}
/>
<Table.Column<TableProps>
dataIndex="pendingJobCount"
Expand All @@ -176,10 +200,9 @@ export const OverviewTable: React.FC<Props> = ({ clusterInfo, failedClusters, is
}
/>
</Table>

<InfoPanes selectItem={selectItem ?? {}} loading={isLoading} />

</Container>

) : (
<DashboardSection
style={{ marginBottom: "16px" }}
Expand Down
4 changes: 2 additions & 2 deletions apps/portal-web/src/pageComponents/shell/Shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
*/

import { debounce } from "@scow/lib-web/build/utils/debounce";
import { FitAddon } from "@xterm/addon-fit";
import { Terminal } from "@xterm/xterm";
import { join } from "path";
import { useEffect, useRef } from "react";
import { urlToDownload } from "src/pageComponents/filemanager/api";
import { ShellInputData, ShellOutputData } from "src/server/setup/shell";
import { User } from "src/stores/UserStore";
import { publicConfig } from "src/utils/config";
import { styled } from "styled-components";
import { Terminal } from "xterm";
import { FitAddon } from "xterm-addon-fit";

const TerminalContainer = styled.div`
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details.
*/

import "xterm/css/xterm.css";
import "@xterm/xterm/css/xterm.css";

import { getI18nConfigCurrentText } from "@scow/lib-web/build/utils/systemLanguage";
import { Button, Popover, Space, Typography } from "antd";
Expand Down
Loading

0 comments on commit 0f2d2f8

Please sign in to comment.