better port search from titlebar, option for ethernet ports
This commit is contained in:
4
Changes
4
Changes
@@ -12,6 +12,10 @@
|
|||||||
* Scheduler config does not need to be uncommented
|
* Scheduler config does not need to be uncommented
|
||||||
* More efficient polling of the job queue
|
* More efficient polling of the job queue
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
* Specific search from titlebar uses default sidebar settings
|
||||||
|
|
||||||
2.036011 - 2017-10-09
|
2.036011 - 2017-10-09
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|||||||
@@ -18,33 +18,48 @@ get '/ajax/content/search/port' => require_login sub {
|
|||||||
if ( $q =~ m/^\d+$/ ) {
|
if ( $q =~ m/^\d+$/ ) {
|
||||||
$rs
|
$rs
|
||||||
= schema('netdisco')->resultset('DevicePort')
|
= schema('netdisco')->resultset('DevicePort')
|
||||||
->columns( [qw/ ip port name descr /] )->search(
|
->columns( [qw/ ip port name up up_admin speed /] )->search({
|
||||||
{ "port_vlans.vlan" => $q },
|
"port_vlans.vlan" => $q,
|
||||||
{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /],
|
( param('uplink') ? () : (-or => [
|
||||||
|
{-not_bool => "me.is_uplink"},
|
||||||
|
{"me.is_uplink" => undef},
|
||||||
|
]) ),
|
||||||
|
( param('ethernet') ? ("me.type" => 'ethernetCsmacd') : () ),
|
||||||
|
},{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /],
|
||||||
join => [qw/ port_vlans device /]
|
join => [qw/ port_vlans device /]
|
||||||
}
|
}
|
||||||
);
|
)->with_times;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my ( $likeval, $likeclause ) = sql_match($q);
|
my ( $likeval, $likeclause ) = sql_match($q);
|
||||||
|
|
||||||
$rs
|
$rs
|
||||||
= schema('netdisco')->resultset('DevicePort')
|
= schema('netdisco')->resultset('DevicePort')
|
||||||
->columns( [qw/ ip port name descr /] )->search(
|
->columns( [qw/ ip port name up up_admin speed /] )
|
||||||
{ -or => [
|
->search({
|
||||||
{ "me.name" => ( param('partial') ? $likeclause : $q ) },
|
-and => [
|
||||||
( length $q == 17
|
-or => [
|
||||||
? { "me.mac" => $q }
|
{ "me.name" => ( param('partial') ? $likeclause : $q ) },
|
||||||
: \[ 'me.mac::text ILIKE ?', $likeval ]
|
( length $q == 17
|
||||||
),
|
? { "me.mac" => $q }
|
||||||
|
: \[ 'me.mac::text ILIKE ?', $likeval ]
|
||||||
|
),
|
||||||
|
( param('uplink') ? (
|
||||||
{ "me.remote_id" => $likeclause },
|
{ "me.remote_id" => $likeclause },
|
||||||
{ "me.remote_type" => $likeclause },
|
{ "me.remote_type" => $likeclause },
|
||||||
]
|
) : () ),
|
||||||
|
],
|
||||||
|
( param('uplink') ? () : (-or => [
|
||||||
|
{-not_bool => "me.is_uplink"},
|
||||||
|
{"me.is_uplink" => undef},
|
||||||
|
]) ),
|
||||||
|
( param('ethernet') ? ("me.type" => 'ethernetCsmacd') : () ),
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /],
|
{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /],
|
||||||
join => [qw/ port_vlans device /]
|
join => [qw/ port_vlans device /]
|
||||||
}
|
}
|
||||||
);
|
)->with_times;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @results = $rs->hri->all;
|
my @results = $rs->hri->all;
|
||||||
|
|||||||
@@ -15,24 +15,24 @@ hook 'before' => sub {
|
|||||||
{ name => 'deviceports', label => 'Device Ports', default => 'on' },
|
{ name => 'deviceports', label => 'Device Ports', default => 'on' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
# view settings for port options
|
||||||
|
var('port_options' => [
|
||||||
|
{ name => 'ethernet', label => 'Ethernet Only', default => 'on' },
|
||||||
|
]);
|
||||||
|
|
||||||
# view settings for device options
|
# view settings for device options
|
||||||
var('device_options' => [
|
var('device_options' => [
|
||||||
{ name => 'matchall', label => 'Match All Options', default => 'on' },
|
{ name => 'matchall', label => 'Match All Options', default => 'on' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return unless (request->path eq uri_for('/search')->path
|
return unless param('firstsearch') and
|
||||||
or index(request->path, uri_for('/ajax/content/search')->path) == 0);
|
(request->path eq uri_for('/search')->path
|
||||||
|
or index(request->path, uri_for('/ajax/content/search')->path) == 0);
|
||||||
|
|
||||||
foreach my $col (@{ var('node_options') }) {
|
foreach my $col (@{ var('node_options') },
|
||||||
next unless $col->{default} eq 'on';
|
@{ var('port_options') },
|
||||||
params->{$col->{name}} = 'checked'
|
@{ var('device_options') }) {
|
||||||
if not param('tab') or param('tab') ne 'node';
|
params->{$col->{name}} = 'checked' if $col->{default} eq 'on';
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $col (@{ var('device_options') }) {
|
|
||||||
next unless $col->{default} eq 'on';
|
|
||||||
params->{$col->{name}} = 'checked'
|
|
||||||
if not param('tab') or param('tab') ne 'device';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<table id="ps-data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
<table id="ps-data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Status</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Port</th>
|
<th>Port</th>
|
||||||
<th>Description</th>
|
|
||||||
<th>Vlan</th>
|
<th>Vlan</th>
|
||||||
|
<th>Speed</th>
|
||||||
|
<th>Last Change</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
@@ -14,29 +16,55 @@ $(document).ready(function() {
|
|||||||
var table = $('#ps-data-table').dataTable({
|
var table = $('#ps-data-table').dataTable({
|
||||||
"deferRender": true,
|
"deferRender": true,
|
||||||
"data": [% results %],
|
"data": [% results %],
|
||||||
|
"columnDefs": [
|
||||||
|
{ "sortable": false, "targets": 0 },
|
||||||
|
{ "searchable": false, "targets": 0 },
|
||||||
|
{ "type": 'portsort', "targets": [ 'portsort' ] }
|
||||||
|
],
|
||||||
|
"order": [[ 1, 'asc' ]],
|
||||||
"columns": [{
|
"columns": [{
|
||||||
|
"data": 'up',
|
||||||
|
"className": "nd_center-cell nd_devport-icon",
|
||||||
|
"render": function(data, type, row, meta) {
|
||||||
|
if (row.up_admin != "up") {
|
||||||
|
return'<i class="icon-remove"></i>';
|
||||||
|
}
|
||||||
|
else if (row.up_admin == "up" && (row.up != "up" && row.up != "dormant")) {
|
||||||
|
return '<i class="icon-arrow-down text-error"></i>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '<i class="icon-angle-up text-success"></i>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
"data": 'name',
|
"data": 'name',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return he.encode(data || '');
|
return he.encode(data || '');
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'ip',
|
"data": 'ip',
|
||||||
|
"className": "nd_nowrap nd_center-cell",
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
var ddns = '';
|
var ddns = '';
|
||||||
if (row.device.dns || row.device.name) {
|
if (row.device.dns || row.device.name) {
|
||||||
ddns = ' (' + he.encode(row.device.dns || row.device.name) + ')';
|
ddns = '<br>(' + he.encode(row.device.dns || row.device.name) + ')';
|
||||||
}
|
}
|
||||||
return '<a href="[% device_ports %]&q=' + encodeURIComponent(data)
|
return '<a href="[% device_ports %]&q=' + encodeURIComponent(data)
|
||||||
+ '&f=' + encodeURIComponent(row.port) + '">' + he.encode(data)
|
+ '&f=' + encodeURIComponent(row.port) + '">' + he.encode(data)
|
||||||
+ ' [' + he.encode(row.port) + ']</a>' + ddns;
|
+ ' [' + he.encode(row.port) + ']</a>' + ddns;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'descr',
|
"data": 'port_vlans.vlan',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return he.encode(data || '');
|
return data || '';
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'port_vlans.vlan',
|
"data": 'speed',
|
||||||
|
"render": function(data, type, row, meta) {
|
||||||
|
return data || '';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"data": 'lastchange_stamp',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return data || '';
|
return data || '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,7 @@
|
|||||||
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
|
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
|
||||||
<input placeholder="Find Anything" class="search-query span3"
|
<input placeholder="Find Anything" class="search-query span3"
|
||||||
id="nq" name="q" value="[% display_name %]" type="text" autocomplete="off"/>
|
id="nq" name="q" value="[% display_name %]" type="text" autocomplete="off"/>
|
||||||
|
<input name="firstsearch" type="hidden" value="on">
|
||||||
<div class="btn-group nd_navbar-search-group">
|
<div class="btn-group nd_navbar-search-group">
|
||||||
<button class="btn btn-inverse nd_navbar-search-icon">
|
<button class="btn btn-inverse nd_navbar-search-icon">
|
||||||
<span style="font-size: 18px;">
|
<span style="font-size: 18px;">
|
||||||
|
|||||||
@@ -10,5 +10,23 @@
|
|||||||
<span class="nd_searchcheckbox uneditable-input">Partial Match</span>
|
<span class="nd_searchcheckbox uneditable-input">Partial Match</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="clearfix input-prepend">
|
||||||
|
<label class="add-on">
|
||||||
|
<input type="checkbox" id="port_uplink"
|
||||||
|
name="uplink"[% ' checked="checked"' IF params.uplink %]/>
|
||||||
|
</label>
|
||||||
|
<label class="nd_checkboxlabel" for="port_uplink">
|
||||||
|
<span class="nd_searchcheckbox uneditable-input">Uplinks</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix input-prepend">
|
||||||
|
<label class="add-on">
|
||||||
|
<input type="checkbox" id="port_ethernet"
|
||||||
|
name="ethernet"[% ' checked="checked"' IF params.ethernet %]/>
|
||||||
|
</label>
|
||||||
|
<label class="nd_checkboxlabel" for="port_ethernet">
|
||||||
|
<span class="nd_searchcheckbox uneditable-input">Ethernet Only</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info">
|
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info">
|
||||||
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search Ports</button>
|
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search Ports</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user