From 1fa4dba7e8c58491b0c300054873c3f9204f2f26 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Wed, 11 Jun 2014 18:24:55 -0400 Subject: [PATCH 1/4] Add missing processing style to dataTables.bootstrap.css --- .../share/public/css/dataTables.bootstrap.css | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Netdisco/share/public/css/dataTables.bootstrap.css b/Netdisco/share/public/css/dataTables.bootstrap.css index bb011f5a..394b5c4c 100644 --- a/Netdisco/share/public/css/dataTables.bootstrap.css +++ b/Netdisco/share/public/css/dataTables.bootstrap.css @@ -203,3 +203,22 @@ div.DTFC_LeftFootWrapper table { border-top: none; } +div.dataTables_processing { + position: absolute; + top: 50%; + left: 50%; + width: 100%; + height: 40px; + margin-left: -50%; + margin-top: -25px; + padding-top: 20px; + text-align: center; + font-size: 1.2em; + background-color: white; + background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0))); + background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: -o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); + background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%); +} From 86d02cc0888a5a8be713eb51f806deb67bbc1db0 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Wed, 11 Jun 2014 18:26:14 -0400 Subject: [PATCH 2/4] Add oui abbrev field to node search results for linking --- Netdisco/lib/App/Netdisco/DB/ResultSet/NodeIp.pm | 1 + Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet/NodeIp.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet/NodeIp.pm index 405dd01f..22202dbc 100644 --- a/Netdisco/lib/App/Netdisco/DB/ResultSet/NodeIp.pm +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet/NodeIp.pm @@ -12,6 +12,7 @@ my $search_attr = { order_by => {'-desc' => 'time_last'}, '+columns' => [ 'oui.company', + 'oui.abbrev', { time_first_stamp => \"to_char(time_first, 'YYYY-MM-DD HH24:MI')" }, { time_last_stamp => \"to_char(time_last, 'YYYY-MM-DD HH24:MI')" }, ], diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 7e20aae2..4419b3a3 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -66,6 +66,7 @@ ajax '/ajax/content/search/node' => require_login sub { order_by => {'-desc' => 'time_last'}, '+columns' => [ 'oui.company', + 'oui.abbrev', { time_first_stamp => \"to_char(time_first, 'YYYY-MM-DD HH24:MI')" }, { time_last_stamp => \"to_char(time_last, 'YYYY-MM-DD HH24:MI')" }, ], @@ -77,6 +78,7 @@ ajax '/ajax/content/search/node' => require_login sub { order_by => {'-desc' => 'time_last'}, '+columns' => [ 'oui.company', + 'oui.abbrev', { time_first_stamp => \"to_char(time_first, 'YYYY-MM-DD HH24:MI')" }, { time_last_stamp => \"to_char(time_last, 'YYYY-MM-DD HH24:MI')" }, ], @@ -91,6 +93,7 @@ ajax '/ajax/content/search/node' => require_login sub { { order_by => { '-desc' => 'time_last' }, '+columns' => [ 'oui.company', + 'oui.abbrev', { time_last_stamp => \"to_char(time_last, 'YYYY-MM-DD HH24:MI')" }], From c8f5a5a5086a0de24f5641284c732a331ce296c7 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Wed, 11 Jun 2014 19:28:20 -0400 Subject: [PATCH 3/4] Move vendor to grouping bar in node search results and link to node vendor report Change DataTables search box description to 'Filter records: ' --- .../share/views/ajax/search/node_by_ip.tt | 80 +++++++++---------- .../share/views/ajax/search/node_by_mac.tt | 56 ++++++------- 2 files changed, 64 insertions(+), 72 deletions(-) diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt index 591c2064..3b495761 100644 --- a/Netdisco/share/views/ajax/search/node_by_ip.tt +++ b/Netdisco/share/views/ajax/search/node_by_ip.tt @@ -4,11 +4,8 @@ MAC - [% IF params.show_vendor %] - Vendor - [% END %] Match - Device or Node + Device or Node [% IF params.stamps %] First Seen Last Seen @@ -19,11 +16,13 @@ [% WHILE (row = macs.next) %] [% IF row.nbname %] - - [% row.net_mac.$mac_format_call | html_entity %] + MAC: + [% row.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - [% row.oui.company | html_entity %] + ( + [% row.oui.company | html_entity %] ) [% END %] + NetBIOS \\[% row.domain | html_entity %]\[% row.nbname | html_entity %]
[% row.nbuser || '[No User]' | html_entity %]@[% row.ip | html_entity %] @@ -35,11 +34,13 @@ [% ELSE %] - - [% row.net_mac.$mac_format_call | html_entity %] + MAC: + [% row.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - [% row.oui.company | html_entity %] + ( + [% row.oui.company | html_entity %] ) [% END %] + IP → MAC [% row.ip | html_entity %] @@ -54,13 +55,13 @@ [% END %] [% FOREACH nbt IN row.netbios %] - - [% nbt.net_mac.$mac_format_call | html_entity %] + MAC: + [% nbt.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% nbt.oui.company | html_entity %] - + ( + [% nbt.oui.company | html_entity %] ) [% END %] + NetBIOS \\[% nbt.domain | html_entity %]\[% nbt.nbname | html_entity %]
[% nbt.nbuser || '[No User]' | html_entity %]@[% nbt.ip | html_entity %] @@ -73,13 +74,13 @@ [% END %] [% FOREACH ni IN row.nodeips %] - - [% ni.net_mac.$mac_format_call | html_entity %] + MAC: + [% ni.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% ni.oui.company | html_entity %] - + ( + [% ni.oui.company | html_entity %] ) [% END %] + IP → MAC [% ni.ip | html_entity %] @@ -94,13 +95,13 @@ [% END %] [% FOREACH node IN row.node_sightings(archive_filter) %] - - [% node.net_mac.$mac_format_call | html_entity %] + MAC: + [% node.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% node.oui.company | html_entity %] - + ( + [% node.oui.company | html_entity %] ) [% END %] + Switch Port @@ -117,13 +118,13 @@ [% FOREACH wlan IN node.wireless %] - - [% wlan.net_mac.$mac_format_call | html_entity %] + MAC: + [% wlan.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% wlan.oui.company | html_entity %] - + ( + [% wlan.oui.company | html_entity %] ) [% END %] + Wireless Info SSID: [% wlan.ssid | html_entity %]
MaxRate: [% wlan.maxrate | html_entity %]Mbps TxRate: [% wlan.txrate | html_entity %]Mbps
@@ -140,13 +141,13 @@ [% END %] [% FOREACH nodeip IN row.ip_aliases(archive_filter) %] - - [% nodeip.net_mac.$mac_format_call | html_entity %] + MAC: + [% nodeip.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% nodeip.oui.company | html_entity %] - + ( + [% nodeip.oui.company | html_entity %] ) [% END %] + MAC → IP [% nodeip.ip | html_entity %] @@ -179,6 +180,9 @@ $(document).ready(function() { "order": [[ 0, 'asc' ]], "stateSave": true, "pageLength": 25, + "language": { + "search": 'Filter records: ' + }, "drawCallback": function ( settings ) { var api = this.api(); var rows = api.rows( {page:'current'} ).nodes(); @@ -187,12 +191,8 @@ $(document).ready(function() { api.column(0, {page:'current'} ).data().each( function ( group, i ) { if ( last !== group ) { $(rows).eq( i ).before( - [% IF params.show_vendor && params.stamps %] - ''+group+'' - [% ELSIF params.stamps %] + [% IF params.stamps %] ''+group+'' - [% ELSIF params.show_vendor %] - ''+group+'' [% ELSE %] ''+group+'' [% END %] diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt index c5ff8634..198d71b9 100644 --- a/Netdisco/share/views/ajax/search/node_by_mac.tt +++ b/Netdisco/share/views/ajax/search/node_by_mac.tt @@ -3,9 +3,6 @@ MAC - [% IF params.show_vendor %] - Vendor - [% END %] Match Device or Node [% IF params.stamps %] @@ -18,13 +15,13 @@ [% WHILE (row = ips.next) %] - + MAC: [% row.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% row.oui.company | html_entity %] - + ( + [% row.oui.company | html_entity %] ) [% END %] + MAC → IP [% row.ip | html_entity %] [% '  ' IF NOT row.active %] @@ -39,14 +36,13 @@ [% WHILE (node = sightings.next) %] - + MAC: [% node.net_mac.$mac_format_call | html_entity %] - [% IF params.show_vendor %] - - [% node.oui.company | html_entity %] - + ( + [% node.oui.company | html_entity %] ) [% END %] + Switch Port @@ -65,13 +61,12 @@ [% WHILE (port = ports.next) %] - [% port.net_mac.$mac_format_call | html_entity %] - + MAC: [% port.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% port.oui.company | html_entity %] - + ( + [% port.oui.company | html_entity %] ) [% END %] + Switch Port @@ -89,13 +84,12 @@ [% WHILE (nbt = netbios.next) %] - [% nbt.net_mac.$mac_format_call | html_entity %] - + MAC: [% nbt.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% nbt.oui.company | html_entity %] - + ( + [% nbt.oui.company | html_entity %] ) [% END %] + NetBIOS \\[% nbt.domain | html_entity %]\[% nbt.nbname | html_entity %]
[% nbt.nbuser || '[No User]' | html_entity %]@[% nbt.ip | html_entity %] @@ -109,13 +103,12 @@ [% WHILE (wlan = wireless.next) %] - [% wlan.net_mac.$mac_format_call | html_entity %] - + MAC: [% wlan.net_mac.$mac_format_call | html_entity %] [% IF params.show_vendor %] - - [% wlan.oui.company | html_entity %] - + ( + [% wlan.oui.company | html_entity %] ) [% END %] + Wireless Info SSID: [% wlan.ssid | html_entity %]
MaxRate: [% wlan.maxrate | html_entity %]Mbps TxRate: [% wlan.txrate | html_entity %]Mbps
@@ -148,6 +141,9 @@ $(document).ready(function() { "order": [[ 0, 'asc' ]], "stateSave": true, "pageLength": 25, + "language": { + "search": 'Filter records: ' + }, "drawCallback": function ( settings ) { var api = this.api(); var rows = api.rows( {page:'current'} ).nodes(); @@ -156,12 +152,8 @@ $(document).ready(function() { api.column(0, {page:'current'} ).data().each( function ( group, i ) { if ( last !== group ) { $(rows).eq( i ).before( - [% IF params.show_vendor && params.stamps %] - ''+group+'' - [% ELSIF params.stamps %] + [% IF params.stamps %] ''+group+'' - [% ELSIF params.show_vendor %] - ''+group+'' [% ELSE %] ''+group+'' [% END %] From e60b5f8ff95e5d87dd2ba26524c5f127f016d7a8 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Wed, 11 Jun 2014 19:33:36 -0400 Subject: [PATCH 4/4] DataTables for Access Point Radios Channel and Power report Optimize SQL for ap_radio_channel_power virtual table Convert mW to dBm via the database query --- .../DB/Result/Virtual/ApRadioChannelPower.pm | 57 +++--- .../Web/Plugin/Report/ApRadioChannelPower.pm | 59 +++++-- .../views/ajax/report/apradiochannelpower.tt | 164 ++++++++++++------ 3 files changed, 195 insertions(+), 85 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm index 30707c1b..e600d830 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm @@ -10,30 +10,38 @@ __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table('ap_radio_channel_power'); __PACKAGE__->result_source_instance->is_virtual(1); __PACKAGE__->result_source_instance->view_definition(< 0 THEN round((10.0 * log(w.power) / log(10))::numeric, 1) + ELSE NULL + END AS power2 +FROM device_port_wireless AS w +JOIN device_port AS dp ON dp.port = w.port +AND dp.ip = w.ip +JOIN device AS d ON d.ip = w.ip +WHERE w.channel != '0' ENDSQL ); __PACKAGE__->add_columns( - 'device_name' => { - data_type => 'text', + 'channel' => { + data_type => 'integer', + }, + 'power' => { + data_type => 'integer', }, 'ip' => { data_type => 'inet', }, - 'dns' => { - data_type => 'text', - }, - 'model' => { - data_type => 'text', - }, - 'location' => { - data_type => 'text', - }, 'port' => { data_type => 'text', }, @@ -43,11 +51,20 @@ __PACKAGE__->add_columns( 'descr' => { data_type => 'text', }, - 'channel' => { - data_type => 'integer', + 'device_name' => { + data_type => 'text', }, - 'power' => { - data_type => 'integer', + 'dns' => { + data_type => 'text', + }, + 'model' => { + data_type => 'text', + }, + 'location' => { + data_type => 'text', + }, + 'power2' => { + data_type => 'numeric', }, ); diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApRadioChannelPower.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApRadioChannelPower.pm index 95cc7b67..8b6f963e 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApRadioChannelPower.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApRadioChannelPower.pm @@ -3,13 +3,14 @@ package App::Netdisco::Web::Plugin::Report::ApRadioChannelPower; use Dancer ':syntax'; use Dancer::Plugin::DBIC; use Dancer::Plugin::Auth::Extensible; +use App::Netdisco::Util::ExpandParams 'expand_hash'; use App::Netdisco::Web::Plugin; register_report( - { category => 'Wireless', - tag => 'apradiochannelpower', - label => 'Access Point Radios Channel and Power', + { category => 'Wireless', + tag => 'apradiochannelpower', + label => 'Access Point Radios Channel and Power', provides_csv => 1, } ); @@ -47,22 +48,50 @@ sub port_tree { return \%ports; } +get '/ajax/content/report/apradiochannelpower/data' => require_role admin => + sub { + send_error( 'Missing parameter', 400 ) + unless ( param('draw') && param('draw') =~ /\d+/ ); + + my $rs = schema('netdisco')->resultset('Virtual::ApRadioChannelPower'); + + my $exp_params = expand_hash( scalar params ); + + my $recordsTotal = $rs->count; + + my @data = $rs->get_datatables_data($exp_params)->hri->all; + + my $recordsFiltered = $rs->get_datatables_filtered_count($exp_params); + + content_type 'application/json'; + return to_json( + { draw => int( param('draw') ), + recordsTotal => int($recordsTotal), + recordsFiltered => int($recordsFiltered), + data => \@data, + } + ); + }; + get '/ajax/content/report/apradiochannelpower' => require_login sub { - my @set - = schema('netdisco')->resultset('Virtual::ApRadioChannelPower')->all; - my $results = port_tree( \@set ); - return unless scalar %$results; - - if (request->is_ajax) { - template 'ajax/report/apradiochannelpower.tt', { results => $results, }, - { layout => undef }; - } - else { - header( 'Content-Type' => 'text/comma-separated-values' ); - template 'ajax/report/apradiochannelpower_csv.tt', { results => $results, }, + if ( request->is_ajax ) { + template 'ajax/report/apradiochannelpower.tt', {}, { layout => undef }; } + + else { + my @results + = schema('netdisco')->resultset('Virtual::ApRadioChannelPower') + ->hri->all; + + return unless scalar @results; + + header( 'Content-Type' => 'text/comma-separated-values' ); + template 'ajax/report/apradiochannelpower_csv.tt', + { results => \@results, }, + { layout => undef }; + } }; true; diff --git a/Netdisco/share/views/ajax/report/apradiochannelpower.tt b/Netdisco/share/views/ajax/report/apradiochannelpower.tt index 92ee8171..eb103733 100644 --- a/Netdisco/share/views/ajax/report/apradiochannelpower.tt +++ b/Netdisco/share/views/ajax/report/apradiochannelpower.tt @@ -1,53 +1,117 @@ -
-[% count = 0 %] -[% FOREACH row IN results.keys.sort %] - [% count = count + 1 %] -
- -
-
- - - - - - - - - - - - [% FOREACH p IN results.$row.ports %] - [% NEXT UNLESS p.channel # No channel port is admin down %] - - - - - - - - [% END %] - -
PortNameDescriptionChannelTx Power (mW/dBm)
- - [% p.port | html_entity %][% p.name %][% p.descr %][% p.channel %][% IF p.power or p.power2 %][% p.power %] / [% p.power2 %][% END %]
-
-
-
-[%END%] -
+ + + + + + + + + + + + + +
IPDNSDevicePortNameDescriptionChannelTx Power (mW/dBm)
+ +