better port search from titlebar, option for ethernet ports

This commit is contained in:
Oliver Gorwits
2017-12-08 23:01:57 +00:00
parent fe7412e19a
commit f09442f63d
6 changed files with 96 additions and 30 deletions

View File

@@ -1,10 +1,12 @@
<table id="ps-data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>Status</th>
<th>Name</th>
<th>Port</th>
<th>Description</th>
<th>Vlan</th>
<th>Speed</th>
<th>Last Change</th>
</tr>
</thead>
</table>
@@ -14,29 +16,55 @@ $(document).ready(function() {
var table = $('#ps-data-table').dataTable({
"deferRender": true,
"data": [% results %],
"columnDefs": [
{ "sortable": false, "targets": 0 },
{ "searchable": false, "targets": 0 },
{ "type": 'portsort', "targets": [ 'portsort' ] }
],
"order": [[ 1, 'asc' ]],
"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',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'ip',
"className": "nd_nowrap nd_center-cell",
"render": function(data, type, row, meta) {
var ddns = '';
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)
+ '&f=' + encodeURIComponent(row.port) + '">' + he.encode(data)
+ ' [' + he.encode(row.port) + ']</a>' + ddns;
}
}, {
"data": 'descr',
"data": 'port_vlans.vlan',
"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) {
return data || '';
}

View File

@@ -138,6 +138,7 @@
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
<input placeholder="Find Anything" class="search-query span3"
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">
<button class="btn btn-inverse nd_navbar-search-icon">
<span style="font-size: 18px;">

View File

@@ -10,5 +10,23 @@
<span class="nd_searchcheckbox uneditable-input">Partial Match</span>
</label>
</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">
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search Ports</button>