From c208d676cb256ef03cc05435b19348b9795c1935 Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 18 Jun 2018 01:24:19 -0400 Subject: [PATCH] * Finished the jquery (for now) to pre-fill the step 2 form. Signed-off-by: Digimer --- cgi-bin/home | 100 ++++++++++++++++++----------------- html/skins/alteeve/config.js | 30 ++++++----- html/skins/alteeve/main.css | 2 +- html/skins/alteeve/main.html | 2 + 4 files changed, 73 insertions(+), 61 deletions(-) diff --git a/cgi-bin/home b/cgi-bin/home index 746f1142..cabf2037 100755 --- a/cgi-bin/home +++ b/cgi-bin/home @@ -448,8 +448,8 @@ ORDER BY push @{$links}, "bcn_link".$bcn; my $this_ip_key = "bcn".$bcn."_ip"; my $this_subnet_key = "bcn".$bcn."_subnet"; - my $this_iface1_key = "bcn".$bcn."_iface1_mac"; - my $this_iface2_key = "bcn".$bcn."_iface2_mac"; + my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set"; + my $this_iface2_key = "bcn".$bcn."_link2_mac_to_set"; $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_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; @@ -475,17 +475,18 @@ ORDER BY # Assemble the form $interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => { - field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), - description => "#!string!striker_0019!#", - ip_key => $this_ip_key, - ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", - ip_value_default => $this_ip, - ip_class => $this_ip_class, - 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_class => $this_subnet_class, - iface1_select => $this_iface1_form, - iface2_select => $this_iface2_form, + field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), + description => "#!string!striker_0019!#", + ip_key => $this_ip_key, + ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", + ip_value_default => $this_ip, + ip_class => $this_ip_class, + subnet_key => $this_subnet_key, + subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "", + subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask}, + subnet_class => $this_subnet_class, + iface1_select => $this_iface1_form, + iface2_select => $this_iface2_form, }}); } @@ -496,8 +497,8 @@ ORDER BY push @{$links}, "ifn_link".$ifn; my $this_ip_key = "ifn".$ifn."_ip"; my $this_subnet_key = "ifn".$ifn."_subnet"; - my $this_iface1_key = "ifn".$ifn."_iface1_mac"; - my $this_iface2_key = "ifn".$ifn."_iface2_mac"; + my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set"; + my $this_iface2_key = "ifn".$ifn."_link2_mac_to_set"; $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_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; @@ -523,17 +524,18 @@ ORDER BY # Assemble the form $interface_form .= $anvil->Template->get({file => "main.html", name => "bonded_interface_form", variables => { - field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), - description => "#!string!striker_0023!#", - ip_key => $this_ip_key, - ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", - ip_value_default => $this_ip, - ip_class => $this_ip_class, - 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_class => $this_subnet_class, - iface1_select => $this_iface1_form, - iface2_select => $this_iface2_form, + field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), + description => "#!string!striker_0023!#", + ip_key => $this_ip_key, + ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", + ip_value_default => $this_ip, + ip_class => $this_ip_class, + subnet_key => $this_subnet_key, + subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "", + subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask}, + subnet_class => $this_subnet_class, + iface1_select => $this_iface1_form, + iface2_select => $this_iface2_form, }}); } } @@ -547,7 +549,7 @@ ORDER BY push @{$links}, "bcn_link".$bcn; my $this_ip_key = "bcn".$bcn."_ip"; 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.","; 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"; @@ -565,16 +567,17 @@ ORDER BY # Assemble the form $interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => { - field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), - description => "#!string!striker_0019!#", - ip_key => $this_ip_key, - ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", - ip_value_default => $this_ip, - ip_class => $this_ip_class, - 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_class => $this_subnet_class, - iface1_select => $this_iface1_form, + field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), + description => "#!string!striker_0019!#", + ip_key => $this_ip_key, + ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", + ip_value_default => $this_ip, + ip_class => $this_ip_class, + subnet_key => $this_subnet_key, + subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{bcn}{netmask}, + subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask}, + subnet_class => $this_subnet_class, + iface1_select => $this_iface1_form, }}); } @@ -585,7 +588,7 @@ ORDER BY push @{$links}, "ifn_link".$ifn; my $this_ip_key = "ifn".$ifn."_ip"; 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.","; 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"; @@ -603,16 +606,17 @@ ORDER BY # Assemble the form $interface_form .= $anvil->Template->get({file => "main.html", name => "single_interface_form", variables => { - field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), - description => "#!string!striker_0023!#", - ip_key => $this_ip_key, - ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", - ip_value_default => $this_ip, - ip_class => $this_ip_class, - 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_class => $this_subnet_class, - iface1_select => $this_iface1_form, + field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), + description => "#!string!striker_0023!#", + ip_key => $this_ip_key, + ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", + ip_value_default => $this_ip, + ip_class => $this_ip_class, + subnet_key => $this_subnet_key, + subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{ifn}{netmask}, + subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask}, + subnet_class => $this_subnet_class, + iface1_select => $this_iface1_form, }}); } } diff --git a/html/skins/alteeve/config.js b/html/skins/alteeve/config.js index e1114f1e..347ad39f 100644 --- a/html/skins/alteeve/config.js +++ b/html/skins/alteeve/config.js @@ -44,16 +44,7 @@ $( window ).on( "load", function() //window.history.pushState('object', document.title, newURL); //console.log('onload fired.'); - /* - 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+'].'); - }); - } - */ - + // Walk through the network.json file and use it to pre-fill the form. $.getJSON('/status/network.json', { get_param: 'value' }, function(data) { $.each(data.ips, function(index, element) { //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+'].'); for (var i = 1; i <= count; i++) { var network_name = network+i; - 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('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()+'].'); 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); + } + } + }); }); }) diff --git a/html/skins/alteeve/main.css b/html/skins/alteeve/main.css index 8441cd42..681a5540 100644 --- a/html/skins/alteeve/main.css +++ b/html/skins/alteeve/main.css @@ -51,7 +51,7 @@ select { background-color: #343434; color: #f7f7f7; font-family: 'Dejavu Sans Mono', 'Courier 10 pitch', monospace, Courier; - font-size: 1.1em; + font-size: 1.0em; } body { diff --git a/html/skins/alteeve/main.html b/html/skins/alteeve/main.html index d8229711..c6916e54 100644 --- a/html/skins/alteeve/main.html +++ b/html/skins/alteeve/main.html @@ -539,6 +539,7 @@ +   @@ -589,6 +590,7 @@ +