Skip to content

Commit

Permalink
fix(frontend): 监控告警自测bug修复 #1531
Browse files Browse the repository at this point in the history
  • Loading branch information
jinquantianxia committed Nov 1, 2023
1 parent e529556 commit fef0977
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 49 deletions.
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2266,5 +2266,6 @@
"元数据检查": "元数据检查",
"日期": "日期",
"未知": "未知",
"请输入 IP": "请输入 IP",
"这行勿动!新增翻译请在上一行添加!": ""
}
8 changes: 8 additions & 0 deletions dbm-ui/frontend/src/services/model/monitor/monitor-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export default class MonitorPolicy {
bk_biz_id: number; // 所属业务,等于0则属于平台策略
creator: string;
create_at: string;
custom_conditions: {
condition: string,
dimension_name: string,
key: string,
method: string,
value: string[],
}[];
dispatch_group_id: number;
db_type: string; // 所属db组件
event_count: number; // 事件数量,-1代表未知,实际数量应为>=0
Expand Down Expand Up @@ -60,6 +67,7 @@ export default class MonitorPolicy {
this.bk_biz_id = payload.bk_biz_id;
this.creator = payload.creator;
this.create_at = payload.create_at;
this.custom_conditions = payload.custom_conditions;
this.dispatch_group_id = payload.dispatch_group_id;
this.db_type = payload.db_type;
this.event_count = payload.event_count;
Expand Down
7 changes: 7 additions & 0 deletions dbm-ui/frontend/src/services/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import MonitorPolicyModel from '@services/model/monitor/monitor-policy';
import type { ListBase } from './types/common';

interface UpdatePolicyParams {
custom_conditions: {
condition: string,
dimension_name: string,
key: string,
method: string,
value: string[],
}[];
targets: {
level: string,
rule: {
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/frontend/src/views/main-views/pages/Database.vue
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
controller-id="influxdb"
module-id="bigdata">
<BkMenuGroup name="InfluxDB">
<BkMenuItem key="InfluxDBManage">
<BkMenuItem key="InfluxDBInstances">
<template #icon>
<i class="db-icon-influxdb" />
</template>
Expand Down Expand Up @@ -419,7 +419,7 @@
</BkMenuItem>
</BkMenuGroup>
<div class="main-views-space-line" />
<BkMenuGroup :name="$t('安全')">
<!-- <BkMenuGroup :name="$t('安全')">
<BkMenuItem key="DBPasswordTemporaryModify">
<template #icon>
<i class="db-icon-password" />
Expand All @@ -431,7 +431,7 @@
</span>
</BkMenuItem>
</BkMenuGroup>
<div class="main-views-space-line" />
<div class="main-views-space-line" /> -->
<BkMenuGroup :name="$t('设置')">
<BkMenuItem key="DatabaseStaff">
<template #icon>
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/frontend/src/views/main-views/pages/Platform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</BkMenuGroup>
<div class="main-views-space-line" />
<BkMenuGroup :name="$t('资源管理')">
<BkMenuItem key="ResourceSpec">
<BkMenuItem key="ResourceSpecList">
<template #icon>
<i class="db-icon-spec" />
</template>
Expand Down Expand Up @@ -197,7 +197,7 @@
</BkMenuItem>
</BkSubmenu>
</FunController>
<BkMenuItem key="PlatformPasswordRandomization">
<!-- <BkMenuItem key="PlatformPasswordRandomization">
<template #icon>
<i class="db-icon-pingbi" />
</template>
Expand All @@ -206,7 +206,7 @@
class="text-overflow">
{{ $t('密码随机化管理') }}
</span>
</BkMenuItem>
</BkMenuItem> -->
<BkMenuItem key="PlatformStaff">
<template #icon>
<i class="db-icon-dba-config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
const isShowEditStrrategySideSilder = ref(false);
const currentChoosedRow = ref({} as RowData);
const searchValue = ref<Array<SearchSelectItem & {values: SearchSelectItem[]}>>([]);
const alarmGroupList = ref<SelectItem<string>[]>([]);
const alarmGroupList = ref<SelectItem<number>[]>([]);
const sliderPageType = ref('edit');
const moduleList = ref<SelectItem<string>[]>([]);
const clusterList = ref<SelectItem<string>[]>([]);
Expand Down Expand Up @@ -334,7 +334,7 @@
alarmGroupNameMap[item.id] = item.name;
return ({
label: item.name,
value: String(item.id),
value: item.id,
});
});
if (notifyGroupId !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
ref="monitorTargetRef"
:bizs-map="bizsMap"
:cluster-list="clusterList"
:customs="data.custom_conditions"
:db-type="dbType"
:disabled="isReadonlyPage"
:module-list="moduleList"
Expand Down Expand Up @@ -199,7 +200,7 @@
data: RowData,
bizsMap: Record<string, string>,
dbType: string,
alarmGroupList: SelectItem<string>[],
alarmGroupList: SelectItem<number>[],
alarmGroupNameMap: Record<string, string>,
moduleList: SelectItem<string>[],
clusterList: SelectItem<string>[],
Expand Down Expand Up @@ -389,14 +390,10 @@
warnRule.value ? warnValueRef.value.getValue() : undefined,
dangerRule.value ? dangerValueRef.value.getValue() : undefined,
];
const { targets, custom_conditions } = monitorTargetRef.value.getValue();
const reqParams = {
targets: monitorTargetRef.value.getValue().map((item: { id: string; value: string[]; }) => ({
rule: {
key: item.id,
value: item.value,
},
level: item.id,
})),
targets,
custom_conditions,
test_rules: testRules.filter(item => item && item.config.length !== 0),
notify_rules: formModel.notifyRules,
notify_groups: formModel.notifyTarget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@
</BkSelect>
<span v-else>{{ item.title }}</span>
</div>
<div
class="content"
:class="{
'content-other': item.isCustom
}">
<div class="content">
<BkSelect
v-if="item.isSelect"
v-model="item.value"
Expand All @@ -109,11 +105,13 @@
<div
v-else
class="content-custom">
<span class="condition">{{ signMap[item.value[0]] }}</span>
<BkInput
v-model="item.value[1]"
:placeholder="t('请输入')"
size="default" />
<span class="condition">{{ signMap[item.method] }}</span>
<BkTagInput
v-model="item.valueList"
allow-create
collapse-tags
has-delete-icon
:placeholder="t('请输入')" />
</div>
</div>
<div class="operate-box">
Expand Down Expand Up @@ -144,6 +142,7 @@
import { signMap } from '@components/monitor-rule-check/index.vue';

type TargetItem = MonitorPolicyModel['targets'][0];
type CustomItem = MonitorPolicyModel['custom_conditions'][0]

type FlowListType = ReturnType<typeof initFlowList>;

Expand All @@ -155,6 +154,7 @@
interface Props {
dbType: string,
targets: TargetItem[],
customs: CustomItem[],
bizsMap: Record<string, string>,
moduleList: SelectItem<string>[],
clusterList: SelectItem<string>[],
Expand All @@ -177,7 +177,7 @@
}
return results;
}, [] as TargetItem[]);
return targets.map((item) => {
const targetList = targets.map((item) => {
let title = '';
const isCustom = !titles.includes(item.level);
if (isCustom) {
Expand Down Expand Up @@ -227,8 +227,25 @@
selectList,
activeAdd: isMySql.value ? selectCounts < 2 : false,
activeMinus: !isCustom,
method: '',
valueList: [],
};
});

const customeList = props.customs.map(item => ({
id: item.key,
title: item.dimension_name,
isCustom: true,
isSelect: false,
method: item.method,
titleList: [],
valueList: item.value,
selectList: [],
value: '',
activeAdd: false,
activeMinus: false,
}));
return [...targetList, ...customeList];
}

function generateFlowSelectItem(item: SelectObjType) {
Expand All @@ -250,7 +267,7 @@
activeAdd: false,
activeMinus: true,
});
return item;
return item as unknown as FlowListType[number];
}
}
Object.assign(item, {
Expand All @@ -259,7 +276,7 @@
activeAdd: isMySql.value,
activeMinus: true,
});
return item;
return item as unknown as FlowListType[number];
}

const enum TargetType {
Expand Down Expand Up @@ -396,11 +413,32 @@
defineExpose<Exposes>({
getValue() {
const defalutObj = {
id: TargetType.BIZ,
value: isPlatform.value ? [currentBizId]
: [props.targets.filter(item => item.level === TargetType.BIZ)[0].rule.value[0]],
rule: {
key: TargetType.BIZ,
// eslint-disable-next-line max-len
value: isPlatform.value ? [currentBizId] : [props.targets.filter(item => item.level === TargetType.BIZ)[0].rule.value[0]],
},
level: TargetType.BIZ,
};
const targetList = flowList.value.filter(item => !item.isCustom).map(row => ({
rule: {
key: row.id,
value: row.value,
},
level: row.id,
}));
const targets = [defalutObj, ...targetList];
const customs = flowList.value.filter(item => item.isCustom).map(item => ({
condition: 'and',
dimension_name: item.title,
key: item.id,
method: item.method,
value: item.valueList,
}));
return {
targets,
custom_conditions: customs,
};
return [defalutObj, ...flowList.value];
},
resetValue() {
flowList.value = initFlowList();
Expand Down Expand Up @@ -430,10 +468,10 @@

.top-bar {
position: absolute;
top: -15px;
top: -16px;
left: 20px;
width: 0;
height: 15px;
height: 16px;
border-left: 1px solid #C4C6CC;
}

Expand Down Expand Up @@ -522,7 +560,7 @@

:deep(.bk-select-tag) {
width: 100%;
min-height: 30px;
min-height: 32px;
overflow: hidden;
border-left-color: transparent;
border-bottom-left-radius: 0;
Expand All @@ -546,17 +584,21 @@

.condition {
width: 60px;
height: 30px;
line-height: 30px;
height: 32px;
line-height: 32px;
text-align: center;
border-right: 1px solid #C4C6CC;
border: 1px solid #C4C6CC;
border-right: none;
}
}
}

.content-other {
border: 1px solid #C4C6CC;
border-left: none;
.bk-tag-input {
flex: 1;

:deep(.bk-tag-input-trigger) {
border-radius: 0;
}
}
}
}

.operate-box {
Expand Down Expand Up @@ -591,11 +633,12 @@

.custom {
.title-box {
padding: 0;
width: auto;
min-width: 80px;
padding: 0 8px;
background: #F5F7FA;
border: none;
justify-content: center;
border-right: 1px solid #C4C6CC;

span {
font-size: 12px;
Expand Down
8 changes: 7 additions & 1 deletion dbm-ui/frontend/src/views/redis/apply/ApplyRedis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@
v-model="state.formdata.details.ip_source"
class="item-input"
@change="fetchCapSpecs(state.formdata.details.city_code)">
<!-- 暂时去掉手动录入IP -->
<BkRadioButton
:key="redisIpSources.resource_pool.id"
:label="redisIpSources.resource_pool.id">
{{ redisIpSources.resource_pool.text }}
</BkRadioButton>
<!-- <BkRadioButton
v-for="item of Object.values(redisIpSources)"
:key="item.id"
:label="item.id">
{{ item.text }}
</BkRadioButton>
</BkRadioButton> -->
</BkRadioGroup>
</BkFormItem>
<Transition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@
const handleRemove = (index: number) => {
const removeItem = tableData.value[index];
const { srcCluster } = removeItem;
console.log('srcCluster>>', srcCluster);
tableData.value.splice(index, 1);
delete domainMemo[srcCluster];
const clustersArr = selectedClusters.value[ClusterTypes.REDIS];
console.log('tableData.value>>>', tableData.value);
selectedClusters.value[ClusterTypes.REDIS] = clustersArr.filter(item => item.temp_cluster_proxy !== srcCluster);
};

Expand Down

0 comments on commit fef0977

Please sign in to comment.