Skip to content

Commit

Permalink
Merge branch 'master' into feat-add-hook-job-time-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tongchong committed May 7, 2024
2 parents 4c92053 + 5a8a09a commit 29199d6
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 66 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 包更名
7 changes: 7 additions & 0 deletions .changeset/violet-deers-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@scow/config": patch
"@scow/lib-hook": patch
"@scow/docs": patch
---

支持填写多个 hook 地址
5 changes: 5 additions & 0 deletions .changeset/yellow-kings-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/mis-web": patch
---

修复了管理系统下消费记录总数金额显示错误以及翻页的问题
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
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
9 changes: 5 additions & 4 deletions apps/mis-web/src/pageComponents/finance/ChargeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const ChargeTable: React.FC<Props> = ({
return getChargesInfo;
}, [query, pageInfo]);


const totalResultPromiseFn = useCallback(async () => {
return await api.getChargeRecordsTotalCount({
query: {
Expand Down Expand Up @@ -240,12 +241,12 @@ export const ChargeTable: React.FC<Props> = ({
</Form.Item>
<Form.Item label={t("common.total")}>
<strong>
{recordsData ? recordsData.results.length : 0}
{totalResultData?.totalCount ?? 0}
</strong>
</Form.Item>
<Form.Item label={t(pCommon("sum"))}>
<strong>
{recordsData ? recordsData.results.reduce(((a, b) => a + b.amount), 0) : 0}
{totalResultData?.totalAmount?.toFixed(2) ?? 0}
</strong>
</Form.Item>
<Form.Item>
Expand All @@ -269,7 +270,7 @@ export const ChargeTable: React.FC<Props> = ({
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({
Expand Down Expand Up @@ -299,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
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
2 changes: 1 addition & 1 deletion dev/test-adapter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the Mulan PSL v2 for more details.


FROM node:iron-alpine@sha256:5cf32127b55467ea639dc805a13c6f51b2facebc5eb11f9c5d49e3059f3c0aa4 AS base
FROM node:iron-alpine@sha256:e18f74fc454fddd8bf66f5c632dfc78a32d8c2737d1ba4e028ee60cfc6f95a9b AS base

RUN apk update && apk add libc6-compat python3 make gcc g++ git

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.docs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the Mulan PSL v2 for more details.


FROM node:iron-alpine@sha256:5cf32127b55467ea639dc805a13c6f51b2facebc5eb11f9c5d49e3059f3c0aa4 AS base
FROM node:iron-alpine@sha256:e18f74fc454fddd8bf66f5c632dfc78a32d8c2737d1ba4e028ee60cfc6f95a9b AS base

RUN apk update && apk add libc6-compat python3 make gcc g++ git

Expand Down Expand Up @@ -43,7 +43,7 @@ COPY protos ./protos

RUN pnpm build

FROM nginx:alpine@sha256:7bd88800d8c18d4f73feeee25e04fcdbeecfc5e0a2b7254a90f4816bb67beadd as runner
FROM nginx:alpine@sha256:fdbfdaea4fc323f44590e9afeb271da8c345a733bf44c4ad7861201676a95f42 as runner

COPY docs/nginx.conf /etc/nginx/templates/default.conf.template
COPY --from=builder --chown=nginx:nginx /app/docs/build /etc/nginx/html/
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.scow
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the Mulan PSL v2 for more details.


FROM node:iron-alpine@sha256:5cf32127b55467ea639dc805a13c6f51b2facebc5eb11f9c5d49e3059f3c0aa4 AS base
FROM node:iron-alpine@sha256:e18f74fc454fddd8bf66f5c632dfc78a32d8c2737d1ba4e028ee60cfc6f95a9b AS base

RUN apk update

Expand Down
12 changes: 12 additions & 0 deletions docs/docs/integration/scow-api-hook/hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ title: SCOW Hook

```yaml title="config/common.yaml"
scowHook:
# 启用SCOW Hook功能,默认为true
# enabled: true

# 若您只有一个hook,您可以直接使用url属性,并填入您的Hook的地址
url: 您的gRPC服务器的地址

# 若您有多个hook,则可以使用hooks属性,逐个填入您的地址。
# 若您填写了hooks,则url属性将会被忽略
hooks:
- name: hook-name-1 # hook名,可选,若填写了,则在日志中可以看到被调用的hook的名字
url: hook 1地址 # hook服务器端地址
- name: hook-name-2
url: hook 2地址
```
5. 重启SCOW
Expand Down
6 changes: 5 additions & 1 deletion libs/config/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export const ScowApiConfigSchema = Type.Object({

export const ScowHookConfigSchema = Type.Object({
enabled: Type.Boolean({ description: "是否启用SCOW Hook", default: true }),
url: Type.String({ description: "SCOW Hook的URL" }),
url: Type.Optional(Type.String({ description: "SCOW Hook的URL" })),
hooks: Type.Optional(Type.Array(Type.Object({
name: Type.Optional(Type.String({ description: "Hook的名称" })),
url: Type.String({ description: "Hook的URL" }),
}), { description: "多个Hook的URL。SCOW将会以数组的顺序逐个调用各个hook。" })),
}, { description: "SCOW Hook配置" });

export const CommonConfigSchema = Type.Object({
Expand Down
Loading

0 comments on commit 29199d6

Please sign in to comment.