Skip to content

Commit

Permalink
refactor: 告警详情页增加恢复时间
Browse files Browse the repository at this point in the history
  • Loading branch information
guguji5 committed Dec 8, 2021
1 parent df1f8ab commit a05325b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "n9e-fe",
"version": "5.0.0-ga-01",
"version": "5.0.0-ga-02",
"scripts": {
"dev": "vite --port 8765 --host",
"preinstall": "sh beforeinstall.sh",
Expand Down
36 changes: 17 additions & 19 deletions src/pages/event/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ const EventDetailPage: React.FC = () => {
},
},
{ label: '触发时值', key: 'trigger_value' },
{
label: '恢复时间',
key: 'recover_time',
render(time) {
return moment((time || 0) * 1000).format('YYYY-MM-DD HH:mm:ss');
},
},
{
label: 'PromQL',
key: 'prom_ql',
Expand Down Expand Up @@ -150,17 +157,6 @@ const EventDetailPage: React.FC = () => {
const requestPromise = isHistory ? getHistoryEventsById(busiId, eventId) : getAlertEventsById(busiId, eventId);
requestPromise.then((res) => {
setEventDetail(res.dat);
if (res.dat.is_recovered) {
const originDescriptionInfo = descriptionInfo;
originDescriptionInfo.splice(8, 0, {
label: '恢复时间',
key: 'recover_time',
render(time) {
return moment((time || 0) * 1000).format('YYYY-MM-DD HH:mm:ss');
},
});
setDescriptionInfo(originDescriptionInfo);
}
});
}, [busiId, eventId]);

Expand Down Expand Up @@ -208,14 +204,16 @@ const EventDetailPage: React.FC = () => {
]}
>
{eventDetail &&
descriptionInfo.map(({ label, key, render }) => {
return (
<div className='desc-row'>
<div className='desc-label'>{label}</div>
<div className='desc-content'>{render ? render(eventDetail[key], eventDetail) : eventDetail[key]}</div>
</div>
);
})}
descriptionInfo
.filter((item) => (eventDetail.is_recovered ? true : item.key !== 'recover_time'))
.map(({ label, key, render }) => {
return (
<div className='desc-row'>
<div className='desc-label'>{label}</div>
<div className='desc-content'>{render ? render(eventDetail[key], eventDetail) : eventDetail[key]}</div>
</div>
);
})}
</Card>
</Spin>
</div>
Expand Down

0 comments on commit a05325b

Please sign in to comment.