diff --git a/.changeset/grumpy-spoons-guess.md b/.changeset/grumpy-spoons-guess.md new file mode 100644 index 0000000000..b33e19a5c0 --- /dev/null +++ b/.changeset/grumpy-spoons-guess.md @@ -0,0 +1,6 @@ +--- +"@scow/portal-web": patch +"@scow/ai": patch +--- + +xterm npm 包更名 diff --git a/.changeset/violet-deers-sniff.md b/.changeset/violet-deers-sniff.md new file mode 100644 index 0000000000..783d0f60c4 --- /dev/null +++ b/.changeset/violet-deers-sniff.md @@ -0,0 +1,7 @@ +--- +"@scow/config": patch +"@scow/lib-hook": patch +"@scow/docs": patch +--- + +支持填写多个 hook 地址 diff --git a/.changeset/yellow-kings-eat.md b/.changeset/yellow-kings-eat.md new file mode 100644 index 0000000000..d7dddf4f91 --- /dev/null +++ b/.changeset/yellow-kings-eat.md @@ -0,0 +1,5 @@ +--- +"@scow/mis-web": patch +--- + +修复了管理系统下消费记录总数金额显示错误以及翻页的问题 diff --git a/apps/ai/src/app/(auth)/jobShell/[clusterId]/[jobId]/page.tsx b/apps/ai/src/app/(auth)/jobShell/[clusterId]/[jobId]/page.tsx index 826fc05622..e98bb63e59 100644 --- a/apps/ai/src/app/(auth)/jobShell/[clusterId]/[jobId]/page.tsx +++ b/apps/ai/src/app/(auth)/jobShell/[clusterId]/[jobId]/page.tsx @@ -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"; diff --git a/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx b/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx index e3de55df28..189239d710 100644 --- a/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx +++ b/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx @@ -45,7 +45,10 @@ export const DataBarChart: React.FC = ({ xLabel = "", toolTipFormatter = (value) => value, }) => { - + const tickFormatter = (value: number) => { + const roundedValue = Number.isInteger(value) ? value : parseFloat(value.toFixed(2)); + return roundedValue.toString(); + }; return ( {isLoading ? : ( @@ -64,7 +67,7 @@ export const DataBarChart: React.FC = ({ label={{ value: xLabel, position: "insideBottom", offset: 0 }} height={40} /> - + diff --git a/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx b/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx index 2a1bb5b943..fb73d0002f 100644 --- a/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx +++ b/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx @@ -22,6 +22,7 @@ interface Props { loading: boolean icon: React.ReactNode | React.ForwardRefExoticComponent<{}>; iconColor?: string + precision?: number | undefined } const Container = styled.div` @@ -40,7 +41,8 @@ const iconToNode = (Icon: any, color?: string) => { const p = prefix("pageComp.admin.statisticCard."); -export const StatisticCard: React.FC = ({ title, newAddValue = 0, totalValue = 0, loading, icon, iconColor }) => +export const StatisticCard: React.FC = ({ title, newAddValue = 0, + totalValue = 0, loading, icon, iconColor, precision = 0 }) => { const t = useI18nTranslateToString(); @@ -52,7 +54,7 @@ export const StatisticCard: React.FC = ({ title, newAddValue = 0, totalVa @@ -63,7 +65,7 @@ export const StatisticCard: React.FC = ({ 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 }} /> diff --git a/apps/mis-web/src/pageComponents/common/PaymentTable.tsx b/apps/mis-web/src/pageComponents/common/PaymentTable.tsx index bc85dcce30..aeca298820 100644 --- a/apps/mis-web/src/pageComponents/common/PaymentTable.tsx +++ b/apps/mis-web/src/pageComponents/common/PaymentTable.tsx @@ -198,7 +198,7 @@ export const PaymentTable: React.FC = ({ accountName, searchType }) => { - {data ? data.total.toFixed(3) : 0} + {data ? data.total.toFixed(2) : 0} @@ -234,7 +234,7 @@ export const PaymentTable: React.FC = ({ accountName, searchType }) => { : undefined } formatDateTime(v)} /> - v.toFixed(3)} /> + v.toFixed(2)} /> = ({ info }) => { title={t("dashboard.account.balance")} valueStyle={{ color: minOne < 0 ? "red" : undefined }} prefix={"¥"} - value={minOne.toFixed(3)} + value={minOne.toFixed(2)} /> diff --git a/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx b/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx index 10e0a7a771..cbad1554f0 100644 --- a/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx +++ b/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx @@ -112,7 +112,7 @@ export const ChargeForm: React.FC = () => { - + = ({ return getChargesInfo; }, [query, pageInfo]); + const totalResultPromiseFn = useCallback(async () => { return await api.getChargeRecordsTotalCount({ query: { @@ -240,12 +241,12 @@ export const ChargeTable: React.FC = ({ - {recordsData ? recordsData.results.length : 0} + {totalResultData?.totalCount ?? 0} - {recordsData ? recordsData.results.reduce(((a, b) => a + b.amount), 0) : 0} + {totalResultData?.totalAmount?.toFixed(2) ?? 0} @@ -269,7 +270,7 @@ export const ChargeTable: React.FC = ({ current: pageInfo.page, pageSize: pageInfo.pageSize, defaultPageSize: DEFAULT_PAGE_SIZE, - total: recordsData ? recordsData.results.length : 0, + total: totalResultData?.totalCount ?? 0, onChange: (page, pageSize) => { // 页码切换时让页面显示的值为上一次query的查询条件 form.setFieldsValue({ @@ -299,7 +300,7 @@ export const ChargeTable: React.FC = ({ render={(_, r) => r.userId ? (`${r.userId} (${r.userName})`) : ""} /> dataIndex="time" title={t(p("time"))} render={(v) => formatDateTime(v)} /> - dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(3)} /> + dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(2)} /> dataIndex="type" title={t(pCommon("type"))} /> dataIndex="comment" diff --git a/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx b/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx index aa872d8527..d351f62d14 100644 --- a/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx +++ b/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx @@ -79,7 +79,7 @@ const EditPriceModal: React.FC ({ label: x, value: x }))} /> - + diff --git a/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx b/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx index fdf5961c32..fd54868237 100644 --- a/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx +++ b/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx @@ -276,7 +276,7 @@ const EditPriceModal: React.FC - + diff --git a/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx b/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx index cc81be3de4..cf319d6e10 100644 --- a/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx +++ b/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx @@ -134,7 +134,7 @@ export const AccountWhitelistTable: React.FC = ({ <> - {t(p("debtSum"))}:{getTotalDebtAmount(data).toFixed(3)} {t(pCommon("unit"))} + {t(p("debtSum"))}:{getTotalDebtAmount(data).toFixed(2)} {t(pCommon("unit"))} diff --git a/apps/mis-web/src/pages/accounts/[accountName]/info.tsx b/apps/mis-web/src/pages/accounts/[accountName]/info.tsx index 637ee10cf8..dc3f56b375 100644 --- a/apps/mis-web/src/pages/accounts/[accountName]/info.tsx +++ b/apps/mis-web/src/pages/accounts/[accountName]/info.tsx @@ -69,10 +69,10 @@ export const AccountInfoPage: NextPage = requireAuth( - {balance.toFixed(3)} {t("common.unit")} + {balance.toFixed(2)} {t("common.unit")} - {blockThresholdAmount.toFixed(3)} {t("common.unit")} + {blockThresholdAmount.toFixed(2)} {t("common.unit")} diff --git a/apps/mis-web/src/pages/admin/statistic.tsx b/apps/mis-web/src/pages/admin/statistic.tsx index 5db7be9187..86f43cff96 100644 --- a/apps/mis-web/src/pages/admin/statistic.tsx +++ b/apps/mis-web/src/pages/admin/statistic.tsx @@ -244,7 +244,7 @@ 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]); @@ -252,7 +252,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) return topPayAccount?.results.map((r) => ({ x: r.accountName, - y: moneyToNumber(r.payAmount), + y: moneyToNumber(r.payAmount).toFixed(2), })) || []; }, [query, topPayAccount]); @@ -383,6 +383,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) loading={totalChargeAmountLoading || dailyChargeLoading} icon={MoneyCollectOutlined} iconColor="#feca57" + precision={2} /> @@ -446,7 +447,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) ({ x: d.date.format("YYYY-MM-DD"), - y: d.count, + y: d.count.toFixed(2), }))} title={t(p("chargeAmount"))} isLoading={dailyChargeLoading} @@ -468,7 +469,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) ({ x: d.date.format("YYYY-MM-DD"), - y: d.count, + y: d.count.toFixed(2), }))} title={t(p("payAmount"))} toolTipFormatter={amountToolTipFormatter} diff --git a/apps/mis-web/src/pages/tenant/info.tsx b/apps/mis-web/src/pages/tenant/info.tsx index bc7a3a418c..b2c05771ef 100644 --- a/apps/mis-web/src/pages/tenant/info.tsx +++ b/apps/mis-web/src/pages/tenant/info.tsx @@ -87,12 +87,12 @@ export const TenantInfoPage: NextPage = requireAuth((u) => u.tenantRoles. {userCount} - {moneyToNumber(balance).toFixed(3)} {t("common.unit")} + {moneyToNumber(balance).toFixed(2)} {t("common.unit")} - {moneyToNumber(defaultAccountBlockThreshold).toFixed(3)} {t("common.unit")} + {moneyToNumber(defaultAccountBlockThreshold).toFixed(2)} {t("common.unit")} { - const client = (config && config.enabled) - ? new HookServiceClient(config.url, ChannelCredentials.createInsecure()) - : undefined; - if (config && client) { - logger.info("Hook configured to %s", config.url); + const hooks: { + name?: string; + client: HookServiceClient, + }[] = []; + + const createHook = (url: string, name?: string) => { + return { + name: name ?? url, + client: new HookServiceClient(url, ChannelCredentials.createInsecure()), + }; + }; + + if (!config) { + logger.info("Hook is not configured."); + } else if (!config.enabled) { + logger.info("Hook is explicitly disabled in config."); + } else if (config.hooks) { + for (const hook of config.hooks) { + hooks.push(createHook(hook.url, hook.name)); + } + logger.info("Hooks are configured with %d hooks", hooks.length); + } else if (config.url) { + hooks.push(createHook(config.url)); + logger.info("Hook %s is configured.", config.url); } else { - logger.info("Hook disabled"); + logger.info("No hooks or url is provided in hook config. Hook is not configured."); } return { @@ -39,28 +58,24 @@ export const createHookClient = ( eventPayload: (Event & { $case: TEventName })[TEventName], logger: Logger, ) => { - - if (!client) { + if (hooks.length === 0) { logger.debug("Attempt to call hook %s with %o", eventName, eventPayload); return; } - logger.info("Calling hook %s with %o", eventName, eventPayload); + logger.info("Calling hooks concurrently with event name %s and payload %o", eventName, eventPayload); - return await asyncUnaryCall(client, "onEvent", { - metadata: { time: new Date().toISOString() }, - // @ts-ignore - event: { $case: eventName, [eventName]: eventPayload }, - }).then( - () => { logger.debug("Hook call completed"); }, - (e) => { - logger.error(e, "Error when calling hook"); - // 如果是修改作业时限的hook,允许抛出错误 - if (eventName === "allowChangeJobTimeLimit") { - throw e; - } - }, - ); + await Promise.all(hooks.map(async (hook) => { + logger.info("Calling hook %s", hook.name); + await asyncUnaryCall(hook.client, "onEvent", { + metadata: { time: new Date().toISOString() }, + // @ts-ignore + event: { $case: eventName, [eventName]: eventPayload }, + }).then( + () => { logger.debug("Hook call completed"); }, + (e) => { logger.error(e, "Error when calling hook"); }, + ); + })); }, }; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 852bbd9c90..84a32d140d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1038,6 +1038,12 @@ importers: '@uiw/react-codemirror': specifier: 4.21.20 version: 4.21.20(@babel/runtime@7.24.4)(@codemirror/autocomplete@6.6.0)(@codemirror/language@6.10.1)(@codemirror/lint@6.0.0)(@codemirror/search@6.2.3)(@codemirror/state@6.4.0)(@codemirror/theme-one-dark@6.1.0)(@codemirror/view@6.26.1)(codemirror@6.0.1)(react-dom@18.2.0)(react@18.2.0) + '@xterm/addon-fit': + specifier: 0.10.0 + version: 0.10.0(@xterm/xterm@5.5.0) + '@xterm/xterm': + specifier: 5.5.0 + version: 5.5.0 antd: specifier: 5.16.0 version: 5.16.0(react-dom@18.2.0)(react@18.2.0) @@ -1107,12 +1113,6 @@ importers: ws: specifier: 8.16.0 version: 8.16.0 - xterm: - specifier: 5.3.0 - version: 5.3.0 - xterm-addon-fit: - specifier: 0.8.0 - version: 0.8.0(xterm@5.3.0) devDependencies: '@ddadaal/next-typed-api-routes-cli': specifier: 0.9.1