diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-11-30 14:52:24 +0000 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-11-30 14:52:24 +0000 |
commit | e92e81943165dce60cdd9b2cf8ebdc1c55acc7fb (patch) | |
tree | 39df1adae252c9195fa3a1ea39dd4fe7ce71e861 /views | |
parent | 044d34c09f446cfca04e8ff1c53a3c5435cf77d8 (diff) |
Updated acknowledge form to allow more things to be done.
--HG--
rename : views/_acknowledge_input.haml => views/_alert_actions.haml
Diffstat (limited to 'views')
-rw-r--r-- | views/_acknowledge_input.haml | 34 | ||||
-rw-r--r-- | views/_alert_actions.haml | 61 | ||||
-rw-r--r-- | views/alert.haml | 19 | ||||
-rw-r--r-- | views/alerts.haml | 4 | ||||
-rw-r--r-- | views/search.haml | 4 |
5 files changed, 68 insertions, 54 deletions
diff --git a/views/_acknowledge_input.haml b/views/_acknowledge_input.haml deleted file mode 100644 index 82f3044..0000000 --- a/views/_acknowledge_input.haml +++ /dev/null @@ -1,34 +0,0 @@ -Acknowledge these alerts for -%input#n_hours{ :name => 'n_hours', :type => "number", :min => 0, :max => 48, :value => 2, :style => "min-width: 6ex;"} -%select#type_hours{:name => 'type_of_hours' } - -# Default to daytime hours - %option{ :value => "working" } working - %option{ :value => "daytime", :selected => "selected"} daytime - %option{ :value => "wallclock" } wall-clock -hours -%span#ack_until_text -%input#ack_until{ :value => '', :type => :hidden, :name => 'ack_until' } -%br -with the note -%input#note{ :name => 'note', :type => "text"} -%input{ :type => 'submit', :value => 'Go!' } -:javascript - // Change of value in the hours box - $('#n_hours').change( function() { - updateDate(); - }); - // As above, but on keypress, with a delay - $('#n_hours').keyup( function() { - clearTimeout($.data(this, 'timer')); - var wait = setTimeout(updateDate, 500); - $(this).data('timer', wait); - }); - // Same as the n_hours change function - $('#type_hours').change( function() { - $('#n_hours').change(); - }); - // Setup the ack text on load. - $(document).ready( function() { - $('#n_hours').change(); - }); - diff --git a/views/_alert_actions.haml b/views/_alert_actions.haml new file mode 100644 index 0000000..2f4eb57 --- /dev/null +++ b/views/_alert_actions.haml @@ -0,0 +1,61 @@ +%select#function{ :name => 'function'} + - if @permitted_actions.include?("acknowledge") + %option{:value => "acknowledge"} Acknowledge + - if @permitted_actions.include?("suppress") + %option{:value => "suppress"} Suppress notifications about + - if @permitted_actions.include?("raise") + %option{:value => "raise"} Raise + - if @permitted_actions.include?("unacknowledge") + %option{:value => "unacknowledge"} Unacknowledge + - if @permitted_actions.include?("clear") + %option{:value => "clear"} Clear + - if @permitted_actions.include?("unsuppress") + %option{:value => "unsuppress"} Unsuppress notifications about +- if defined? @alert + this alert +- else + these alerts +%span#hours_input + for + %input#n_hours{ :name => 'n_hours', :type => "number", :min => 0, :max => 48, :value => 2, :style => "min-width: 6ex;"} + %select#type_hours{:name => 'type_of_hours' } + -# Default to daytime hours + %option{ :value => "working" } working + %option{ :value => "daytime", :selected => "selected"} daytime + %option{ :value => "wallclock" } wall-clock + hours + %span#ack_until_text + %input#ack_until{ :value => '', :type => :hidden, :name => 'ack_until' } +%br +with the note +%input#note{ :name => 'note', :type => "text"} +%input{ :type => 'submit', :value => 'Go!' } +:javascript + // Make the hours bit disappear when clearing alerts. + $('#function').change( function() { + if( $('#function').val() == "acknowledge" || $('#function').val() == "suppress" ) { + $('#hours_input').show(); + } else { + $('#hours_input').hide(); + } + }); + // Change of value in the hours box + $('#n_hours').change( function() { + updateDate(); + }); + // As above, but on keypress, with a delay + $('#n_hours').keyup( function() { + clearTimeout($.data(this, 'timer')); + var wait = setTimeout(updateDate, 500); + $(this).data('timer', wait); + }); + // Same as the n_hours change function + $('#type_hours').change( function() { + $('#n_hours').change(); + }); + // Setup the ack text on load. + $(document).ready( function() { + $('#n_hours').change(); + $('#function').change(); + }); + diff --git a/views/alert.haml b/views/alert.haml index 6aa2e23..ef8d0f6 100644 --- a/views/alert.haml +++ b/views/alert.haml @@ -1,4 +1,4 @@ -%h1 Alert detail +%h2 Alert detail %table %tr %th.summary{:title => "Text for humans describing the nature of the alert, first 100 characters are only ones guaranteed to make it to pagers, twitter, SMS etc."} Summary @@ -60,19 +60,6 @@ %a{:href => "/events/alert/#{@alert.id}"} View full event history %h2 Actions -- if !@alert.acknowledged? - %form{:method => :post, :action => "/alert/#{@alert.id}/acknowledge"} - =partial("acknowledge_input") -- else - %form.hidden{:method => :post, :action => "/alert/#{@alert.id}/unacknowledge"} - %input{:type => :submit, :value => "Unacknowledge this alert"} -%a#hide{:onclick => "$('form.hidden').toggle(); return false", :href=>"#"} Show other actions -- if @alert.cleared? - %form.hidden{:method => :post, :action => "/alert/#{@alert.id}/raise"} - %input{:type => :submit, :value => "Raise this alert"} -- if @alert.raised? - %form.hidden{:method => :post, :action => "/alert/#{@alert.id}/clear"} - %input{:type => :submit, :value => "Clear this alert"} -%form.hidden{:method => :post, :action => "/alert/#{@alert.id}/destroy"} - %input{:type => :submit, :value => "Destroy this alert"} +%form{:method => :post, :action => "/alert/#{@alert.id}"} + =partial("alert_actions") diff --git a/views/alerts.haml b/views/alerts.haml index 88cb82c..9d3b7fc 100644 --- a/views/alerts.haml +++ b/views/alerts.haml @@ -1,7 +1,7 @@ -%form#alerts{:method => :post, :action => '/alerts/acknowledge'} +%form#alerts{:method => :post, :action => '/alerts'} = partial('alerts_table') %h2 Actions - %p= partial('acknowledge_input') + %p= partial('alert_actions') :javascript // Do the magic updates.. setTimeout("updateAlertsTable('#{@alert_type}','#{@group_by}');", 120000) diff --git a/views/search.haml b/views/search.haml index dec227a..27c59ec 100644 --- a/views/search.haml +++ b/views/search.haml @@ -13,9 +13,9 @@ =@min_length characters long. - else - %form#alerts{:method => :post, :action => '/alerts/acknowledge'} + %form#alerts{:method => :post, :action => '/alerts'} = partial('search_table') - unless @alerts.empty? %h2 Actions - %p= partial('acknowledge_input') + %p= partial('alert_actions') |