diff options
-rw-r--r-- | lib/mauve/alert.rb | 2 | ||||
l--------- | static/javascript | 1 | ||||
-rw-r--r-- | static/javascript/mauve_utils.js (renamed from static/mauve_utils.js) | 0 | ||||
-rw-r--r-- | static/mauve.js | 211 | ||||
-rw-r--r-- | views/_alerts_table.haml | 2 | ||||
-rw-r--r-- | views/_alerts_table_alert_summary.haml | 5 | ||||
-rw-r--r-- | views/_alerts_table_group.haml | 2 | ||||
-rw-r--r-- | views/_head.haml | 2 |
8 files changed, 8 insertions, 217 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb index 9cb2521..6694fca 100644 --- a/lib/mauve/alert.rb +++ b/lib/mauve/alert.rb @@ -395,7 +395,7 @@ module Mauve alert_db = first(:alert_id => alert.id, :source => update.source) || new(:alert_id => alert.id, :source => update.source) - + # # Work out what state the alert was in before receiving this update. # diff --git a/static/javascript b/static/javascript deleted file mode 120000 index e3b95b4..0000000 --- a/static/javascript +++ /dev/null @@ -1 +0,0 @@ -/usr/share/javascript
\ No newline at end of file diff --git a/static/mauve_utils.js b/static/javascript/mauve_utils.js index 3012ca3..3012ca3 100644 --- a/static/mauve_utils.js +++ b/static/javascript/mauve_utils.js diff --git a/static/mauve.js b/static/mauve.js deleted file mode 100644 index 0cc32ec..0000000 --- a/static/mauve.js +++ /dev/null @@ -1,211 +0,0 @@ -/* - * This contains all the 'clever' javascript used on the page. - */ -var mouse_is_inside = false; - -/* -try { - $("#myselector").click (function () {}); //my jQuery code here -} catch (e) { - //this executes if jQuery isn't loaded - alert(e.message - + "\nCould be a network error leading to jquery not being loaded!\n" - + "Reloading the page."); - window.location.reload(true); -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -// Treeview data. -$(document).ready(function(){ - $("#blackAck").treeview({ - control: "#treecontrolAck", - persist: "cookie", - cookieId: "treeview-black" - }); - -}); -$(document).ready(function(){ - $("#blackNew").treeview({ - control: "#treecontrolNew", - persist: "cookie", - cookieId: "treeview-black" - }); -}); - -$(document).ready(function(){ - - //////////////////////////////////////////////////////////////////////////////// - // This allows pop! to do its thing, used for details. - $.pop(); - - //////////////////////////////////////////////////////////////////////////////// - // Countdown code. - - /* - // This binds to the timer that reloads the page every 300 seconds via callback. - $('#reloadPage').countdown({until: +300, onExpiry: liftOff, format: 'MS'}); - - // This is the callback that reloads the page. - function liftOff() { - window.location.reload(true); - } - */ - - - //////////////////////////////////////////////////////////////////////////////// - // Mouse outside of changeStatus form. - // See url http://stackoverflow.com/questions/1403615/use-jquery-to-hide-div-when-click-outside-it - $('.updateAlertStatus').hover(function(){ - mouse_is_inside=true; - }, function(){ - mouse_is_inside=false; - }); - $('body').mouseup(function(){ - if(! mouse_is_inside) - { - //$(".updateAlertStatus").fadeOut(1000); - //$('.darkMask').fadeOut(1000); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - } - }); -}); - -//////////////////////////////////////////////////////////////////////////////// -// Acknowledge status functions. - - -//////////////////////////////////////////////////////////////////////////////// -// Standards are there to be violated... -function mouseX(evt) { - if (evt.pageX) return evt.pageX; - else if (evt.clientX) - return evt.clientX + (document.documentElement.scrollLeft ? - document.documentElement.scrollLeft : - document.body.scrollLeft); - else return null; -} - -//////////////////////////////////////////////////////////////////////////////// -// Standards are there to be violated... -function mouseY(evt) { - if (evt.pageY) return evt.pageY; - else if (evt.clientY) - return evt.clientY + (document.documentElement.scrollTop ? - document.documentElement.scrollTop : - document.body.scrollTop); - else return null; -} - -//////////////////////////////////////////////////////////////////////////////// -// Shows the updateAlertStatus div where the mouse clicked and mask the rest of -// page. -function showAcknowledgeStatus (e, id, ackTime) { - - // Build the form. - document.changeAlertStatusForm.AlertID.value = id; - document.changeAlertStatusForm.AlertDefaultAcknowledgeTime.value = ackTime; - var myselect=document.getElementById("sample"); - myselect.remove(0); - str = returnTimeString(ackTime); - myselect.add(new Option(str, ackTime, true, true), myselect.options[0]) - - // Show the form. - //leftVal = mouseX(e); - leftVal = 2 - topVal = mouseY(e); - $('.updateAlertStatus').css({left:leftVal,top:topVal}).fadeIn(500); - $('.darkMask').css({height:$(document).height()}).show(); -} - -// Returns the default time. -function returnTimeString (time) { - hrs = time / 3600 - if (1 == hrs) - { - str = "1 hour" - } - else if (24 > hrs && 1 > hrs) - { - str = hrs + " hours" - } - else if (24 == hrs) - { - str = "1 day" - } - else if (24 < hrs && 168 > hrs) - { - str = hrs / 24 + " days" - } - else if (168 == hrs) - { - str = "1 week" - } - else - { - str = hrs / 168 + " weeks" - } - return str + ", default." -} - -//////////////////////////////////////////////////////////////////////////////// -// Shows the updateAlertSatus div for group of alerts. -function showBulkAcknowledgeStatus(e, ids, ackTime) -{ - for (i in ids) - { - changeAcknowledgeStatusCall(ids[i], ackTime); - } - //window.location.reload(true); - tmp = $('#firstAlert'+ids[0]); - tmp.remove() -} - -function changeAcknowledgeStatusCall (id, acknowledgedUntil) { - $.post('/alert/acknowledge/'+id+'/'+acknowledgedUntil); - tmp = $('#alert'+id) - tmp.remove(); - tmp.appendTo('#blackAck'); -} - -//////////////////////////////////////////////////////////////////////////////// -// Actually gets the alert updated and moves it to the right list. -// Note that id is a numberical ID of the alert. -// Note that acknowledgedUntil is a number of seconds. -function changeAcknowledgeStatus (id, acknowledgedUntil) { - if (-1 != id) - { - changeAcknowledgeStatusCall(id, acknowledgedUntil); - } - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Clears (aka trash aka delete) an alert. -// THIS IS NOT WHAT YOU WANT -// url http://stackoverflow.com/questions/95600/jquery-error-option-in-ajax-utility -// url http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages -function clearAlert (id) { - $.post('/alert/'+id+'/clear'); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - tmp = $('#alert'+id) - tmp.remove(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Raises (aka unacknowledge) an alert. -function raiseAlert (id) { - $.post('/alert/'+id+'/raise'); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - tmp = $('#alert'+id) - tmp.remove(); - tmp.appendTo('#blackNew'); -} - - -//////////////////////////////////////////////////////////////////////////////// -// EOF diff --git a/views/_alerts_table.haml b/views/_alerts_table.haml index aa0c437..f413c30 100644 --- a/views/_alerts_table.haml +++ b/views/_alerts_table.haml @@ -10,8 +10,8 @@ this.checked = !this.checked; }); }); - %th#time At %th#summary Summary + %th#time At = partial("alerts_table_group", :collection => @grouped_alerts) %tr %td diff --git a/views/_alerts_table_alert_summary.haml b/views/_alerts_table_alert_summary.haml index 06f1dc2..a06ccb8 100644 --- a/views/_alerts_table_alert_summary.haml +++ b/views/_alerts_table_alert_summary.haml @@ -6,5 +6,8 @@ %label{ :for => "alerts[#{alert.id}]" } %strong= alert.subject = alert.summary - %a{ :id => ["a","detail", alert.id], :href => "/alert/#{alert.id}", :onclick => "fetchDetail('#{alert.id}'); return false;"} Details ↓ + %a{ :id => ["a","detail", alert.id], | + :href => "/alert/#{alert.id}", | + :onclick => "fetchDetail('#{alert.id}'); return false;"} + Details ↓ %td= alert.raised_at.to_s_relative diff --git a/views/_alerts_table_group.haml b/views/_alerts_table_group.haml index f3af4b2..8bc73b4 100644 --- a/views/_alerts_table_group.haml +++ b/views/_alerts_table_group.haml @@ -2,7 +2,7 @@ - group, alerts = alerts_table_group unless alerts_table_group.nil? - hilight = cycle(nil,"hilight") - row_class = [ hilight, alerts.first.raised? && "triggered", alerts.first.acknowledged? && "acknowledged", alerts.first.level] -=partial("alerts_table_alert_summary", :locals => {:alert => alerts.first, :row_class => row_class }) +=partial("alerts_table_alert_summary", :locals => {:alert => alerts.pop, :row_class => row_class }) - if alerts.length > 1 %tr{ :class => [ hilight, alerts.first.raised? && "triggered", alerts.first.acknowledged? && "acknowledged"]} %td diff --git a/views/_head.haml b/views/_head.haml index 276680d..981aaf1 100644 --- a/views/_head.haml +++ b/views/_head.haml @@ -5,4 +5,4 @@ %link{:rel => "stylesheet", :href => "/stylesheets/mauve.css", :media => "all", :type => "text/css"}/ %link{:rel => "stylesheet", :href => "/stylesheets/mauve-handheld.css", :media => "handheld, only screen and (max-width: 1000px), only screen and (max-device-width: 1000px)", :type => "text/css" }/ %script{:src => '/javascript/jquery/jquery.min.js', :type => 'text/javascript'} - %script{:src => '/mauve_utils.js', :type => 'text/javascript'} + %script{:src => '/javascript/mauve_utils.js', :type => 'text/javascript'} |