@ -12,13 +12,127 @@ $( window ).on( "load", function()
// Clears the URL to remove everything off after '?'.
//var newURL = location.href.split("?")[0];
//window.history.pushState('object', document.title, newURL);
//console.log('onload fired.');
// Toggle the table with the list of hosts that can be configured.
$ ( "#toggle_unconfigured_icon" ) . click ( function ( ) {
$ ( "#unconfigured_hosts" ) . toggle ( ) ;
} ) ;
$ ( "#toggle_unconfigured_text" ) . click ( function ( ) {
$ ( "#unconfigured_hosts" ) . toggle ( ) ;
} ) ;
// 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_mask: ['+element.subnet_mask+'].');
//console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
$ . getJSON ( '/status/all_status.json' , { get _param : 'value' } , function ( data ) {
//console.log('read /status/all_status.json');
var show _none = 1 ;
var say _none = $ ( '#unconfigured_hosts' ) . data ( 'none' ) ;
var say _yes = $ ( '#unconfigured_hosts' ) . data ( 'yes' ) ;
var say _no = $ ( '#unconfigured_hosts' ) . data ( 'no' ) ;
var say _unconfigured = $ ( '#unconfigured_hosts' ) . data ( 'unconfigured' ) ;
var say _configured = $ ( '#unconfigured_hosts' ) . data ( 'configured' ) ;
var say _type = $ ( '#unconfigured_hosts' ) . data ( 'type' ) ;
var say _accessible = $ ( '#unconfigured_hosts' ) . data ( 'accessible' ) ;
var say _at _ip = $ ( '#unconfigured_hosts' ) . data ( 'at-ip' ) ;
// Open the table
var body = '<table id="unconfigured_hosts_table" class="data_table_nowrap">' ;
body += '<tr class="data_row">' ;
body += '<td class="column_header">' + say _unconfigured + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header">' + say _type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header">' + say _accessible + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header">' + say _at _ip + '</td>' ;
body += '</tr>' ;
$ . each ( data . hosts , function ( index , element ) {
if ( element . type === 'dashboard' ) {
// Skip
return true ;
} ;
if ( element . configured != 1 ) {
show _none = 0 ;
if ( element . matched _ip _address ) {
//console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']');
body += '<tr class="data_row">' ;
body += '<td class="column_row_value_fixed"><a class="available" href="?anvil=true&task=prep-network&host=' + element . host _uuid + '">' + element . short _name + '</a></td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="available">' + say _yes + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . matched _ip _address + '</td>' ;
body += '</tr>' ;
} else {
//console.log('Show: ['+element.short_name+'], not accessible from here');
body += '<tr class="data_row">' ;
body += '<td class="column_row_value_fixed">' + element . short _name + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="unavailable">' + say _no + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">--</td>' ;
body += '</tr>' ;
}
}
} ) ;
if ( show _none ) {
body += '<tr class="data_row">' ;
body += '<td class="subtle_text" colspan="7"><' + say _none + '></td>' ;
body += '</tr>' ;
}
// Now show configured ones (in case the user wants to reconfigure a host)
show _none = 1 ;
body += '<tr class="data_row">' ;
body += '<td class="column_header" style="padding-top: 0.5em;">' + say _configured + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header" style="padding-top: 0.5em;">' + say _type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header" style="padding-top: 0.5em;">' + say _accessible + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_header" style="padding-top: 0.5em;">' + say _at _ip + '</td>' ;
body += '</tr>' ;
$ . each ( data . hosts , function ( index , element ) {
if ( element . type === 'dashboard' ) {
// Skip
return true ;
} ;
if ( element . configured == 1 ) {
show _none = 0 ;
if ( element . matched _ip _address ) {
//console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']');
body += '<tr class="data_row">' ;
body += '<td class="column_row_value_fixed"><a class="available" href="?anvil=true&task=prep-network&host=' + element . host _uuid + '">' + element . short _name + '</a></td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="available">' + say _yes + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . matched _ip _address + '</td>' ;
body += '</tr>' ;
} else {
//console.log('Show: ['+element.short_name+'], not accessible from here');
body += '<tr class="data_row">' ;
body += '<td class="column_row_value_fixed">' + element . short _name + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">' + element . type + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="unavailable">' + say _no + '</td>' ;
body += '<td class="column_header"> </td>' ;
body += '<td class="column_row_value_fixed">--</td>' ;
body += '</tr>' ;
}
}
} ) ;
if ( show _none ) {
body += '<tr class="data_row">' ;
body += '<td class="subtle_text" style="text-align: center;" colspan="7"><' + say _none + '></td>' ;
body += '</tr>' ;
}
// Close the table
body += '</table>' ;
$ ( "#unconfigured_hosts" ) . append ( body ) ;
} ) ;
} )