Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 committed Jun 14, 2024
1 parent a21de41 commit 7d95076
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 83 deletions.
2 changes: 1 addition & 1 deletion ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@
"src.pages.Alert.Shield.639D1A8C": "请选择",
"src.pages.Alert.Shield.B0133BD9": "请选择集群",
"src.pages.Alert.Shield.A519C403": "请选择",
"src.pages.Alert.Shield.4AE1863A": "请选择{nextFormName![1] === 'observer' ? '主机' : '租户'}",
"src.pages.Alert.Shield.4AE1863A": "请选择{ConditionalExpression0}",
"src.pages.Alert.Shield.0EEFD182": "主机",
"src.pages.Alert.Shield.74A00B6E": "租户",
"src.pages.Alert.Shield.5F7B1190": "请选择",
Expand Down
13 changes: 1 addition & 12 deletions ui/src/models/alarm.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { getSimpleClusterList } from '@/services';
import { getAllTenants } from '@/services/tenant';
import { useEffect, useState } from 'react';
import { useState } from 'react';

export default () => {
const [clusterList, setClusterList] = useState<API.SimpleClusterList>();
const [tenantList, setTenantList] = useState<API.TenantDetail[]>();

useEffect(() => {
getSimpleClusterList().then(({ successful, data }) => {
if (successful) setClusterList(data);
});
getAllTenants().then(({ successful, data }) => {
if (successful) setTenantList(data);
});
}, []);

return {
clusterList,
setClusterList,
Expand Down
70 changes: 29 additions & 41 deletions ui/src/pages/Alert/Rules/RuleDrawerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,53 +124,41 @@ export default function RuleDrawerForm({
<Col span={16}>
<Form.Item
name={'name'}
rules={
isEdit
? [
{
required: true,
message: intl.formatMessage({
id: 'src.pages.Alert.Rules.B7B764AE',
defaultMessage: '请输入',
}),
},
]
: [
{
required: true,
message: intl.formatMessage({
id: 'src.pages.Alert.Rules.50003344',
defaultMessage: '请输入',
}),
},
{
validator: async (_, value) => {
if (rules) {
for (const rule of rules) {
if (rule.name === value) {
return Promise.reject(
new Error(
intl.formatMessage({
id: 'src.pages.Alert.Rules.B46056EE',
defaultMessage:
'告警规则已存在,请重新输入',
}),
),
);
}
}
}
return Promise.resolve();
},
},
]
}
rules={[
{
required: true,
message: intl.formatMessage({
id: 'src.pages.Alert.Rules.50003344',
defaultMessage: '请输入',
}),
},
{
validator: async (_, value) => {
if (rules) {
for (const rule of rules) {
if (rule.name === value) {
return Promise.reject(
new Error(
intl.formatMessage({
id: 'src.pages.Alert.Rules.B46056EE',
defaultMessage: '告警规则已存在,请重新输入',
}),
),
);
}
}
}
return Promise.resolve();
},
},
]}
label={intl.formatMessage({
id: 'src.pages.Alert.Rules.14235DA8',
defaultMessage: '告警规则名',
})}
>
<Input
disabled={isEdit}
placeholder={intl.formatMessage({
id: 'src.pages.Alert.Rules.63C9E8E6',
defaultMessage: '请输入',
Expand Down
4 changes: 3 additions & 1 deletion ui/src/pages/Alert/Rules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function Rules() {
defaultMessage: '告警规则名',
}),
dataIndex: 'name',
fixed: true,
key: 'name',
},
{
Expand Down Expand Up @@ -135,6 +136,7 @@ export default function Rules() {
id: 'src.pages.Alert.Rules.F333E1DF',
defaultMessage: '操作',
}),
fixed: 'right',
dataIndex: 'action',
render: (_, record) => (
<>
Expand Down Expand Up @@ -214,7 +216,7 @@ export default function Rules() {
rowKey="name"
dataSource={listRules}
pagination={{ simple: true }}
// scroll={{ x: 1500 }}
scroll={{ x: 1400 }}
/>
</Card>
<RuleDrawerForm
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Alert/Shield/ShieldObjInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default function ShieldObjInput({
{
id: 'src.pages.Alert.Shield.4AE1863A',
defaultMessage:
"请选择${nextFormName![1] === 'observer' ? '主机' : '租户'}",
"请选择{ConditionalExpression0}",
},
{
ConditionalExpression0:
Expand Down
11 changes: 10 additions & 1 deletion ui/src/pages/Alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getSimpleClusterList } from '@/services';
import { getAllTenants } from '@/services/tenant';
import { intl } from '@/utils/intl';
import { PageContainer } from '@ant-design/pro-components';
import { Outlet, history } from '@umijs/max';
import { Outlet, history, useModel } from '@umijs/max';
import type { TabsProps } from 'antd';
import { Divider, Tabs } from 'antd';
import { useEffect, useState } from 'react';
Expand Down Expand Up @@ -62,13 +64,20 @@ const getInitialActiveKey = () => {
};

export default function Alert() {
const { setClusterList, setTenantList } = useModel('alarm');
const [activeKey, setActiveKey] = useState<string>(getInitialActiveKey());
const onChange = (key: string) => {
setActiveKey(key);
history.push(`/alert/${key}`);
};

useEffect(() => {
getSimpleClusterList().then(({ successful, data }) => {
if (successful) setClusterList(data);
});
getAllTenants().then(({ successful, data }) => {
if (successful) setTenantList(data);
});
const unlisten = history.listen(({ location }) => {
const curKey =
location.pathname.split('/')[location.pathname.split('/').length - 1];
Expand Down
25 changes: 0 additions & 25 deletions ui/src/pages/Cluster/ClusterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,6 @@ const columns: ColumnsType<DataType> = [
width: 178,
key: 'createTime',
},

//监控还未返回
// {
// title: '监控',
// children: [
// {
// title: 'CPU',
// dataIndex: 'cpuPercent',
// key: 'cpuPercent',
// render: (value) => <CanvasPie percent={Number(value)} name="cpu" />,
// },
// {
// title: '内存',
// dataIndex: 'memoryPercent',
// key: 'memoryPercent',
// render: (value) => <CanvasPie percent={Number(value)} name="memory" />,
// },
// {
// title: '磁盘',
// dataIndex: 'diskPercent',
// key: 'diskPercent',
// render: (value) => <CanvasPie percent={Number(value)} name="disk" />,
// },
// ],
// },
];

export default function ClusterList({
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Layouts/DetailLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const DetailLayout: React.FC<DetailLayoutProps> = ({

useEffect(() => {
getAppInfoFromStorage().then((appInfo) => {
setVersion(appInfo.version);
setVersion(appInfo?.version);
});
}, []);

Expand Down

0 comments on commit 7d95076

Please sign in to comment.