* Got the jquery to fill the form IP data is set.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 97441831e6
commit 2ea506b4d9
  1. 2
      Anvil/Tools.pm
  2. 98
      html/skins/alteeve/config.js
  3. 2
      tools/anvil-update-states

@ -749,7 +749,7 @@ sub _set_defaults
switch_octet3 => "3",
striker_octet3 => "4",
},
dns => "8.8.8.8, 4.4.4.4",
dns => "8.8.8.8, 8.8.4.4",
# IFN starts at 10.(80+)/16
ifn => {
subnet => "10.100.0.0",

@ -56,15 +56,15 @@ $( window ).on( "load", function()
$.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+'].');
console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
//console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].');
//console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// If this is the default gateway, see about setting the Gateway IP and DNS.
if (element.default_gateway == '1') {
console.log('This is the default gateway interface.');
console.log('- Form value for gateway......: ['+$("#gateway").val()+'] and dns: ['+$("#dns").val()+'].');
console.log('- Default values for gateway..: ['+$("#gateway_default").val()+'] and dns: ['+$("#dns_default").val()+'].');
console.log('- Interface values for gateway: ['+element.gateway+'] and dns: ['+element.dns+'].');
//console.log('This is the default gateway interface.');
//console.log('- Form value for gateway......: ['+$("#gateway").val()+'] and dns: ['+$("#dns").val()+'].');
//console.log('- Default values for gateway..: ['+$("#gateway_default").val()+'] and dns: ['+$("#dns_default").val()+'].');
//console.log('- Interface values for gateway: ['+element.gateway+'] and dns: ['+element.dns+'].');
if (($("#gateway").val() == '') && (element.gateway)) {
$("#gateway").val(element.gateway);
}
@ -72,57 +72,59 @@ $( window ).on( "load", function()
$("#dns").val(element.dns);
}
}
// Does this IP match any of the fields?
if(element.on.match(new RegExp('_'))) {
var network_prefix = element.on.match(/^(.*)_/).pop();
var network_ip_key = network_prefix+'_ip'
var network_subnet_key = network_prefix+'_subnet'
//console.log('Matching: ['+network_ip_key+'] and: ['+network_subnet_key+'].');
if ($("#"+network_ip_key).val() == '')
{
$("#"+network_ip_key).val(element.address);
}
if ($("#"+network_subnet_key).val() == '')
{
$("#"+network_subnet_key).val(element.subnet);
}
}
});
// If DNS or gateway are blank still and we have default values, set them.
console.log('Form value for gateway......: ['+$("#gateway").val()+'] and dns: ['+$("#dns").val()+'].');
console.log('Interface values for gateway: ['+$("#gateway_default").val()+'] and dns: ['+$("#dns_default").val()+'].');
//console.log('Form value for gateway......: ['+$("#gateway").val()+'] and dns: ['+$("#dns").val()+'].');
//console.log('Interface values for gateway: ['+$("#gateway_default").val()+'] and dns: ['+$("#dns_default").val()+'].');
if (($("#gateway").val() == '') && ($("#gateway_default").val())) {
$("#gateway").val($("#gateway_default").val());
}
if (($("#dns").val() == '') && ($("#dns_default").val())) {
$("#dns").val($("#dns_default").val());
}
});
// Now set any other default IP/subnets
jQuery.each("bcn sn ifn".split(" "), function(index, network) {
//console.log('Network: ['+network+'].');
if($("#"+network+"_count").val()) {
var count = $("#"+network+"_count").val();
//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()+'].');
//jQuery.each("bcn sn ifn".split(" "), function(index, network) {
// jQuery.each("ifn".split(" "), function(index, network) {
// //console.log('Network: ['+network+'].');
// if($("#"+network+"_count").val()) {
// var count = $("#"+network+"_count").val();
// //console.log(network+' count: ['+count+'].');
// for (var i = 1; i <= count; i++) {
// var network_name = network+i;
// var ip_set = $("#"+network_name+"_ip").val();
// console.log('i: ['+i+'], Network: ['+network_name+'], IP set: ['+ip_set+'], default: ['+$("#"+network_name+"_ip_default").val()+'].');
// if (ip_set == '') {
// console.log('Reading /status/network.json');
// $.ajax({dataType:"json",url:"/status/network.json",data:{get_param:"value"},async:false}), function(data) {
// console.log('Read for: ['+network_name+'].');
// $.each(data.ips, function(index, element) {
// var on_interface = element.on;
// console.log('on_interface: ['+on_interface+'], network_name: ['+network_name+'].');
// //console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].');
// //console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// if(on_interface.match(new RegExp(network_name))) {
// console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// if (element.default_gateway == '1') {
// if ($("#gateway").val() == '') {
// $("#gateway").val(element.gateway);
// };
// if ($("#dns").val() == '') {
// $("#dns").var(element.dns);
// };
// };
// };
// });
// };
// var default_ip = $("#"+network_name+"_ip_default").val();
// console.log(network+' IP not set. Setting to: ['+default_ip+']');
// $("#"+network_name+"_ip").val(default_ip);
// };
// };
// };
// });
if ($("#"+network_name+"_ip").val() == '')
{
var ip = $("#"+network_name+"_ip_default").val();
$("#"+network_name+"_ip").val(ip);
}
if ($("#"+network_name+"_subnet").val() == '')
{
var subnet = $("#"+network_name+"_subnet_default").val();
$("#"+network_name+"_subnet").val(subnet);
}
};
};
});
});
})

@ -3,6 +3,8 @@
# This is the master daemon that manages all periodically run processes on Striker dashboards and Anvil!
# nodes.
#
# TODO: Make sure to delete interfaces/bonds/bridges that disappear
#
use strict;
use warnings;
use Anvil::Tools;

Loading…
Cancel
Save