The reason for this is that DataTables keys local data on the page path, so each tab should have its own path. We're already doing this for reports and admin tasks, so it also makes sense to have consistency with search and device tabs. Squashed commit of the following: commit 4ad33a23a81122496adfe561ad14f039e6255eff Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:46:17 2014 +0100 fix search preference selection commit 363e094935d386961e8773f787af41c46b83129a Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:36:45 2014 +0100 fix css selector to match begins with /search commit 43c972ee0d9401f74dcc3bd30052dba130b0d068 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:18:24 2014 +0100 fix history push commit 84f83eb46874b0222c0484014389713e4f027c8a Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:06:44 2014 +0100 update sidebar form for tab-path, remove hidden tab name field commit 344d4679a83f714c998cd475c041f8effab0c696 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:05:49 2014 +0100 update template links for tab path commit 9cf370d7eb4413aac6fc19c2c13a9bf670600965 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:04:57 2014 +0100 move tab-specific JS from common into specific includes files commit c2d8592a18e389535368d1e74fed29fe5a0eabd8 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:02:46 2014 +0100 fix mode commit 52487cea47eaaea7f5c74536ad6d4bb2a8d6ba4c Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:01:15 2014 +0100 move from tab param to tabname template var commit b5a2424631a0050d5de3bc658746a40cd822e869 Merge:531782bd8102bfAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 10:50:00 2014 +0100 Merge branch 'master' into em-device-ports-json
609 lines
25 KiB
Plaintext
609 lines
25 KiB
Plaintext
[% SET user_can_port_control = user_has_role('port_control') %]
|
|
<table id="dp-data-table" class="table table-bordered table-striped" width="100%" cellspacing="0">
|
|
</table>
|
|
|
|
[% IF user_can_port_control %]
|
|
<div id="nd_portlog" class="nd_modal nd_deep-horizon modal hide fade" tabindex="-1"
|
|
role="dialog" aria-hidden="true">
|
|
<div class="modal-body">
|
|
<blockquote>
|
|
<ul><li><p>Please provide a reason for changing the Port Configuration</p></li></ul>
|
|
</blockquote>
|
|
<select id="nd_portlog-reason" class="input-block-level" name="reason">
|
|
[% FOREACH pair IN settings.port_control_reasons.pairs %]
|
|
<option[% ' selected="selected"' IF pair.key == 'other' %] value="[% pair.key | html_entity %]">
|
|
[% pair.value | html_entity %]</option>
|
|
[% END %]
|
|
</select>
|
|
<textarea id="nd_portlog-log" class="input-block-level" rows="2" name="log"
|
|
placeholder="Enter a log message"></textarea>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
|
<button id="nd_portlog-submit" class="btn btn-info" data-dismiss="modal">Continue</button>
|
|
</div>
|
|
</div>
|
|
[% END %]
|
|
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
|
|
$(document).ready(function() {
|
|
var freeDate = moment().subtract( [% params.age_num %], '[% params.age_unit %]' );
|
|
var table = $('#dp-data-table').dataTable({
|
|
"deferRender": true,
|
|
"order": [[ 1, "asc" ]],
|
|
"colVis": {
|
|
"exclude": [ 0 ]
|
|
},
|
|
"columns": [
|
|
{
|
|
"title": '',
|
|
"name": 'icon',
|
|
"data": "up",
|
|
"searchable": false,
|
|
"sortable": false,
|
|
"className": 'nd_center-cell nd_devport-icon',
|
|
"render": function(data, type, row, meta) {
|
|
var cell_str = '<i class="icon-angle-up text-success"></i>';
|
|
if (row.up_admin !== 'up') {
|
|
cell_str = '<i class="icon-remove"></i>';
|
|
} else if (row.up === 'up' && row.stp === 'blocking' && row.vlan_membership.length < 2) {
|
|
cell_str = '<i class="icon-fullscreen text-info"></i>';
|
|
} else if (row.up !== 'up' && freeDate.isAfter(row.lastchange_stamp)) {
|
|
cell_str = '<i class="icon-arrow-down text-success"></i>';
|
|
} else if (row.up_admin === 'up' && (row.up !== 'up' && row.up !== 'dormant')) {
|
|
cell_str = '<i class="icon-arrow-down text-error"></i>';
|
|
}
|
|
if (row.slave_of) {
|
|
cell_str += '<br/>';
|
|
if (row.agg_master_up_admin != 'up') {
|
|
cell_str += '<small><i class="icon-group muted"></i></small>';
|
|
} else if (row.agg_master_up === 'up') {
|
|
cell_str += '<small><i class="icon-group text-success"></i></small>';
|
|
} else {
|
|
cell_str += '<small><i class="icon-group text-error"></i></small>';
|
|
}
|
|
}
|
|
return cell_str;
|
|
}
|
|
},
|
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
|
[% NEXT UNLESS config.position == 'left' AND params.${config.name} %]
|
|
[% TRY %]
|
|
[% INCLUDE "plugin/${config.name}/device_port_column.tt" %],
|
|
[% CATCH %]
|
|
// dummy content required by Template Toolkit TRY
|
|
[% END %],
|
|
[% END %]
|
|
{
|
|
"title": 'Port',
|
|
"name": 'c_port',
|
|
"data": 'port',
|
|
"type": 'portsort',
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
"createdCell": function (td, cellData, rowData, row, col) {
|
|
$(td).attr('data-field', 'c_port');
|
|
$(td).attr('data-for-device', he.encode(rowData.ip));
|
|
$(td).attr('data-for-port', he.encode(rowData.port));
|
|
},
|
|
"className": 'nd_editable-cell nd_nowrap',
|
|
[% ELSE %]
|
|
"className": 'nd_nowrap',
|
|
[% END %]
|
|
"render": function(data, type, row, meta) {
|
|
if (type === 'display') {
|
|
var cell_str = '';
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
if (row.up_admin === 'up') {
|
|
cell_str += '<span class="nd_hand-icon">'
|
|
+ '<i class="icon-bullseye" data-action="bounce" rel="tooltip" data-placement="top"'
|
|
+ ' data-offset="3" data-animation="" data-title="Bounce Port"></i>'
|
|
+ ' <i class="icon-hand-down" rel="tooltip" data-placement="top"'
|
|
+ ' data-offset="3" data-animation="" data-title="Disable Port"></i>'
|
|
+ '</span>';
|
|
} else {
|
|
cell_str += '<span class="nd_hand-icon">'
|
|
+ '<i class="icon-bullseye" data-action="bounce" rel="tooltip" data-placement="top" style="display: none"'
|
|
+ ' data-offset="3" data-animation="" data-title="Bounce Port"></i>'
|
|
+ ' <i class="icon-hand-up" rel="tooltip" data-placement="top"'
|
|
+ ' data-offset="3" data-animation="" data-title="Enable Port"></i>'
|
|
+ '</span>';
|
|
}
|
|
cell_str += '<a class="nd_log-icon" href="[% uri_for('/report/portlog') %]?q='
|
|
+ encodeURIComponent(row.ip) + '&f=' + encodeURIComponent(row.port) + '">'
|
|
+ '<i class="icon-file-text-alt" rel="tooltip" data-placement="top"'
|
|
+ ' data-offset="3" data-animation="" data-title="View Port Log"></i></a>';
|
|
[% ELSE %]
|
|
cell_str += '';
|
|
[% END %]
|
|
cell_str += '<a class="nd_this-port-only nd_port-only-first" href="[% uri_for('/device',self_options) %]&q=[% params.q | uri %]&f='
|
|
+ encodeURIComponent(row.port) + '&prefer=port">';
|
|
if (row.is_master) {
|
|
cell_str += '<small><i class="icon-group muted"></i></small> ';
|
|
}
|
|
cell_str += he.encode(row.port) + '</a>';
|
|
if (row.slave_of) {
|
|
cell_str += '<br/>'
|
|
+ '<a class="nd_this-port-only" href="[% uri_for('/device', self_options) %]&q=[% params.q | uri %]&f='
|
|
+ encodeURIComponent(row.slave_of) + '&prefer=port">'
|
|
+ he.encode(row.slave_of) + '</a>';
|
|
}
|
|
return cell_str;
|
|
}
|
|
else {
|
|
return he.encode(data || '');
|
|
}
|
|
}
|
|
},
|
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
|
[% NEXT UNLESS config.position == 'mid' AND params.${config.name} %]
|
|
[% TRY %]
|
|
[% INCLUDE "plugin/${config.name}/device_port_column.tt" %],
|
|
[% CATCH %]
|
|
// dummy content required by Template Toolkit TRY
|
|
[% END %],
|
|
[% END %]
|
|
{
|
|
"title": 'Description',
|
|
"name": 'c_descr',
|
|
"type": 'portsort',
|
|
"className": 'nd_nowrap',
|
|
"data": "descr",
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
}, {
|
|
"title": 'Type',
|
|
"name": 'c_type',
|
|
"data": "type",
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
}, {
|
|
"title": 'Duplex',
|
|
"name": 'c_duplex',
|
|
"data": "duplex",
|
|
"render": function(data, type, row, meta) {
|
|
if (row.up === 'up' && row.duplex) {
|
|
return he.encode(capitalizeFirstLetter(row.duplex_admin || 'auto') )
|
|
+ ' / ' + he.encode(capitalizeFirstLetter(row.duplex) || '');
|
|
}
|
|
else {
|
|
return '';
|
|
}
|
|
}
|
|
}, {
|
|
"title": 'Last Change',
|
|
"name": 'c_lastchange',
|
|
"data": "lastchange_stamp",
|
|
}, {
|
|
"title": 'Name',
|
|
"name": 'c_name',
|
|
"data": "name",
|
|
"type": 'portsort',
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
"createdCell": function (td, cellData, rowData, row, col) {
|
|
$(td).attr('contenteditable', 'true');
|
|
$(td).attr('data-field', 'c_name');
|
|
$(td).attr('data-for-device', he.encode(rowData.ip));
|
|
$(td).attr('data-for-port', he.encode(rowData.port));
|
|
},
|
|
"className": 'nd_editable-cell nd_nowrap',
|
|
"render": function(data, type, row, meta) {
|
|
if (type === 'display') {
|
|
return '<i class="icon-edit nd_edit-icon"></i>'
|
|
+ '<div class="nd_editable-cell-content">'
|
|
+ he.encode(data || '') + '</div>';
|
|
}
|
|
else {
|
|
return data;
|
|
}
|
|
}
|
|
[% ELSE %]
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
[% END %]
|
|
}, {
|
|
"title": 'Speed',
|
|
"name": 'c_speed',
|
|
"data": "speed",
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
}, {
|
|
"title": 'Port MAC',
|
|
"name": 'c_mac',
|
|
"data": "mac",
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
}, {
|
|
"title": 'MTU',
|
|
"name": 'c_mtu',
|
|
/* mtu is an integer, no need to encode */
|
|
"data": "mtu"
|
|
}, {
|
|
"title": 'Native VLAN',
|
|
"name": 'c_pvid',
|
|
"data": "native_vlan",
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
"createdCell": function (td, cellData, rowData, row, col) {
|
|
$(td).attr('contenteditable', 'true');
|
|
$(td).attr('data-field', 'c_pvid');
|
|
$(td).attr('data-for-device', he.encode(rowData.ip));
|
|
$(td).attr('data-for-port', he.encode(rowData.port));
|
|
},
|
|
"className": 'nd_editable-cell',
|
|
"render": function ( data, type, row, meta ) {
|
|
if (type === 'display') {
|
|
var cell_str = '<i class="icon-edit nd_edit-icon"></i>'
|
|
+ '<div class="nd_editable-cell-content">';
|
|
if (row.native_vlan) {
|
|
/* row.native_vlan is an integer, no need to encode */
|
|
cell_str += row.native_vlan;
|
|
}
|
|
cell_str += '</div>';
|
|
return cell_str;
|
|
}
|
|
else {
|
|
return data;
|
|
}
|
|
}
|
|
[% ELSE %]
|
|
"render": function ( data, type, row, meta ) {
|
|
if (row.native_vlan && type === 'display') {
|
|
return '<a class="nd_linkcell" href="[% uri_for('/search/vlan') %]?q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
|
}
|
|
else {
|
|
return data;
|
|
}
|
|
}
|
|
[% END %]
|
|
}, {
|
|
"title": 'VLAN Membership',
|
|
"name": 'c_vmember',
|
|
"type": 'natural',
|
|
"data": null,
|
|
"render": function ( data, type, row, meta ) {
|
|
if (type === 'display' && row.vlan_membership) {
|
|
var cell_str = '';
|
|
var arr = row.vlan_membership;
|
|
arr = arr.sort(function(a, b){return a-b});
|
|
arr = jQuery.map( arr, function( a ) {
|
|
return '<a href="[% uri_for('/search/vlan') %]?q=' + a + '">' + a + '</a>';
|
|
});
|
|
if (row.vlan_membership.length > 10) {
|
|
return '<div class="nd_vlan-total">('
|
|
+ row.vlan_membership.length
|
|
+ ')</div><span class="nd_linkcell nd_collapse-vlans">'
|
|
+ '<div class="nd_arrow-up-down-left icon-chevron-up icon-large"></div>Show VLANs</span>'
|
|
+ '<div class="nd_collapsing nd_collapse-pre-hidden">' + arr.join(", ")
|
|
+ '</div>';
|
|
}
|
|
else {
|
|
return row.vlan_membership ? arr.join(", ") : "";
|
|
}
|
|
}
|
|
else {
|
|
return row.vlan_membership ? row.vlan_membership.join(", ") : "";
|
|
}
|
|
}
|
|
}, {
|
|
"title": 'PoE',
|
|
"name": 'c_power',
|
|
"data": "power_admin",
|
|
"defaultContent": "",
|
|
"className": 'nd_nowrap',
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
"createdCell": function (td, cellData, rowData, row, col) {
|
|
if (row.power_admin && row.power_admin === 'true') {
|
|
$(td).attr('data-action', 'false');
|
|
}
|
|
else {
|
|
$(td).attr('data-action', 'true');
|
|
}
|
|
$(td).attr('data-action', 'false');
|
|
$(td).attr('data-field', 'c_power');
|
|
$(td).attr('data-for-device', he.encode(rowData.ip));
|
|
$(td).attr('data-for-port', he.encode(rowData.port));
|
|
},
|
|
[% END %]
|
|
"render": function ( data, type, row, meta ) {
|
|
if (type === 'display') {
|
|
var cell_str = '';
|
|
if (row.power_admin && row.power_admin === 'true') {
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
cell_str += '<i class="icon-off nd_power-icon nd_power-on" '
|
|
+ 'rel="tooltip" data-placement="top" data-offset="3" '
|
|
+ 'data-animation="" data-title="Disable Power"></i>';
|
|
[% ELSE %]
|
|
cell_str += '<i class="icon-off nd_power-on"></i>';
|
|
[% END %]
|
|
cell_str += '<span> ';
|
|
if (row.power && row.power > 0) {
|
|
cell_str += row.power + ' mW';
|
|
}
|
|
else {
|
|
cell_str += he.encode(row.power_status || '');
|
|
}
|
|
cell_str += '<span>';
|
|
return cell_str;
|
|
}
|
|
else {
|
|
[% IF user_can_port_control AND params.c_admin %]
|
|
cell_str += '<i class="icon-off nd_power-icon" '
|
|
+ 'rel="tooltip" data-placement="top" data-offset="3" '
|
|
+ 'data-animation="" data-title="Enable Power"></i>';
|
|
[% ELSE %]
|
|
cell_str += '<i class="icon-off"></i>';
|
|
[% END %]
|
|
}
|
|
}
|
|
else {
|
|
return data;
|
|
}
|
|
}
|
|
}, {
|
|
"title": 'SSID',
|
|
"name": 'c_ssid',
|
|
"data": "null",
|
|
"defaultContent": "",
|
|
"render": function ( data, type, row, meta ) {
|
|
if (row.ssids && type === 'display') {
|
|
var arr = row.ssids;
|
|
arr = arr.sort();
|
|
arr = jQuery.map( arr, function( a ) {
|
|
return he.encode(a || '');
|
|
});
|
|
return row.ssids ? arr.join(", ") : "";
|
|
}
|
|
else {
|
|
return row.ssids ? row.ssids.join(", ") : "";
|
|
}
|
|
}
|
|
}, {
|
|
"title": 'Connected Devices and Nodes',
|
|
"name": 'c_neighbors',
|
|
"data": "null",
|
|
"defaultContent": "",
|
|
"render": function ( data, type, row, meta ) {
|
|
var cell_str = '';
|
|
var d_suffix = '[% settings.domain_suffix %]';
|
|
if (row.remote_ip || row.is_uplink) {
|
|
if (row.neighbor_alias_ip) {
|
|
cell_str += '<i class="icon-link';
|
|
if (row.manual_topo) {
|
|
cell_str += ' text-warning';
|
|
}
|
|
cell_str += '"></i> ';
|
|
if (row.remote_type && row.remote_type.match(/ip.phone/i)) {
|
|
cell_str += '<i class="icon-phone"></i> ';
|
|
}
|
|
else if (row.remote_type && row.remote_type.match(/(cisco\s+AIR-[L|C]?AP|-K9W8-|^AP:\s)/)) {
|
|
cell_str += '<i class="icon-signal"></i> ';
|
|
}
|
|
cell_str += '<a href="[% uri_for('/device', self_options) %]&q='
|
|
+ encodeURIComponent(row.neighbor_alias_ip) + '">';
|
|
var n_dns = row.neighbor_alias_dns ? row.neighbor_alias_dns.replace(d_suffix, '') : '';
|
|
cell_str += he.encode(n_dns || row.neighbor_alias_ip) + '</a>';
|
|
if (row.remote_port) {
|
|
cell_str += ' - '
|
|
+ '<a href="[% uri_for('/device', self_options) %]&q='
|
|
+ encodeURIComponent(row.neighbor_alias_ip)
|
|
+ '&f=' + encodeURIComponent(row.remote_port)
|
|
+ '&prefer=port">' + he.encode(row.remote_port || '') + '</a>';
|
|
}
|
|
cell_str += '<br/>';
|
|
if (row.remote_id || row.remote_type) {
|
|
cell_str += '<span class="neigh_id nd_collapse-pre-hidden"> (';
|
|
if (row.remote_id) {
|
|
cell_str += ' id: ' + he.encode(row.remote_id);
|
|
}
|
|
else if (row.remote_type) {
|
|
cell_str += ' type: ' + he.encode(row.remote_type);
|
|
}
|
|
cell_str += ' )<br/> </span>';
|
|
}
|
|
}
|
|
else if (row.remote_ip) {
|
|
cell_str += '<i class="icon-unlink text-error"></i> ';
|
|
if (row.remote_type && row.remote_type.match(/ip.phone/i)) {
|
|
cell_str += '<i class="icon-phone"></i> ';
|
|
}
|
|
else if (row.remote_type && row.remote_type.match(/(cisco\s+AIR-[L|C]?AP|-K9W8-|^AP:\s)/)) {
|
|
cell_str += '<i class="icon-signal"></i> ';
|
|
}
|
|
cell_str += '<a href="[% search_node %]&q='
|
|
+ encodeURIComponent(row.remote_ip) + '">'
|
|
+ he.encode(row.remote_ip || '');
|
|
if (row.remote_port) {
|
|
cell_str += ' - ' + he.encode(row.remote_port || '');
|
|
}
|
|
cell_str += '</a><br/>';
|
|
if (row.remote_id || row.remote_type) {
|
|
cell_str += '<span class="neigh_id nd_collapse-pre-hidden"> (';
|
|
if (row.remote_id) {
|
|
cell_str += ' id: ' + he.encode(row.remote_id);
|
|
}
|
|
else if (row.remote_type) {
|
|
cell_str += ' type: ' + he.encode(row.remote_type);
|
|
}
|
|
cell_str += ' )<br/> </span>';
|
|
}
|
|
}
|
|
else {
|
|
cell_str += '<i class="icon-unlink text-error"></i> (possible uplink)';
|
|
}
|
|
}
|
|
cell_str += '<span class="c_nodes nd_collapse-pre-hidden">';
|
|
var macfmt = '[% params.mac_format %]';
|
|
for (index = 0; index < row.nodes.length; ++index) {
|
|
if ((row.remote_ip || row.is_uplink) && index === 0 ) {
|
|
cell_str += '<br/>';
|
|
}
|
|
if (row.nodes[index].active === 0) {
|
|
cell_str += '<span class="n_archived nd_collapse-pre-hidden">';
|
|
if (index > 0 ) {
|
|
cell_str += '<br/>';
|
|
}
|
|
cell_str += '<i class="icon-book"></i> ';
|
|
}
|
|
else if (index > 0 && row.nodes[index].active !== 0) {
|
|
cell_str += '<br/>';
|
|
}
|
|
if (row.remote_type && row.remote_type.match(/ip.phone/i)) {
|
|
cell_str += '<i class="icon-phone"></i> ';
|
|
}
|
|
else if (row.nodes[index].ssids || (row.remote_type && row.remote_type.match(/(cisco\s+AIR-[L|c]?AP|-K9W8-|^AP:\s)/))) {
|
|
cell_str += '<i class="icon-signal"></i> ';
|
|
}
|
|
cell_str += '<a href="[% search_node %]&q=';
|
|
var fmac = formatMacAddress(row.nodes[index].mac, macfmt);
|
|
cell_str += encodeURIComponent(fmac) + '">'
|
|
+ he.encode(fmac) + '</a>';
|
|
|
|
// n_vendor
|
|
if (row.nodes[index].abbrev) {
|
|
cell_str += '<span class="n_vendor nd_collapse-pre-hidden"> ('
|
|
+ '<a href="[%+ uri_for('/report/nodevendor') %]?vendor='
|
|
+ encodeURIComponent(row.nodes[index].abbrev) + '">'
|
|
+ he.encode(row.nodes[index].abbrev || '') + '</a>)</span>';
|
|
}
|
|
|
|
if (row.nodes[index].vlans.length > 0) {
|
|
var vl = row.nodes[index].vlans ? row.nodes[index].vlans.join(", ") : "";
|
|
cell_str += ' (on vlan ' + vl + ')';
|
|
}
|
|
|
|
// n_ssid
|
|
if (row.nodes[index].ssids && row.nodes[index].ssids.length > 0) {
|
|
var arr = row.nodes[index].ssids;
|
|
arr = arr.sort();
|
|
arr = jQuery.map( arr, function( a ) {
|
|
return '<a href="[% uri_for('/report/portssid') %]?ssid=' + encodeURIComponent(a) + '">' + he.encode(a) + '</a>';
|
|
});
|
|
cell_str += '<span class="n_ssid nd_collapse-pre-hidden"> (SSID: ' + arr.join(" ") + ')</span>';
|
|
}
|
|
|
|
// n_age
|
|
cell_str += '<span class="n_age nd_collapse-pre-hidden"> (';
|
|
var now = moment();
|
|
var t_last = moment(row.nodes[index].time_last);
|
|
cell_str += t_last.from(now) + ')</span>';
|
|
|
|
// n_ip
|
|
if (row.nodes[index].ip && row.nodes[index].ip.length > 0) {
|
|
cell_str += '<span class="n_ip nd_collapse-pre-hidden">';
|
|
for (idx = 0; idx < row.nodes[index].ip.length; ++idx) {
|
|
if (row.nodes[index].ip_active[idx] === 0) {
|
|
cell_str += '<span class="n_archived nd_collapse-pre-hidden">';
|
|
cell_str += '<br/> <i class="icon-book"></i> ';
|
|
}
|
|
else {
|
|
cell_str += '<br/> ';
|
|
}
|
|
cell_str += '<a href="[% search_node %]&q='
|
|
+ encodeURIComponent(row.nodes[index].ip[idx]) + '">';
|
|
if (row.nodes[index].dns[idx]) {
|
|
cell_str += he.encode(row.nodes[index].dns[idx])
|
|
+ ' ( ' + he.encode(row.nodes[index].ip[idx]) + ' )</a>';
|
|
}
|
|
else {
|
|
cell_str += he.encode(row.nodes[index].ip[idx]) + '</a>';
|
|
}
|
|
if (row.nodes[index].ip_active[idx] === 0) {
|
|
cell_str += '</span>';
|
|
}
|
|
}
|
|
cell_str += '</span>';
|
|
}
|
|
|
|
// n_netbios
|
|
if (row.nodes[index].nbname) {
|
|
cell_str += '<span class="n_netbios nd_collapse-pre-hidden">'
|
|
+ '<br/> \\\\<a href="[% uri_for('/report/netbios') %]?domain=';
|
|
var nb_dom_uri = row.nodes[index].nbname ? encodeURIComponent(row.nodes[index].domain) : 'blank';
|
|
var nb_dom = row.nodes[index].nbname ? he.encode(row.nodes[index].domain) : '(Blank Domain)';
|
|
cell_str += nb_dom_uri + '" title="Nodes in this Domain">' + nb_dom + '</a>\\'
|
|
+ '<a href="[% search_node %]&q=' + encodeURIComponent(row.nodes[index].nbname) + '">'
|
|
+ he.encode(row.nodes[index].nbname) + '</a>'
|
|
+ '<br/> ';
|
|
var nb_user = row.nodes[index].nbuser ? he.encode(row.nodes[index].nbuser) : '[No User]';
|
|
cell_str += nb_user + '@'
|
|
+ '<a href="[% search_node %]&q='
|
|
+ encodeURIComponent(row.nodes[index].nb_ip) + '">'
|
|
+ he.encode(row.nodes[index].nb_ip) + '</a></span>';
|
|
}
|
|
|
|
if (row.nodes[index].active === 0) {
|
|
cell_str += '</span>';
|
|
}
|
|
}
|
|
cell_str += '</span>';
|
|
return cell_str;
|
|
}
|
|
}, {
|
|
"title": 'Spanning Tree',
|
|
"name": 'c_stp',
|
|
"data": "stp",
|
|
"render": function(data, type, row, meta) {
|
|
return type === 'display' ? he.encode(data || '') : data;
|
|
}
|
|
}, {
|
|
"title": 'Status',
|
|
"name": 'c_up',
|
|
"data": "up",
|
|
},
|
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
|
[% NEXT UNLESS config.position == 'right' AND params.${config.name} %]
|
|
[% TRY %]
|
|
[% INCLUDE "plugin/${config.name}/device_port_column.tt" %],
|
|
[% CATCH %]
|
|
// dummy content required by Template Toolkit TRY
|
|
[% END %]
|
|
[% END %]
|
|
],
|
|
"data": [% results %],
|
|
[% INCLUDE 'ajax/datatabledefaults.tt' -%]
|
|
});
|
|
|
|
// display the column show/hide buttons in the sidebar
|
|
var colvis = new $.fn.dataTable.ColVis( table );
|
|
var columns = colvis.s.dt.aoColumns;
|
|
|
|
// first remove existing controls, in case indexes have changed
|
|
$('#nd_column-controls').find('.nd_colvis-checkbox').remove();
|
|
|
|
if ( $.inArray( 'all', colvis.s.exclude ) === -1 ) {
|
|
for ( var i=0, iLen=columns.length ; i<iLen ; i++ ) {
|
|
if ( $.inArray( i, colvis.s.exclude ) === -1 ) {
|
|
var button = colvis.dom.buttons.shift();
|
|
if (columns[i]["name"] == "icon") {
|
|
continue;
|
|
}
|
|
|
|
$(button).addClass('nd_colvis-checkbox');
|
|
$(button).find('label').addClass('checkbox');
|
|
$(button).find('input').attr('id', columns[i]["name"]);
|
|
$(button).find('input').attr('name', columns[i]["name"]);
|
|
|
|
if (columns[i]["name"] == "c_neighbors") {
|
|
$(button).find('span').text('Connected Devices');
|
|
}
|
|
|
|
// need to re-activate tooltips on new content
|
|
$(button).click(function() {
|
|
$("[rel=tooltip]").tooltip({live: true});
|
|
});
|
|
|
|
$('#nd_column-controls').append( button );
|
|
}
|
|
}
|
|
}
|
|
|
|
});
|
|
//]]>
|
|
</script>
|