Skip to content

Commit

Permalink
chore: add Contion Type to Rule Details
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojiping committed Feb 13, 2025
1 parent 4e82154 commit d1dbf9e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 2 additions & 0 deletions web/src/locales/en-US/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ export default {
"alert.rule.table.columnns.objects": "Objects",
"alert.rule.table.columnns.schedule": "Schedule",
"alert.rule.table.columnns.expression": "Expression",
"alert.rule.table.columnns.condition.type": "Condition Type",
"alert.rule.table.columnns.condition": "Condition",
"alert.rule.table.columnns.status": "Status",
"alert.rule.table.columnns.status.failed": "Connect failed",
"alert.rule.table.columnns.status.succeeded": "Connect succeeded",
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/zh-CN/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export default {
"alert.rule.table.columnns.objects": "告警对象",
"alert.rule.table.columnns.schedule": "计划周期",
"alert.rule.table.columnns.expression": "告警规则",
"alert.rule.table.columnns.condition.type": "触发条件类型",
"alert.rule.table.columnns.condition": "触发条件",
"alert.rule.table.columnns.status": "运行状态",
"alert.rule.table.columnns.status.failed": "连接失败",
"alert.rule.table.columnns.status.succeeded": "连接成功",
Expand Down
36 changes: 32 additions & 4 deletions web/src/pages/Alerting/Rule/components/RuleCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const RuleCard = ({ ruleID, data = {} }) => {
);
};
const clusters = useGlobalClusters();
const isBucketDiff = !!(data && data.bucket_conditions)

return (
<div>
Expand Down Expand Up @@ -158,10 +159,16 @@ const RuleCard = ({ ruleID, data = {} }) => {
<span style={{ wordBreak: "break-all" }}>{data?.expression}</span>
</Col>
</Row>
<Row style={{ marginBottom: 10}}>
<Col span={6}>{formatMessage({ id: "alert.rule.table.columnns.condition.type" })}</Col>
<Col span={18}>
{isBucketDiff ? formatMessage({id: `alert.rule.form.label.buckets_diff`}) : formatMessage({id: `alert.rule.form.label.metrics_value`})}
</Col>
</Row>
<Row style={{ marginBottom: 30 }}>
<Col span={6}>Condition</Col>
<Col span={6}>{formatMessage({ id: "alert.rule.table.columnns.condition" })}</Col>
<Col span={18}>
<Conditions items={data.conditions?.items} />
<Conditions items={isBucketDiff ? data.bucket_conditions?.items : data.conditions?.items} />
</Col>
</Row>
</Card>
Expand All @@ -173,6 +180,9 @@ const Conditions = ({ items }) => {
return (items || []).map((item) => {
let operator = "";
switch (item.operator) {
case "equals":
operator = "=";
break;
case "gte":
operator = ">=";
break;
Expand All @@ -185,11 +195,29 @@ const Conditions = ({ items }) => {
case "lte":
operator = "<=";
break;
case "range":
operator = "range";
break;
}
return (
<div key={item.priority} style={{ marginBottom: 10 }}>
<span>{operator} </span>
<span style={{ marginRight: 15 }}>{item.values[0]}</span>
{item.type && (<span style={{ marginRight: 15 }}>{formatMessage({id: `alert.rule.form.label.${item.type}`})}</span>)}
{
operator === 'range' ? (
<>
<span>{`>=`}</span>
<span style={{ marginRight: 4 }}>{item.values[0]}</span>
<span style={{ marginRight: 4 }}>{`&`}</span>
<span>{`<=`}</span>
<span style={{ marginRight: 15 }}>{item.values[1]}</span>
</>
) : (
<>
<span>{operator} </span>
<span style={{ marginRight: 15 }}>{item.values[0]}</span>
</>
)
}
<PriorityIconText priority={item.priority} />
</div>
);
Expand Down

0 comments on commit d1dbf9e

Please sign in to comment.