* Finished the jquery (for now) to pre-fill the step 2 form.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 2ea506b4d9
commit c208d676cb
  1. 100
      cgi-bin/home
  2. 30
      html/skins/alteeve/config.js
  3. 2
      html/skins/alteeve/main.css
  4. 2
      html/skins/alteeve/main.html

@ -448,8 +448,8 @@ ORDER BY
push @{$links}, "bcn_link".$bcn; push @{$links}, "bcn_link".$bcn;
my $this_ip_key = "bcn".$bcn."_ip"; my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet"; my $this_subnet_key = "bcn".$bcn."_subnet";
my $this_iface1_key = "bcn".$bcn."_iface1_mac"; my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set";
my $this_iface2_key = "bcn".$bcn."_iface2_mac"; my $this_iface2_key = "bcn".$bcn."_link2_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.","; $cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.",";
my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
@ -475,17 +475,18 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}),
description => "#!string!striker_0019!#", description => "#!string!striker_0019!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_key => $this_subnet_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{'default'}{network}{bcn}{netmask}, subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "",
subnet_class => $this_subnet_class, subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask},
iface1_select => $this_iface1_form, subnet_class => $this_subnet_class,
iface2_select => $this_iface2_form, iface1_select => $this_iface1_form,
iface2_select => $this_iface2_form,
}}); }});
} }
@ -496,8 +497,8 @@ ORDER BY
push @{$links}, "ifn_link".$ifn; push @{$links}, "ifn_link".$ifn;
my $this_ip_key = "ifn".$ifn."_ip"; my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet"; my $this_subnet_key = "ifn".$ifn."_subnet";
my $this_iface1_key = "ifn".$ifn."_iface1_mac"; my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set";
my $this_iface2_key = "ifn".$ifn."_iface2_mac"; my $this_iface2_key = "ifn".$ifn."_link2_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.","; $cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.",";
my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
@ -523,17 +524,18 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}),
description => "#!string!striker_0023!#", description => "#!string!striker_0023!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_key => $this_subnet_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{'default'}{network}{ifn}{netmask}, subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "",
subnet_class => $this_subnet_class, subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask},
iface1_select => $this_iface1_form, subnet_class => $this_subnet_class,
iface2_select => $this_iface2_form, iface1_select => $this_iface1_form,
iface2_select => $this_iface2_form,
}}); }});
} }
} }
@ -547,7 +549,7 @@ ORDER BY
push @{$links}, "bcn_link".$bcn; push @{$links}, "bcn_link".$bcn;
my $this_ip_key = "bcn".$bcn."_ip"; my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet"; my $this_subnet_key = "bcn".$bcn."_subnet";
my $this_iface1_key = "bcn".$bcn."_iface1_mac"; my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.","; $cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",";
my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
@ -565,16 +567,17 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}),
description => "#!string!striker_0019!#", description => "#!string!striker_0019!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_key => $this_subnet_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{'default'}{network}{bcn}{netmask}, subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{bcn}{netmask},
subnet_class => $this_subnet_class, subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask},
iface1_select => $this_iface1_form, subnet_class => $this_subnet_class,
iface1_select => $this_iface1_form,
}}); }});
} }
@ -585,7 +588,7 @@ ORDER BY
push @{$links}, "ifn_link".$ifn; push @{$links}, "ifn_link".$ifn;
my $this_ip_key = "ifn".$ifn."_ip"; my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet"; my $this_subnet_key = "ifn".$ifn."_subnet";
my $this_iface1_key = "ifn".$ifn."_iface1_mac"; my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.","; $cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",";
my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
@ -603,16 +606,17 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}),
description => "#!string!striker_0023!#", description => "#!string!striker_0023!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_key => $this_subnet_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{'default'}{network}{ifn}{netmask}, subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{ifn}{netmask},
subnet_class => $this_subnet_class, subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask},
iface1_select => $this_iface1_form, subnet_class => $this_subnet_class,
iface1_select => $this_iface1_form,
}}); }});
} }
} }

@ -44,16 +44,7 @@ $( window ).on( "load", function()
//window.history.pushState('object', document.title, newURL); //window.history.pushState('object', document.title, newURL);
//console.log('onload fired.'); //console.log('onload fired.');
/* // Walk through the network.json file and use it to pre-fill the form.
if($("#interface_list").val()) {
var interface_list = $('#interface_list').val();
console.log('Interface list: ['+interface_list+'].');
jQuery.each(interface_list.split(","), function(index, item) {
console.log('Interface: ['+item+'].');
});
}
*/
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) { $.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.ips, function(index, element) { $.each(data.ips, function(index, element) {
//console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].'); //console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].');
@ -109,8 +100,8 @@ $( window ).on( "load", function()
//console.log(network+' count: ['+count+'].'); //console.log(network+' count: ['+count+'].');
for (var i = 1; i <= count; i++) { for (var i = 1; i <= count; i++) {
var network_name = network+i; var network_name = network+i;
console.log('Network: ['+network_name+'], IP set: ['+$("#"+network_name+"_ip").val()+'/'+$("#"+network_name+"_subnet").val()+'].'); //console.log('Network: ['+network_name+'], IP set: ['+$("#"+network_name+"_ip").val()+'/'+$("#"+network_name+"_subnet").val()+'].');
console.log('- default: ['+$("#"+network_name+"_ip_default").val()+'/'+$("#"+network_name+"_subnet_default").val()+'].'); //console.log('- default: ['+$("#"+network_name+"_ip_default").val()+'/'+$("#"+network_name+"_subnet_default").val()+'].');
if ($("#"+network_name+"_ip").val() == '') if ($("#"+network_name+"_ip").val() == '')
{ {
@ -126,5 +117,20 @@ $( window ).on( "load", function()
}; };
}); });
// Look for interfaces with names we recognize and use them to select interfaces from the
// select lists.
$.each(data.networks, function(index, element) {
//console.log('Entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'].');
var mac_key = element.name+'_mac_to_set';
if ($("#"+mac_key).length) {
var select_value = $('#'+mac_key).find(":selected").text();
//console.log('- Field exists, current value: ['+select_value+'].');
if (select_value == '') {
//console.log('- Setting to: ['+element.mac+'].');
$("#"+mac_key).val(element.mac);
}
}
});
}); });
}) })

@ -51,7 +51,7 @@ select {
background-color: #343434; background-color: #343434;
color: #f7f7f7; color: #f7f7f7;
font-family: 'Dejavu Sans Mono', 'Courier 10 pitch', monospace, Courier; font-family: 'Dejavu Sans Mono', 'Courier 10 pitch', monospace, Courier;
font-size: 1.1em; font-size: 1.0em;
} }
body { body {

@ -539,6 +539,7 @@
</td> </td>
<td> <td>
<input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#"> <input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#">
<input type="hidden" name="#!variable!subnet_key!#_default" id="#!variable!subnet_key!#_default" value="#!variable!subnet_value_default!#">
</td> </td>
<td> <td>
&nbsp; &nbsp;
@ -589,6 +590,7 @@
</td> </td>
<td> <td>
<input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#"> <input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#">
<input type="hidden" name="#!variable!subnet_key!#_default" id="#!variable!subnet_key!#_default" value="#!variable!subnet_value_default!#">
</td> </td>
<td> <td>
&nbsp; &nbsp;

Loading…
Cancel
Save