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

fix alarm silence strategy setting failed #1131

Merged
merged 5 commits into from
Jul 25, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public boolean filterConverge(Alert currentAlert) {
return false;
}
});
} else {
match = true;
}
if (match && alertConverge.getPriorities() != null && !alertConverge.getPriorities().isEmpty()) {
match = alertConverge.getPriorities().stream().anyMatch(item -> item != null && item == currentAlert.getPriority());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public boolean filterSilence(Alert alert) {
return false;
}
});
}
} else {
match = true;
}
if (match && alertSilence.getPriorities() != null && !alertSilence.getPriorities().isEmpty()) {
match = alertSilence.getPriorities().stream().anyMatch(item -> item != null && item == alert.getPriority());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.Set;

/**
Expand All @@ -31,7 +32,11 @@ public class AlertSilenceServiceImpl implements AlertSilenceService {

@Override
public void validate(AlertSilence alertSilence, boolean isModify) throws IllegalArgumentException {
// todo
// todo
// 兜底策略, 如果周期性情况下设置的告警静默选择日期为空, 视为全部勾选
if (alertSilence.getType() == 1 && alertSilence.getDays() == null) {
alertSilence.setDays(Arrays.asList((byte)7, (byte)1, (byte)2, (byte)3, (byte)4, (byte)5, (byte)6));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,7 @@
<nz-form-item *ngIf="isLimit">
<nz-form-label nzSpan="7" nzFor="days">{{ 'alert.notice.rule.period-chose' | i18n }}</nz-form-label>
<nz-form-control nzSpan="12">
<nz-checkbox-group
name="days"
id="days"
[(ngModel)]="dayCheckOptions"
(ngModelChange)="onNoticeRuleDaysChange(dayCheckOptions)"
></nz-checkbox-group>
<nz-checkbox-group name="days" id="days" [(ngModel)]="dayCheckOptions"></nz-checkbox-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ export class AlertNoticeComponent implements OnInit {
} else {
this.isLimit = true;
}
this.dayCheckOptions.forEach(item => {
item.checked = this.rule.days != undefined && this.rule.days.indexOf(item.value) >= 0;
});
this.isManageRuleModalVisible = true;
this.isManageRuleModalAdd = false;
this.receiversOption.push({
Expand All @@ -313,19 +316,12 @@ export class AlertNoticeComponent implements OnInit {
}
}

onNoticeRuleDaysChange(value: any[]) {
this.rule.days = value
.filter(item => item.checked == true)
.map(item => item.value)
.concat();
}

onNoticeRuleLimitChange(limit: boolean) {
if (!limit) {
this.rule.days = this.dayCheckOptions.map(item => item.value).concat();
} else {
this.rule.days = this.dayCheckOptions
.filter(item => item.checked == true)
.filter(item => item.checked)
.map(item => item.value)
.concat();
}
Expand Down Expand Up @@ -496,6 +492,14 @@ export class AlertNoticeComponent implements OnInit {
if (this.rule.priorities != undefined) {
this.rule.priorities = this.rule.priorities.filter(item => item != null && item != 9);
}
if (this.isLimit) {
this.rule.days = this.dayCheckOptions
.filter(item => item.checked)
.map(item => item.value)
.concat();
} else {
this.rule.days = this.dayCheckOptions.map(item => item.value).concat();
}
this.isManageRuleModalOkLoading = true;
if (this.isManageRuleModalAdd) {
const modalOk$ = this.noticeRuleSvc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,7 @@
<nz-form-item *ngIf="silence.type == 1">
<nz-form-label nzSpan="7" nzFor="days">{{ 'alert.notice.rule.period-chose' | i18n }}</nz-form-label>
<nz-form-control nzSpan="12">
<nz-checkbox-group
name="days"
id="days"
[(ngModel)]="dayCheckOptions"
(ngModelChange)="onSilenceDaysChange(dayCheckOptions)"
></nz-checkbox-group>
<nz-checkbox-group name="days" id="days" [(ngModel)]="dayCheckOptions"></nz-checkbox-group>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="silence.type == 1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class AlertSilenceComponent implements OnInit {
let now = new Date();
now.setHours(now.getHours() + 6);
this.silenceDates = [new Date(), now];
this.dayCheckOptions.forEach(item => (item.checked = true));
this.isManageModalAdd = true;
this.isManageModalVisible = true;
this.isManageModalOkLoading = false;
Expand Down Expand Up @@ -233,6 +234,10 @@ export class AlertSilenceComponent implements OnInit {
this.silence = message.data;
if (this.silence.type === 0) {
this.silenceDates = [this.silence.periodStart, this.silence.periodEnd];
} else {
this.dayCheckOptions.forEach(item => {
item.checked = this.silence.days != undefined && this.silence.days.indexOf(item.value) >= 0;
});
}
this.isManageModalVisible = true;
this.isManageModalAdd = false;
Expand Down Expand Up @@ -279,6 +284,11 @@ export class AlertSilenceComponent implements OnInit {
if (this.silence.type === 0) {
this.silence.periodStart = this.silenceDates[0];
this.silence.periodEnd = this.silenceDates[1];
} else {
this.silence.days = this.dayCheckOptions
.filter(item => item.checked)
.map(item => item.value)
.concat();
}
this.isManageModalOkLoading = true;
if (this.isManageModalAdd) {
Expand Down Expand Up @@ -329,12 +339,6 @@ export class AlertSilenceComponent implements OnInit {
);
}
}
onSilenceDaysChange(value: any[]) {
this.silence.days = value
.filter(item => item.checked == true)
.map(item => item.value)
.concat();
}

onPrioritiesChange() {
if (this.silence.priorities != undefined) {
Expand Down