diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortSsid.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortSsid.pm
index b5936329..36f27168 100644
--- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortSsid.pm
+++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortSsid.pm
@@ -44,26 +44,34 @@ get '/ajax/content/report/portssid' => require_login sub {
if ( defined $ssid ) {
- $rs
- = $rs->search( { ssid => $ssid } )
- ->prefetch( [qw/ device port /] )
- ->order_by( [qw/ port.ip port.port /] )->hri;
+ $rs = $rs->search(
+ { ssid => $ssid },
+ { '+columns' => [
+ qw/ device.dns device.name device.model device.vendor port.port/
+ ],
+ join => [qw/ device port /],
+ collapse => 1,
+ }
+ )->order_by( [qw/ port.ip port.port /] )->hri;
}
else {
$rs = $rs->get_ssids->hri;
}
- return unless $rs->has_rows;
+ my @results = $rs->all;
+ return unless scalar @results;
if ( request->is_ajax ) {
- template 'ajax/report/portssid.tt', { results => $rs, opt => $ssid },
+ my $json = to_json( \@results );
+ template 'ajax/report/portssid.tt',
+ { results => $json, opt => $ssid },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/portssid_csv.tt',
- { results => $rs, opt => $ssid },
+ { results => \@results, opt => $ssid },
{ layout => undef };
}
};
diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/SsidInventory.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/SsidInventory.pm
index 85decf3c..910bdddd 100644
--- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/SsidInventory.pm
+++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/SsidInventory.pm
@@ -15,16 +15,19 @@ register_report(
);
get '/ajax/content/report/ssidinventory' => require_login sub {
- my $rs = schema('netdisco')->resultset('DevicePortSsid')->get_ssids->hri;
- return unless $rs->has_rows;
+ my @results = schema('netdisco')->resultset('DevicePortSsid')
+ ->get_ssids->hri->all;
+
+ return unless scalar @results;
if ( request->is_ajax ) {
- template 'ajax/report/portssid.tt', { results => $rs, },
+ my $json = to_json( \@results );
+ template 'ajax/report/portssid.tt', { results => $json },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
- template 'ajax/report/portssid_csv.tt', { results => $rs, },
+ template 'ajax/report/portssid_csv.tt', { results => \@results },
{ layout => undef };
}
};
diff --git a/Netdisco/share/views/ajax/report/portssid.tt b/Netdisco/share/views/ajax/report/portssid.tt
index 0a09cc3d..6aeeea8f 100644
--- a/Netdisco/share/views/ajax/report/portssid.tt
+++ b/Netdisco/share/views/ajax/report/portssid.tt
@@ -1,6 +1,6 @@
[% USE Number.Format %]
[% IF opt %]
-
+
[% ELSE %]
-
+
| SSID |
@@ -35,18 +20,67 @@
Count |
-
- [% WHILE (row = results.next) %]
-
- |
-
- [% row.ssid | html_entity %]
- |
- [% row.broadcast ? 'Yes' : 'No' %] |
- [% row.count | format_number %] |
-
- [% END %]
-
[% END %]
+
+
diff --git a/Netdisco/share/views/ajax/report/portssid_csv.tt b/Netdisco/share/views/ajax/report/portssid_csv.tt
index fa6e2ffb..02c27277 100644
--- a/Netdisco/share/views/ajax/report/portssid_csv.tt
+++ b/Netdisco/share/views/ajax/report/portssid_csv.tt
@@ -2,7 +2,7 @@
[% IF opt %]
[% CSV.dump(['Device' 'Port' 'Name' 'Broadcast' 'Model' 'SSID' 'Vendor']) %]
- [% WHILE (row = results.next) %]
+ [% FOREACH row IN results %]
[% mylist = [] %]
[% device = row.device.dns || row.device.name || row.device.ip %]
[% broadcast = row.broadcast ? 'Yes' : 'No' %]
@@ -15,7 +15,7 @@
[% ELSE %]
[% CSV.dump(['SSID' 'Count']) %]
- [% WHILE (row = results.next) %]
+ [% FOREACH row IN results %]
[% mylist = [] %]
[% FOREACH col IN [ row.ssid row.count ] %]
[% mylist.push(col) %]