From f71c16484a72815f9690c3e91cbec5e79f757859 Mon Sep 17 00:00:00 2001 From: Digimer Date: Thu, 12 Mar 2020 00:25:17 -0400 Subject: [PATCH] * Got the fence config confirmation screen working. Signed-off-by: Digimer --- cgi-bin/striker | 128 ++++++++++++++++++++++++---- html/skins/alteeve/anvil.html | 72 ++++++++++++++++ html/skins/alteeve/main.css | 25 ++++++ share/words.xml | 1 + tools/anvil-daemon | 2 +- tools/striker-manage-install-target | 3 +- 6 files changed, 210 insertions(+), 21 deletions(-) diff --git a/cgi-bin/striker b/cgi-bin/striker index b20a3e4e..a3970183 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -1542,15 +1542,6 @@ sub sanity_check_fence_agent_form { my ($anvil, $fence_agent) = @_; - ### TODO: Left off here. Make the confirm form a table; - ### Any set options that matches the default gets set to 'subtle'. -=cut -Fence Agent: $fence_agent -Devices: -| option | default | 1 | 2 | ... -+--------+---------+-------+-------+----- -| foo | bar | bar | baz | -=cut my $sane = 1; my $confirn_form = ""; foreach my $i (1..$anvil->data->{cgi}{fence_count}{value}) @@ -1568,13 +1559,14 @@ Devices: my $description = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{description}; my $type = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{content_type}; my $default = exists $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} ? $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { - option_key => $option_key, - unique => $unique, - required => $required, - description => $description, - type => $type, - 'default' => $default, + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 's1:name' => $name, + 's2:option_key' => $option_key, + 's3:unique' => $unique, + 's4:required' => $required, + 's5:description' => $description, + 's6:type' => $type, + 's7:default' => $default, }}); # If this is 'boolean' and the default is '1', change the default to 'on' so that @@ -1585,16 +1577,40 @@ Devices: $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'default' => $default }}); } + my $is_default = 1; my $passed_parameter_key = $name."_".$i; my $passed_value = defined $anvil->data->{cgi}{$passed_parameter_key}{value} ? $anvil->data->{cgi}{$passed_parameter_key}{value} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + my $say_value = $passed_value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { passed_parameter_key => $passed_parameter_key, passed_value => $passed_value, 'default' => $default, }}); + if ($type eq "boolean") + { + $say_value = ""; + if (defined $passed_value) + { + # Yes No + $say_value = $passed_value ? "#!string!unit_0001!#" : "#!string!unit_0002!#"; + } + else + { + # Yes No + $say_value = $default ? "#!string!unit_0001!#" : "#!string!unit_0002!#"; + } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_value => $say_value }}); + } + elsif ((($type eq "string") or ($type eq "select")) && ($passed_value eq "")) + { + $say_value = "--"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_value => $say_value }}); + } + if ($passed_value ne $default) { # Something changed. Is it sane? + $is_default = 0; if (($type eq "integer") or ($type eq "second")) { # Make sure the value is a bare integer @@ -1603,7 +1619,7 @@ Devices: # Problem. $sane = 0; $anvil->data->{cgi}{$passed_parameter_key}{alert} = 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::${passed_parameter_key}::alert" => $anvil->data->{cgi}{$passed_parameter_key}{alert}, sane => $sane, }}); @@ -1616,9 +1632,16 @@ Devices: "fence::${fence_agent}::set::${i}::parameter::${name}::set" => $anvil->data->{fence}{$fence_agent}{set}{$i}{parameter}{$name}{set}, }}); } + $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'} = $is_default; + $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value} = $say_value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "fence::confirm_table::data::${name}::${i}::default" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'}, + "fence::confirm_table::data::${name}::${i}::value" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value}, + }}); } } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sane => $sane }}); return($sane); } @@ -1643,11 +1666,80 @@ sub process_fences my $fence_agent = $anvil->data->{cgi}{fence_agent}{value}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { fence_agent => $fence_agent }}); + # Are we going back to the form? + if ($anvil->data->{cgi}{back}{value}) + { + $anvil->data->{cgi}{save}{value} = ""; + $anvil->data->{cgi}{confirm}{value} = ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "cgi::save::value" => $anvil->data->{cgi}{save}{value}, + "cgi::confirm::value" => $anvil->data->{cgi}{confirm}{value}, + }}); + } + # Are we saving? if ($anvil->data->{cgi}{save}{value}) { # Sanity check my $sane = sanity_check_fence_agent_form($anvil, $fence_agent); + + if ($sane) + { + # Build the table and ask the user to confirm. + #print $anvil->Template->get({file => "shared.html", name => "http_headers"})."\n"; + #print "
\n";
+				#print Dumper $anvil->data->{fence}{confirm_table};
+				#print "
\n"; + + my $header_columns = $anvil->Template->get({file => "anvil.html", name => "fence-agent-column", variables => { + class => "column_header", + value => " ", + }}); + foreach my $i (1..$anvil->data->{cgi}{fence_count}{value}) + { + $header_columns .= $anvil->Template->get({file => "anvil.html", name => "fence-agent-column", variables => { + class => "column_header", + value => $anvil->Words->string({key => "striker_0220", variables => { number => $i }}), + }}); + } + my $confirm_table = $anvil->Template->get({file => "anvil.html", name => "fence-agent-row", variables => { + columns => $header_columns, + }}); + foreach my $name (sort {$a cmp $b} keys %{$anvil->data->{fence}{confirm_table}{data}}) + { + my $entry_row = $anvil->Template->get({file => "anvil.html", name => "fence-agent-column", variables => { + class => "column_header", + value => $name, + }}); + foreach my $i (sort {$a cmp $b} keys %{$anvil->data->{fence}{confirm_table}{data}{$name}}) + { + my $is_default = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'}; + my $value = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 's1:name' => $name, + 's2:i' => $i, + 's3:is_default' => $is_default, + 's4:value' => $value, + }}); + $entry_row .= $anvil->Template->get({file => "anvil.html", name => "fence-agent-column-hidden-value", variables => { + class => $is_default ? "default_value" : "changed_value", + name => $name."_".$i, + value => $value, + }}); + } + $confirm_table .= $anvil->Template->get({file => "anvil.html", name => "fence-agent-row", variables => { + columns => $entry_row, + }}); + } + + $anvil->data->{form}{back_link} = "?anvil=true&task=fences"; + $anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "fence-agent-confirm", variables => { + table => $confirm_table, + span_count => $anvil->data->{cgi}{fence_count}{value}, + }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }}); + return(0); + } } my $agent_description = format_fence_description($anvil, $fence_agent, $anvil->data->{fences}{$fence_agent}{description}); diff --git a/html/skins/alteeve/anvil.html b/html/skins/alteeve/anvil.html index bfff757b..2d8e198f 100644 --- a/html/skins/alteeve/anvil.html +++ b/html/skins/alteeve/anvil.html @@ -127,6 +127,78 @@ + + + #!variable!columns!# + + + + + + #!variable!value!# + + + + + + #!variable!value!# + + + + + + + + + + + + + + + + + + + + + + + +
+   +
+ + + #!string!striker_0215!# +
+   +
+
+ + #!variable!table!# + + + + + + + + + +
+  
+ +
+  
+ +
+
+
+   +
+ + diff --git a/html/skins/alteeve/main.css b/html/skins/alteeve/main.css index 4f45d9f3..a9e56a1d 100644 --- a/html/skins/alteeve/main.css +++ b/html/skins/alteeve/main.css @@ -61,6 +61,14 @@ body { padding: 0.15em; } +.column_header_veritcal { + text-align: left; + vertical-align: bottom; + color: #9ba0a5; + padding: 0.15em; + transform: rotate(-90deg); +} + .config_header1 { color: #f7f7f7; text-align: center; @@ -364,6 +372,13 @@ td.column_row_value_centered { padding: 0.2em; } +td.column_row_value_centered_border { + text-align: center; + color: #f7f7f7; + padding: 0.2em; + border: 1px solid #8f8f8f; +} + .fixed_link { text-align: left; color: #f7f7f7; @@ -460,6 +475,16 @@ tr.data_row { text-align: center; } +.changed_value { + color: #00934d; + text-align: center; +} + +.default_value { + color: #f2f2f2; + text-align: center; +} + table.list { /* margin-left: auto; */ /* margin-right: auto; */ diff --git a/share/words.xml b/share/words.xml index e9164c45..c196b152 100644 --- a/share/words.xml +++ b/share/words.xml @@ -1089,6 +1089,7 @@ If you are comfortable that the target has changed for a known reason, you can s Options description (from the agent's metadata): Note: Names and descriptions come from the fence agent itself. If you need more help, please run 'man #!variable!name!#' at the command line. Required field + Device #!variable!number!#: #!variable!number!#/sec diff --git a/tools/anvil-daemon b/tools/anvil-daemon index fbfb200d..0a0866c9 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -294,7 +294,7 @@ sub check_if_mapping } } - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::mapping_network" => $anvil->data->{sys}{mapping_network} }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "sys::mapping_network" => $anvil->data->{sys}{mapping_network} }}); return($anvil->data->{sys}{mapping_network}); } diff --git a/tools/striker-manage-install-target b/tools/striker-manage-install-target index 37d49b67..c2ba2334 100755 --- a/tools/striker-manage-install-target +++ b/tools/striker-manage-install-target @@ -1195,8 +1195,7 @@ sub update_install_source } update_progress($anvil, 85, ""); - $output = ""; - ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{createrepo_c}." -g ".$comps_xml." ".$repo_path }); + my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{createrepo_c}." -g ".$comps_xml." ".$repo_path }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output => $output, return_code => $return_code }}); print $anvil->Words->string({key => "message_0130"})."\n"; update_progress($anvil, 90, "message_0130");