diff --git a/cgi-bin/striker b/cgi-bin/striker index b6e83549..579529d6 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -500,39 +500,60 @@ sub process_keys ### TODO: Left off here... Create a check-box list of state_uuid(s) the user selected, if any, and store them as a comma-separated list. ### NOTE: This doesn't update Striker (the Alteeve) stack yet, just the base OK. - $anvil->data->{cgi}{confirm}{value} = "" if not defined $anvil->data->{cgi}{confirm}{value}; - if ($anvil->data->{cgi}{confirm}{value}) + my $show_list = 1; + $anvil->data->{cgi}{'delete'}{value} = "" if not defined $anvil->data->{cgi}{'delete'}{value}; + if ($anvil->data->{cgi}{'delete'}{value}) { # Record the job! my $job_data = ""; + foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{cgi}}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { key => $key }}); + if ($key =~ /^state_uuid_(.*)$/) + { + my $state_uuid = $1; + $show_list = 0; + $job_data .= $state_uuid.","; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + state_uuid => $state_uuid, + show_list => $show_list, + job_data => $job_data, + }}); + } + } + $job_data =~ s/,$//; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_data => $job_data }}); - - die; - my ($job_uuid) = $anvil->Database->insert_or_update_jobs({ - file => $THIS_FILE, - line => __LINE__, - job_command => $anvil->data->{path}{exe}{'anvil-manage-keys'}, - job_data => "", - job_name => "manage::keys", - job_title => "job_0056", - job_description => "job_0057", - job_progress => 0, - job_host_uuid => $anvil->data->{sys}{host_uuid}, - }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }}); - - # We don't need to store anything as hidden variables, we'll read it back from the database - # later. - $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "job recorded", variables => { - title_id => "", - message_id => "", - reload_url => "/cgi-bin/".$THIS_FILE, - title => "#!string!job_0056!#", - description => "#!string!job_0057!#", - }}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }}); + if ($job_data) + { + my ($job_uuid) = $anvil->Database->insert_or_update_jobs({ + file => $THIS_FILE, + line => __LINE__, + job_command => $anvil->data->{path}{exe}{'anvil-manage-keys'}, + job_data => $job_data, + job_name => "manage::broken_keys", + job_title => "job_0056", + job_description => "job_0057", + job_progress => 0, + job_host_uuid => $anvil->data->{sys}{host_uuid}, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }}); + + # We don't need to store anything as hidden variables, we'll read it back from the database + # later. + $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "job recorded", variables => { + title_id => "", + message_id => "", + reload_url => "/cgi-bin/".$THIS_FILE, + title => "#!string!job_0056!#", + description => "#!string!job_0057!#", + }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }}); + } } - else + + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { show_list => $show_list }}); + if ($show_list) { # Get a list of bad keys we know about and ask the user which they want to remove my $query = " @@ -543,7 +564,7 @@ SELECT state_note FROM states -AND +WHERE state_name LIKE 'host_key_changed::%' ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); @@ -575,16 +596,58 @@ AND state_name => $state_name, state_note => $state_note, }}); + + my $bad_file = ""; + my $bad_line = ""; + foreach my $pair (split/,/, $state_note) + { + my ($variable, $value) = ($pair =~ /^(.*?)=(.*)$/); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + pair => $pair, + variable => $variable, + value => $value, + }}); + if ($variable eq "file") + { + $bad_file = $value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bad_file => $bad_file }}); + } + if ($variable eq "line") + { + $bad_line = $value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bad_line => $bad_line }}); + } + } + my ($target, $user) = ($state_name =~ /host_key_changed::(.*)::(.*)$/); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + target => $target, + user => $user, + bad_file => $bad_file, + bad_line => $bad_line, + }}); + + + my $checkbox_key = "state_uuid_".$state_uuid; + my $checked = ""; + if ((exists $anvil->data->{cgi}{$checkbox_key}) && ($anvil->data->{cgi}{$checkbox_key}{value})) + { + $checked = "checked"; + } + $bad_key_list .= $anvil->Template->get({file => "striker.html", name => "broken-key-entry", variables => { + checkbox_name => $checkbox_key, + checkbox_checked => $checked, + target => $target, + user => $user, + file => $bad_file, + line => $bad_line, + }}); } + + #Show the screen the confirm the addition. + $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "broken-key-list", variables => { + bad_keys => $bad_key_list, + }}); } - - die; - #Show the screen the confirm the addition. - $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "confirm-action", variables => { - title => "#!string!job_0056!#", - message => "#!string!!#", - hidden_fields => "", - }}); } return(0); diff --git a/html/skins/alteeve/main.css b/html/skins/alteeve/main.css index 811182fd..a56b3599 100644 --- a/html/skins/alteeve/main.css +++ b/html/skins/alteeve/main.css @@ -15,6 +15,9 @@ a { color: #f2f2f2; text-decoration: none; } +a.highlight { + color: #ff80ee; +} body { font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif; @@ -367,3 +370,9 @@ tr.data_row { text-align: left; font-size: 0.9em; } + +.warning { + color: #dc9012; + font-size: 1.1em; + font-weight: bold; +} diff --git a/html/skins/alteeve/striker.html b/html/skins/alteeve/striker.html index f192bbc9..fbe65501 100644 --- a/html/skins/alteeve/striker.html +++ b/html/skins/alteeve/striker.html @@ -1,3 +1,96 @@ + +
+ #!string!striker_0133!# + | +
+ #!string!striker_0137!# + | +
+ + | +
+ |
+
+ + | +