aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-06-16 16:09:08 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-06-16 16:09:08 +0100
commit4ca1b2c8db777cd1e389a227072b1cd108e23d05 (patch)
tree20c3b89ae8dfbe839f1ab73334ff409e306a4fa5 /views
parent0b553879d0606b3f24047302e8958f9610341f2b (diff)
Updated web interface to use a Sinatra layout.
Diffstat (limited to 'views')
-rw-r--r--views/_alerts_table.haml31
-rw-r--r--views/_head.haml1
-rw-r--r--views/_navbar.haml15
-rw-r--r--views/alert.haml156
-rw-r--r--views/alerts.haml41
-rw-r--r--views/login.haml28
-rw-r--r--views/not_implemented.haml8
7 files changed, 143 insertions, 137 deletions
diff --git a/views/_alerts_table.haml b/views/_alerts_table.haml
index f413c30..99a4e13 100644
--- a/views/_alerts_table.haml
+++ b/views/_alerts_table.haml
@@ -1,19 +1,14 @@
-%form#alerts{:method => :post, :action => '/alerts/acknowledge'}
- %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;
- });
+%table#alerts_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 At
- = partial("alerts_table_group", :collection => @grouped_alerts)
- %tr
- %td &nbsp;
- %td{:colspan => 2}
- = partial("acknowledge_input")
+ });
+ %th#summary Summary
+ %th#time At
+ = partial("alerts_table_group", :collection => @grouped_alerts)
diff --git a/views/_head.haml b/views/_head.haml
index 981aaf1..642d408 100644
--- a/views/_head.haml
+++ b/views/_head.haml
@@ -5,4 +5,5 @@
%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 => '/javascript/jquery.periodicalupdater.js', :type => 'text/javascript'}
%script{:src => '/javascript/mauve_utils.js', :type => 'text/javascript'}
diff --git a/views/_navbar.haml b/views/_navbar.haml
index 4f81450..5df4991 100644
--- a/views/_navbar.haml
+++ b/views/_navbar.haml
@@ -4,11 +4,20 @@
%a{:href => "/"} Mauve
- if @person
%li{:class => [ @alert_type == "raised" && "nav_selected"]}
- %a{:href => '/alerts/raised/'+@group_by} Raised (#{@alerts_raised.length})
+ %a{:href => '/alerts/raised/'+@group_by}
+ Raised (
+ %span#count_raised><= @alerts_raised.length
+ )
%li{:class => [ @alert_type == "acknowledged" && "nav_selected"]}
- %a{:href => '/alerts/acknowledged/'+@group_by} Ack'd (#{@alerts_ackd.length})
+ %a{:href => '/alerts/acknowledged/'+@group_by}
+ Ack'd (
+ %span#count_ackd><= @alerts_ackd.length
+ )
%li{:class => [ @alert_type == "cleared" && "nav_selected"]}
- %a{:href => '/alerts/cleared/'+@group_by} Cleared (#{@alerts_cleared.length})
+ %a{:href => '/alerts/cleared/'+@group_by}
+ Cleared (
+ %span#count_cleared><= @alerts_cleared.length
+ )
%li
%a{:href => '/logout'} Log out
%br
diff --git a/views/alert.haml b/views/alert.haml
index 0486770..b752f35 100644
--- a/views/alert.haml
+++ b/views/alert.haml
@@ -1,82 +1,76 @@
-!!!5
-%html
- = partial('head')
- %body
- =partial("navbar")
- .container
- %h1 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
- %td= @alert.summary
- %tr
- %th.summary{:title => "The server/entity that this alert concerns"} Subject
- %td= @alert.subject
- %tr
- %th{:title => "The server/entitiy that originated the alert"} Source
- %td= @alert.source
- %tr
- %th{:title => "HTML fragment describing the alert in more detail, no limit on length."} Detail
- %td
- :textile
- #{@alert.detail}
- %tr
- %th{:title => "ID set by the source of the alert."} Alert ID
- %td= @alert.alert_id
- %tr
- %th{:title => "The groups in the Mauve server configuration that match this alert"} Alert groups
- %td= Mauve::AlertGroup.matches(@alert).map{|g| g.name}.join("; ")
- %tr
- %th{:title => "The level of the first group in the Mauve server configuration that matched this alert"} Alert level
- %td= @alert.level.to_s.upcase
- -if @alert.raised?
- %tr
- %th{:title => "The time at which the alert was raised"} Raised at
- %td= @alert.raised_at.to_s_human
- -if @alert.acknowledged?
- %tr
- %th{:title => "The time at which the alert was acknowledged"} Acknowledged at
- %td= @alert.acknowledged_at.to_s_human + " by " + @alert.acknowledged_by + " until " + @alert.will_unacknowledge_at.to_s_human
- -if @alert.will_raise_at
- %tr
- %th{:title => "The time at which the alert will be automatically raised"} Will raise at
- %td= @alert.will_raise_at.to_s_human
- -if @alert.cleared_at
- %tr
- %th{:title => "The time at which the alert was last cleared"} Last cleared at
- %td= @alert.cleared_at.to_s_human
- -if @alert.will_clear_at
- %tr
- %th{:title => "The time at which the alert will be automatically cleared"} Will clear
- %td= @alert.will_raise_at.to_s_human
- %tr
- %th Notifications sent out
- %td
- %ul
- - @alert.changes.each do |change|
- - if change.was_relevant?
- %li
- %strong= change.level
- = change.update_type
- notification to
- = change.person
- at
- = change.at.to_s_human
-
- %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"}
+%h1 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
+ %td= @alert.summary
+ %tr
+ %th.summary{:title => "The server/entity that this alert concerns"} Subject
+ %td= @alert.subject
+ %tr
+ %th{:title => "The server/entitiy that originated the alert"} Source
+ %td= @alert.source
+ %tr
+ %th{:title => "HTML fragment describing the alert in more detail, no limit on length."} Detail
+ %td
+ :textile
+ #{@alert.detail}
+ %tr
+ %th{:title => "ID set by the source of the alert."} Alert ID
+ %td= @alert.alert_id
+ %tr
+ %th{:title => "The groups in the Mauve server configuration that match this alert"} Alert groups
+ %td= Mauve::AlertGroup.matches(@alert).map{|g| g.name}.join("; ")
+ %tr
+ %th{:title => "The level of the first group in the Mauve server configuration that matched this alert"} Alert level
+ %td= @alert.level.to_s.upcase
+ -if @alert.raised?
+ %tr
+ %th{:title => "The time at which the alert was raised"} Raised at
+ %td= @alert.raised_at.to_s_human
+ -if @alert.acknowledged?
+ %tr
+ %th{:title => "The time at which the alert was acknowledged"} Acknowledged at
+ %td= @alert.acknowledged_at.to_s_human + " by " + @alert.acknowledged_by + " until " + @alert.will_unacknowledge_at.to_s_human
+ -if @alert.will_raise_at
+ %tr
+ %th{:title => "The time at which the alert will be automatically raised"} Will raise at
+ %td= @alert.will_raise_at.to_s_human
+ -if @alert.cleared_at
+ %tr
+ %th{:title => "The time at which the alert was last cleared"} Last cleared at
+ %td= @alert.cleared_at.to_s_human
+ -if @alert.will_clear_at
+ %tr
+ %th{:title => "The time at which the alert will be automatically cleared"} Will clear
+ %td= @alert.will_raise_at.to_s_human
+ %tr
+ %th Notifications sent out
+ %td
+ %ul
+ - @alert.changes.each do |change|
+ - if change.was_relevant?
+ %li
+ %strong= change.level
+ = change.update_type
+ notification to
+ = change.person
+ at
+ = change.at.to_s_human
+
+%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"}
diff --git a/views/alerts.haml b/views/alerts.haml
index 2d871cc..aedbc72 100644
--- a/views/alerts.haml
+++ b/views/alerts.haml
@@ -1,12 +1,31 @@
-!!! 5
-%html
- = partial('head')
- %body
- =partial("navbar")
- .container
- - if @grouped_alerts.length > 0
- = partial('alerts_table')
- - else
- .notice
- %p No alerts to display.
+- if @grouped_alerts.length > 0
+ %form#alerts{:method => :post, :action => '/alerts/acknowledge'}
+ = partial('alerts_table')
+ %h2 Actions
+ %p= partial('acknowledge_input')
+- else
+ .notice#alerts_table
+ %p No alerts to display.
+:javascript
+ $(document).ready( function() {
+ $.PeriodicalUpdater({
+ url: '/ajax/alerts_table/#{@alert_type}/#{@group_by}',
+ minTimeout: 10000,
+ maxTimeout: 30000,
+ }, function(alerts_table, success, xhr, handle){
+ $('#alerts_table').replaceWith(alerts_table);
+ });
+ $.PeriodicalUpdater({
+ url: '/ajax/alert_counts',
+ minTimeout: 10000,
+ maxTimeout: 30000,
+ }, function(alert_counts, success, xhr, handle){
+ var counts = jQuery.parseJSON( alert_counts );
+ $('#count_raised').html(counts[0]+counts[1]+counts[2]);
+ $('#count_ackd').html(counts[3]);
+ $('#count_cleared').html(counts[4]);
+ return false;
+ });
+
+ });
diff --git a/views/login.haml b/views/login.haml
index 06e5320..3deee76 100644
--- a/views/login.haml
+++ b/views/login.haml
@@ -1,17 +1,11 @@
-!!! 5
-%html
- =partial("head")
- %body
- = partial('navbar')
- .container
- %form{:action => '/login', :method => :POST}
- %fieldset
- %legend Please log in
- %label{:for => "username"} Username
- %input{:name => 'username', :type => 'text', :autocorrect => "off", :autocapitalize => "off"}/
- %br
- %label{:for => "password", :title => "This is either your Single Sign On password or a PIN."} Password / PIN
- %input{:name => 'password', :type => 'password'}/
- %br
- %input{:type => 'hidden', :name => 'next_page', :value => @next_page}/
- %input{:type => 'submit', :value => 'Log in'}/
+%form{:action => '/login', :method => :POST}
+ %fieldset
+ %legend Please log in
+ %label{:for => "username"} Username
+ %input{:name => 'username', :type => 'text', :autocorrect => "off", :autocapitalize => "off"}/
+ %br
+ %label{:for => "password", :title => "This is either your Single Sign On password or a PIN."} Password / PIN
+ %input{:name => 'password', :type => 'password'}/
+ %br
+ %input{:type => 'hidden', :name => 'next_page', :value => @next_page}/
+ %input{:type => 'submit', :value => 'Log in'}/
diff --git a/views/not_implemented.haml b/views/not_implemented.haml
index a07b00d..dd3fe15 100644
--- a/views/not_implemented.haml
+++ b/views/not_implemented.haml
@@ -1,7 +1 @@
-!!! 5
-%html
- = partial('head')
- %body
- =partial("navbar")
- .container
- .error Not implemented
+.error Not implemented