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 event severity change #872

Conversation

memfiz
Copy link
Contributor

@memfiz memfiz commented Jan 13, 2020

This PR closes #870.

  • Added a new property "severity" to the ZBXEvent.
  • Panel problems for both layouts: show severity from the lastEvent.severity if it exists.
  • Create triggerList based on lastEvent.severity if it exists.

Not sure about the code style. It works in my production, but I'm not an expert in typescript/javascript.

Copy link
Collaborator

@alexanderzobnin alexanderzobnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contribution! Looks good, just little fix required.


let severityDesc: TriggerSeverity;
severityDesc = _.find(panelOptions.triggerSeverity, s => s.priority === Number(problem.priority));
if (problem.lastEvent.severity) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to check if lastEvent not empty also:

Suggested change
if (problem.lastEvent.severity) {
if (problem.lastEvent && problem.lastEvent.severity) {


let severityDesc: TriggerSeverity;
severityDesc = _.find(problemSeverityDesc, s => s.priority === Number(props.original.priority));
if (problem.lastEvent.severity) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

@@ -398,7 +398,12 @@ export class TriggerPanelCtrl extends PanelCtrl {

// Filter triggers by severity
triggerList = _.filter(triggerList, trigger => {
return this.panel.triggerSeverity[trigger.priority].show;
//return this.panel.triggerSeverity[trigger.priority].show;
if (trigger.lastEvent.severity) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same

Suggested change
if (trigger.lastEvent.severity) {
if (trigger.lastEvent && trigger.lastEvent.severity) {

@@ -398,7 +398,12 @@ export class TriggerPanelCtrl extends PanelCtrl {

// Filter triggers by severity
triggerList = _.filter(triggerList, trigger => {
return this.panel.triggerSeverity[trigger.priority].show;
//return this.panel.triggerSeverity[trigger.priority].show;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be removed

Suggested change
//return this.panel.triggerSeverity[trigger.priority].show;

@alexanderzobnin alexanderzobnin self-requested a review January 16, 2020 06:44
@alexanderzobnin
Copy link
Collaborator

@memfiz could you fix comments above?

@memfiz
Copy link
Contributor Author

memfiz commented Jan 17, 2020

@memfiz could you fix comments above?

Fixed.

@alexanderzobnin
Copy link
Collaborator

@memfiz I mean trigger.lastEvent.severity (#872 (comment))

@memfiz
Copy link
Contributor Author

memfiz commented Jan 22, 2020

Yes, my fault. Another try...

@alexanderzobnin alexanderzobnin merged commit 94c5059 into grafana:master Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems panel does not support event severity change
2 participants