* Got the fence config confirmation screen working.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 81f62d6457
commit f71c16484a
  1. 128
      cgi-bin/striker
  2. 72
      html/skins/alteeve/anvil.html
  3. 25
      html/skins/alteeve/main.css
  4. 1
      share/words.xml
  5. 2
      tools/anvil-daemon
  6. 3
      tools/striker-manage-install-target

@ -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 "<pre>\n";
#print Dumper $anvil->data->{fence}{confirm_table};
#print "</pre>\n";
my $header_columns = $anvil->Template->get({file => "anvil.html", name => "fence-agent-column", variables => {
class => "column_header",
value => "&nbsp;",
}});
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});

@ -127,6 +127,78 @@
</table>
<!-- end fence-agent-configuration -->
<!-- start fence-agent-row -->
<tr>
#!variable!columns!#
</tr>
<!-- end fence-agent-row -->
<!-- start fence-agent-column -->
<td class="column_row_value_centered_border">
<span class="#!variable!class!#">#!variable!value!#</span>
</td>
<!-- end fence-agent-column -->
<!-- start fence-agent-column-hidden-value -->
<td class="column_row_value_centered_border">
<span class="#!variable!class!#">#!variable!value!#</span>
<input type="hidden" name="#!variable!name!#" id="#!variable!name!#" value="#!variable!value!#" />
</td>
<!-- end fence-agent-column-hidden-value -->
<!-- start fence-agent-confirm -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<img src="#!data!skin::url!#/images/fence.png" class="top_icon" >
</td>
<td class="title">
#!string!striker_0215!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<form name="conce_configuration" action="" method="post">
<table class="data_table">
#!variable!table!#
<tr>
<td class="close_top">
&nbsp;<br />
<input type="submit" name="back" id="back" value="#!string!striker_0098!#" class="button">
</td>
<td class="close_top" style="text-align: right;" colspan="#!variable!span_count!#">
&nbsp;<br />
<input type="submit" name="save" id="save" value="#!string!striker_0067!#" class="button">
</td>
<input type="hidden" name="fence_agent" id="fence_agent" value="#!data!cgi::fence_agent::value!#">
<input type="hidden" name="fence_count" id="fence_count" value="#!data!cgi::fence_count::value!#">
<input type="hidden" name="add" id="add" value="true">
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="fences">
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
</table>
<!-- end fence-agent-confirm -->
<!-- start fence-agent-option-menu -->
<tr>
<td colspan="3" class="menu_title">

@ -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; */

@ -1089,6 +1089,7 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0217">Options description (from the agent's metadata):</key>
<key name="striker_0218">Note: Names and descriptions come from the fence agent itself. If you need more help, please run 'man #!variable!name!#' at the command line.</key>
<key name="striker_0219">Required field</key>
<key name="striker_0220">Device #!variable!number!#:</key>
<!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key>

@ -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});
}

@ -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");

Loading…
Cancel
Save