From 4ca1b2c8db777cd1e389a227072b1cd108e23d05 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 16 Jun 2011 16:09:08 +0100 Subject: Updated web interface to use a Sinatra layout. --- lib/mauve/web_interface.rb | 102 +++++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 27 deletions(-) (limited to 'lib/mauve/web_interface.rb') diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb index 721fc3f..d999554 100644 --- a/lib/mauve/web_interface.rb +++ b/lib/mauve/web_interface.rb @@ -44,7 +44,23 @@ module Mauve set :dump_errors, true # ...will dump errors to the log set :raise_errors, false # ...will not let exceptions out to main program set :show_exceptions, false # ...will not show exceptions - + + # + # Default template. + # + template :layout do + < [b[1].first, b[0]] end end + + def alerts_table(params) + find_active_alerts + + if %w(raised cleared acknowledged).include?(params[:alert_type]) + @alert_type = params[:alert_type] + else + @alert_type = "raised" + end + + if %w(subject source summary id alert_id level).include?(params[:group_by]) + @group_by = params[:group_by] + else + @group_by = "subject" + end + + @title += " Alerts " + + + case @alert_type + when "raised" + @grouped_alerts = group_by(@alerts_raised, @group_by) + when "acknowledged" + @grouped_alerts = group_by(@alerts_ackd, @group_by) + haml(:alerts) + else + haml(:not_implemented) + end + end def find_active_alerts @alerts_raised = Alert.all_raised -- cgit v1.2.1