diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/_search_table.haml | 21 | ||||
-rw-r--r-- | views/_search_table_row.haml | 18 | ||||
-rw-r--r-- | views/search.haml | 21 |
3 files changed, 60 insertions, 0 deletions
diff --git a/views/_search_table.haml b/views/_search_table.haml new file mode 100644 index 0000000..14a9cfa --- /dev/null +++ b/views/_search_table.haml @@ -0,0 +1,21 @@ +%table#search_table + %tr + %th#selector + %input#toggle_all{ :type => "checkbox" } + :javascript + // This just toggles all the checkboxes. + $('#toggle_all').change( function() { + $('input.alert').each( function(index) { + this.checked = !this.checked; + }); + }); + %th#summary Summary + %th#time Last update + - if @alerts.length > 0 + = partial("search_table_row", :collection => @alerts) + - else + %tr{:class => %w(notice)} + %td + %td{:style => "text-align: center;"} + = "No alerts found!" + %td diff --git a/views/_search_table_row.haml b/views/_search_table_row.haml new file mode 100644 index 0000000..3226bc7 --- /dev/null +++ b/views/_search_table_row.haml @@ -0,0 +1,18 @@ +- alert = search_table_row if defined? search_table_row +- row_class = (row_class || []) + [ cycle(nil, "hilight"), alert.raised? && "triggered", alert.acknowledged? && "acknowledged", alert.level] +%tr{ :class => row_class, :id => ["tr", "summary", alert.id] } + %td + %input{ :type => "checkbox", :id => "alerts[#{alert.id}]", :name => "alerts[#{alert.id}]", :class => 'alert' } + %td + %label{ :for => "alerts[#{alert.id}]" } + %strong= alert.subject + = alert.summary + - if alert.suppressed? + (suppressed) + %a{ :id => ["a","detail", alert.id], | + :href => "/alert/#{alert.id}", | + :onclick => "fetchDetail('#{alert.id}'); return false;"} + Details ↓ + %td + = (alert.update_type || "cleared").capitalize + = ((alert.raised? && alert.raised_at) || (alert.acknowledged? && alert.acknowledged_at) || alert.cleared_at || alert.updated_at || Time.now).to_s_relative diff --git a/views/search.haml b/views/search.haml new file mode 100644 index 0000000..dec227a --- /dev/null +++ b/views/search.haml @@ -0,0 +1,21 @@ +%h2 Search +%form{:method => "GET", :action => '/search'} + %p + %label{:for => "q"} + Search for + %input{:type => "text", :name => "q", :value => "#{@q}"} + %input{:type => "submit", :name => "submit", :value => "Search"} +- unless @q.nil? + - if @q.length < @min_length and @alerts.empty? + %div{:class => ["error"]} + %p + Search terms must be at least + =@min_length + characters long. + - else + %form#alerts{:method => :post, :action => '/alerts/acknowledge'} + = partial('search_table') + - unless @alerts.empty? + %h2 Actions + %p= partial('acknowledge_input') + |