Skip to content

Commit 9125de3

Browse files
jinquantianxiaiSecloud
authored andcommitted
feat(frontend): 支持告警事件和告警屏蔽 #9404
# Reviewed, transaction id: 34240
1 parent 7294f72 commit 9125de3

File tree

7 files changed

+233
-198
lines changed

7 files changed

+233
-198
lines changed

dbm-ui/frontend/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
<template #content-header>
5656
<RouterBack />
5757
</template>
58-
<DbRouterView style="height: 100%" />
58+
<DbRouterView
59+
:key="route.name"
60+
style="height: 100%" />
5961
</Layout>
6062
<SystemVersionLog v-model:is-show="isShowSystemVersionLog" />
6163
</template>
@@ -88,6 +90,7 @@
8890
const userProfileStore = useUserProfile();
8991
const { locale, t } = useI18n();
9092
const systemEnvironStore = useSystemEnviron();
93+
const route = useRoute();
9194
9295
const documentTitles: Record<string, string> = {
9396
en: 'DBM | Tencent BlueKing',

dbm-ui/frontend/src/locales/en.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,5 +1760,14 @@
17601760
"备份 DB 名": "",
17611761
"暂不支持,请去监控平台操作": "",
17621762
"跳转监控": "",
1763+
"1小时": "",
1764+
"1天": "",
1765+
"近n分钟": "",
1766+
"近n小时": "",
1767+
"近n天": "",
1768+
"近n个月": "",
1769+
"近1小时": "",
1770+
"近1天": "",
1771+
"近1个月": "",
17631772
"这行勿动!新增翻译请在上一行添加!": ""
17641773
}

dbm-ui/frontend/src/locales/zh-cn.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,13 +4058,22 @@
40584058
"n小时": "{n}小时",
40594059
"n天": "{n}天",
40604060
"n个月": "{n}个月",
4061+
"近n分钟": "近{n}分钟",
4062+
"近n小时": "近{n}小时",
4063+
"近n天": "近{n}天",
4064+
"近n个月": "近{n}个月",
40614065
"n年": "{n}年",
40624066
"备份 DB 名": "备份 DB 名",
40634067
"暂不支持,请去监控平台操作": "暂不支持,请去监控平台操作",
40644068
"15天": "15天",
40654069
"6个月": "6个月",
40664070
"1个月": "1个月",
40674071
"1年": "1年",
4072+
"1小时": "1小时",
4073+
"1天": "1天",
4074+
"近1小时": "近1小时",
4075+
"近1天": "近1天",
4076+
"近1个月": "近1个月",
40684077
"跳转监控": "跳转监控",
40694078
"这行勿动!新增翻译请在上一行添加!": ""
40704079
}

dbm-ui/frontend/src/views/monitor-alarm/alarm-events/Index.vue

Lines changed: 60 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@
246246
export type RowData = ServiceReturnType<typeof getAlarmEventsList>['results'][number];
247247
248248
const { t } = useI18n();
249-
const router = useRouter();
250249
const route = useRoute();
251250
const globalBizStore = useGlobalBizs();
252251
const { urls } = useSystemEnviron();
@@ -257,6 +256,32 @@
257256
const activeLevel = ref(0);
258257
const searchOperationRef = ref<InstanceType<typeof SearchOperation>>();
259258
const createShieldAlarmsRef = ref<InstanceType<typeof ShieldAlarms>>();
259+
const severityList = ref([
260+
{
261+
count: 0,
262+
iconColor: '',
263+
name: t('全部'),
264+
value: 0,
265+
},
266+
{
267+
count: 0,
268+
iconColor: '#3A84FF',
269+
name: t('提醒'),
270+
value: 3,
271+
},
272+
{
273+
count: 0,
274+
iconColor: '#F59500',
275+
name: t('预警'),
276+
value: 2,
277+
},
278+
{
279+
count: 0,
280+
iconColor: '#EA3636',
281+
name: t('致命'),
282+
value: 1,
283+
},
284+
]);
260285
261286
const selectionList = shallowRef<RowData[]>([]);
262287
const currentEvent = shallowRef<RowData>();
@@ -307,33 +332,6 @@
307332
},
308333
];
309334
310-
const severityList = ref([
311-
{
312-
count: 0,
313-
iconColor: '',
314-
name: t('全部'),
315-
value: 0,
316-
},
317-
{
318-
count: 0,
319-
iconColor: '#3A84FF',
320-
name: t('提醒'),
321-
value: 3,
322-
},
323-
{
324-
count: 0,
325-
iconColor: '#F59500',
326-
name: t('预警'),
327-
value: 2,
328-
},
329-
{
330-
count: 0,
331-
iconColor: '#EA3636',
332-
name: t('致命'),
333-
value: 1,
334-
},
335-
]);
336-
337335
const tableSetting = {
338336
checked: [
339337
'alert_name',
@@ -363,58 +361,47 @@
363361
'severity',
364362
];
365363
364+
const searchValue: Record<string, string> = {};
366365
const columnFilterParams: Record<string, string> = {};
367366
368-
watch(
369-
() => route.query,
370-
() => {
371-
if (!Object.keys(route.query).length) {
372-
return;
373-
}
374-
375-
updateTableData();
376-
},
377-
{
378-
deep: true,
379-
},
380-
);
367+
const triggerSearch = () => {
368+
tableRef.value?.fetchData({
369+
bk_biz_id: undefined,
370+
...searchValue,
371+
});
372+
};
381373
382-
const updateTableData = () => {
383-
const params = route.query;
374+
const initURLParmasToSearchValue = () => {
384375
if (!isTodoPage.value && !isGlobalPage.value) {
385-
Object.assign(params, {
376+
Object.assign(searchValue, {
386377
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
387378
});
388379
}
389380
// 平台管理页鉴权标记
390381
if (isGlobalPage.value) {
391-
Object.assign(params, {
382+
Object.assign(searchValue, {
392383
platform: true,
393384
});
394385
}
395386
if (route.query.self_assist) {
396-
Object.assign(params, {
387+
Object.assign(searchValue, {
397388
self_assist: true,
398389
});
399390
}
400391
if (route.query.self_manage || (!route.query.self_manage && !route.query.self_assist && isTodoPage.value)) {
401-
Object.assign(params, {
392+
Object.assign(searchValue, {
402393
self_manage: true,
403394
});
404395
}
405396
if (route.query.bk_biz_id) {
406-
Object.assign(params, {
397+
Object.assign(searchValue, {
407398
bk_biz_id: Number(route.query.bk_biz_id),
408399
});
409400
}
410-
setTimeout(() => {
411-
tableRef.value?.fetchData({
412-
bk_biz_id: undefined,
413-
...params,
414-
});
415-
});
416401
};
417402
403+
initURLParmasToSearchValue();
404+
418405
const handleRequestSuccess = (data: ServiceReturnType<typeof getAlarmEventsList>) => {
419406
const severityInfo = data.aggs.find((item) => item.id === 'severity');
420407
if (!severityInfo) {
@@ -445,13 +432,11 @@
445432
446433
const handleSelectLevel = (level: number) => {
447434
activeLevel.value = level;
448-
router.push({
449-
name: route.name,
450-
query: {
451-
...route.query,
452-
severity: level ? level : undefined,
453-
},
435+
Object.assign(searchValue, {
436+
severity: level ? level : undefined,
454437
});
438+
439+
triggerSearch();
455440
};
456441
457442
const handleOpenShieldAlarms = (isEnable = true, data: RowData) => {
@@ -479,30 +464,32 @@
479464
} else {
480465
delete columnFilterParams[data.field];
481466
}
482-
tableRef.value?.fetchData({
483-
bk_biz_id: undefined,
484-
...route.query,
485-
...columnFilterParams,
467+
const filterKeys = ['stage', 'status'];
468+
filterKeys.forEach((key) => {
469+
if (!columnFilterParams[key]) {
470+
delete searchValue[key];
471+
return;
472+
}
473+
474+
searchValue[key] = columnFilterParams[key];
486475
});
476+
477+
triggerSearch();
487478
};
488479
489480
const handleSearchChange = (data: Record<string, string>) => {
490481
const searchData = _.cloneDeep(data);
491-
const query = _.cloneDeep(route.query);
492-
Object.keys(route.query).forEach((key) => {
482+
Object.keys(searchValue).forEach((key) => {
493483
if (!searchData[key] && searchDataKeys.includes(key)) {
494484
// searchselect 删除的项
495-
delete query[key];
485+
delete searchValue[key];
496486
} else if (searchData[key]) {
497-
query[key] = searchData[key];
487+
searchValue[key] = searchData[key];
498488
delete searchData[key];
499489
}
500490
});
501-
Object.assign(query, searchData);
502-
router.push({
503-
name: route.name,
504-
query,
505-
});
491+
Object.assign(searchValue, searchData);
492+
triggerSearch();
506493
};
507494
508495
const handleClosed = () => {
@@ -538,7 +525,6 @@
538525
539526
const handleShieldSuccess = () => {
540527
currentEvent.value!.is_shielded = true;
541-
// updateTableData();
542528
};
543529
</script>
544530
<style lang="less" scoped>

dbm-ui/frontend/src/views/monitor-alarm/alarm-events/components/SearchOperation.vue

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</BkSelect>
1818
<ShieldDateTimePicker
1919
class="shield-date-picker"
20+
mode="previous"
2021
:model-value="filterDateRange"
2122
@change="handleDateTimeChange"
2223
@finish="handleDateTimePick" />
@@ -152,6 +153,11 @@
152153
},
153154
];
154155
156+
const dbList = Object.values(DBTypeInfos);
157+
const dateFormatStr = 'YYYY-MM-DD HH:mm:ss';
158+
const startTime = dayjs().subtract(7, 'day').format(dateFormatStr);
159+
const endTime = dayjs().format(dateFormatStr);
160+
155161
const defaultStatus = {
156162
id: 'status',
157163
name: t('状态'),
@@ -180,31 +186,41 @@
180186
...item,
181187
values: [
182188
{
183-
id,
189+
id: item.id === 'bk_biz_id' ? Number(id) : id,
184190
name,
185191
},
186192
],
187193
});
188194
}
189195
return results;
190196
}, []);
191-
if (!route.query.status) {
197+
if (!route.query.limit && !route.query.status) {
192198
baseValue.push(defaultStatus);
193199
}
194200
return baseValue;
195201
};
196202
197-
const dbList = Object.values(DBTypeInfos);
198-
const dateFormatStr = 'YYYY-MM-DD HH:mm:ss';
199-
const startTime = dayjs().subtract(6, 'day').format(dateFormatStr);
200-
const endTime = dayjs().format(dateFormatStr);
203+
const initDatetime = () => {
204+
const start = route.query.start_time as string;
205+
const end = route.query.end_time as string;
206+
if (start && end) {
207+
return {
208+
end_time: dayjs(end).format(dateFormatStr),
209+
start_time: dayjs(start).format(dateFormatStr),
210+
};
211+
}
201212
202-
const filterData = ref<Record<string, any>>({
203-
end_time: endTime,
204-
start_time: startTime,
205-
});
213+
return {
214+
end_time: endTime,
215+
start_time: startTime,
216+
};
217+
};
218+
219+
const initDateRange = initDatetime();
220+
221+
const filterData = ref<Record<string, any>>(initDateRange);
206222
const dbValue = ref<string[]>([]);
207-
const filterDateRange = ref<[string, string]>([startTime, endTime]);
223+
const filterDateRange = ref<[string, string]>([initDateRange.start_time, initDateRange.end_time]);
208224
const searchValue = ref<ISearchValue[]>(initSearchValue());
209225
210226
const searchSelectData = computed(() => {
@@ -271,8 +287,7 @@
271287
if (!handledValueList.length) {
272288
filterData.value = {
273289
db_types: filterData.value.db,
274-
end_time: endTime,
275-
start_time: startTime,
290+
...initDatetime(),
276291
};
277292
return;
278293
}

0 commit comments

Comments
 (0)