Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): 告警通知优化 #8366 #9111

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dbm-ui/frontend/patch/user-selector/selector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,9 @@
}
try {
loading.value = true;
const pasteStr = event.clipboardData.getData('text').replace(/\s/g, '');
const pasteStr = event.clipboardData.getData('text').replace(/[^\S\r\n]/g, '');
const values = pasteStr
.split(/,|;/)
.split(/\s*[||,,;;、\t/\s]\s*/g)
.map((value) => pasteFormatter.value(value))
.filter((value) => value.length);
const uniqueValues = [...new Set(values)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@
].join('\n'),
};

const InputMessageTypeMap: Record<string, string> = {
'wxwork-bot': MessageTypes.WECOM_ROBOT,
[MessageTypes.WECOM_ROBOT]: 'wxwork-bot',
};

let head: TableHead[] = [
{
label: t('告警级别'),
Expand Down Expand Up @@ -472,14 +477,16 @@
const inputArr = _.cloneDeep(panelInitData.inputArr);

configItem.notice_ways.forEach((wayItem) => {
if (InputMessageTypes.includes(wayItem.name)) {
const idx = inputArr.findIndex((inputItem) => inputItem.type === wayItem.name);
// 转为消息类型对应值
const conversionType = InputMessageTypeMap[wayItem.name] || wayItem.name;
if (InputMessageTypes.includes(conversionType)) {
const idx = inputArr.findIndex((inputItem) => inputItem.type === conversionType);

if (idx > -1) {
inputArr[idx].value = (wayItem.receivers || []).join(',');
}
} else {
const idx = checkboxArr.findIndex((checkboxItem) => checkboxItem.type === wayItem.name);
const idx = checkboxArr.findIndex((checkboxItem) => checkboxItem.type === conversionType);

if (idx > -1) {
checkboxArr[idx].checked = true;
Expand Down Expand Up @@ -625,7 +632,7 @@
(prev, current) => {
if (current.value !== '') {
prev.push({
name: current.type,
name: InputMessageTypeMap[current.type] || current.type, // 转为映射值
receivers: current.value.split(','),
});
}
Expand Down Expand Up @@ -697,10 +704,9 @@

.table-row-item {
display: flex;
min-width: 120px;
width: 110px;
padding: 0 12px;
border-bottom: 1px solid #dcdee5;
flex: 1;
align-items: center;
justify-content: center;
flex-shrink: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:default-alternate="defaultAlternate"
:disabled="disabled"
:fuzzy-search-method="fuzzySearchMethod"
:paste-validator="pasteValidator"
:render-list="renderList"
:render-tag="renderTag"
:search-from-default-alternate="false"
Expand Down Expand Up @@ -227,6 +228,13 @@
userSelectorRef.value.search();
};

const pasteValidator = (values: string[]) =>
getUserList({
exact_lookups: values.join(','),
offset: 0,
limit: -1,
}).then((userResult) => userResult.results.map((userItem) => userItem.username));

defineExpose<Exposes>({
getSelectedReceivers() {
return modelValue.value.map((modelValueItem) => ({
Expand Down
Loading