Module: nagvis Branch: master Commit: 0de3684be6021aee5c82682a84c93f117078872c URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=0de3684be6021aee5c82682a84c93f117078872c
Author: LaMi <[email protected]> Date: Sat Dec 5 12:37:15 2009 +0100 #84 Disabled eventhandler when switiching from a worse state to a better one --- .../frontend/nagvis-js/js/NagVisStatefulObject.js | 33 +++++++++++ share/frontend/nagvis-js/js/frontend.js | 58 +++++++++++--------- 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js b/share/frontend/nagvis-js/js/NagVisStatefulObject.js index 76aa1cf..a42cf82 100644 --- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js +++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js @@ -119,6 +119,39 @@ var NagVisStatefulObject = NagVisObject.extend({ }, /** + * PUBLIC stateChangedToWorse() + * + * Check if a state change occured to a worse state + * + * @author Lars Michelsen <[email protected]> + */ + stateChangedToWorse: function() { + var lastSubState = 'normal'; + if(this.last_conf.summary_problem_has_been_acknowledged && this.last_conf.summary_problem_has_been_acknowledged == 1) { + lastSubState = 'ack'; + } else if(this.last_conf.summary_in_downtime && this.last_conf.summary_in_downtime == 1) { + lastSubState = 'downtime'; + } + + var lastWeight = oStates[this.last_conf.summary_state][lastSubState]; + + var subState = 'normal'; + if(this.conf.summary_problem_has_been_acknowledged && this.conf.summary_problem_has_been_acknowledged == 1) { + subState = 'ack'; + } else if(this.conf.summary_in_downtime && this.conf.summary_in_downtime == 1) { + subState = 'downtime'; + } + + var weight = oStates[this.conf.summary_state][subState]; + + if(lastWeight < weight) { + return true; + } else { + return false; + } + }, + + /** * PUBLIC outputChanged() * * Check if an output/perfdata change occured since last refresh diff --git a/share/frontend/nagvis-js/js/frontend.js b/share/frontend/nagvis-js/js/frontend.js index 7a12568..bbcfa0a 100644 --- a/share/frontend/nagvis-js/js/frontend.js +++ b/share/frontend/nagvis-js/js/frontend.js @@ -676,36 +676,40 @@ function updateObjects(aMapObjectInformations, aObjs, sType) { * event_scroll=1/0 * event_sound=1/0 */ - - // - Highlight (Flashing) - if(oPageProperties.event_highlight === '1') { - if(aObjs[intIndex].conf.view_type && aObjs[intIndex].conf.view_type === 'icon') { + + // Only do eventhandling when object state changed to a worse state + if(aObjs[intIndex].stateChangedToWorse()) { + + // - Highlight (Flashing) + if(oPageProperties.event_highlight === '1') { + if(aObjs[intIndex].conf.view_type && aObjs[intIndex].conf.view_type === 'icon') { + // Detach the handler + // Had problems with this. Could not give the index to function: + // function() { flashIcon(iIndex, 10); iIndex = null; } + setTimeout('flashIcon('+intIndex+', '+oPageProperties.event_highlight_duration+', '+oPageProperties.event_highlight_interval+')', 0); + } else { + // FIXME: Atm only flash icons, not lines or gadgets + } + } + + // - Scroll to object + if(oPageProperties.event_scroll === '1') { // Detach the handler - // Had problems with this. Could not give the index to function: - // function() { flashIcon(iIndex, 10); iIndex = null; } - setTimeout('flashIcon('+intIndex+', '+oPageProperties.event_highlight_duration+', '+oPageProperties.event_highlight_interval+')', 0); + setTimeout(function() { scrollSlow(aObjs[intIndex].conf.x, aObjs[intIndex].conf.y, 15); }, 0); + } + + // - Eventlog + if(aObjs[intIndex].conf.type == 'service') { + eventlog("state-change", "info", aObjs[intIndex].conf.type+" "+aObjs[intIndex].conf.name+" "+aObjs[intIndex].conf.service_description+": Old: "+aObjs[intIndex].last_conf.summary_state+"/"+aObjs[intIndex].last_conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].last_conf.summary_in_downtime+" New: "+aObjs[intIndex].conf.summary_state+"/"+aObjs[intIndex].conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].conf.summary_in_downtime); } else { - // FIXME: Atm only flash icons, not lines or gadgets + eventlog("state-change", "info", aObjs[intIndex].conf.type+" "+aObjs[intIndex].conf.name+": Old: "+aObjs[intIndex].last_conf.summary_state+"/"+aObjs[intIndex].last_conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].last_conf.summary_in_downtime+" New: "+aObjs[intIndex].conf.summary_state+"/"+aObjs[intIndex].conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].conf.summary_in_downtime); + } + + // - Sound + if(oPageProperties.event_sound === '1') { + // Detach the handler + setTimeout('playSound('+intIndex+', 1)', 0); } - } - - // - Scroll to object - if(oPageProperties.event_scroll === '1') { - // Detach the handler - setTimeout(function() { scrollSlow(aObjs[intIndex].conf.x, aObjs[intIndex].conf.y, 15); }, 0); - } - - // - Eventlog - if(aObjs[intIndex].conf.type == 'service') { - eventlog("state-change", "info", aObjs[intIndex].conf.type+" "+aObjs[intIndex].conf.name+" "+aObjs[intIndex].conf.service_description+": Old: "+aObjs[intIndex].last_conf.summary_state+"/"+aObjs[intIndex].last_conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].last_conf.summary_in_downtime+" New: "+aObjs[intIndex].conf.summary_state+"/"+aObjs[intIndex].conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].conf.summary_in_downtime); - } else { - eventlog("state-change", "info", aObjs[intIndex].conf.type+" "+aObjs[intIndex].conf.name+": Old: "+aObjs[intIndex].last_conf.summary_state+"/"+aObjs[intIndex].last_conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].last_conf.summary_in_downtime+" New: "+aObjs[intIndex].conf.summary_state+"/"+aObjs[intIndex].conf.summary_problem_has_been_acknowledged+"/"+aObjs[intIndex].conf.summary_in_downtime); - } - - // - Sound - if(oPageProperties.event_sound === '1') { - // Detach the handler - setTimeout('playSound('+intIndex+', 1)', 0); } } ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
