much better wildcard/partial port search
This does not require silly quoting. It adds a "partial" checkbox in the ports sidebar. If this is ticked, simple wildcarding * and ? are also supported.
This commit is contained in:
@@ -31,9 +31,16 @@ ajax '/ajax/content/device/ports' => require_login sub {
|
|||||||
return unless $set->count;
|
return unless $set->count;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$f =~ s/\*/%/g if index($f, '*') >= 0;
|
if (param('partial')) {
|
||||||
$f =~ s/\?/_/g if index($f, '?') >= 0;
|
# change wildcard chars to SQL
|
||||||
$f = { '-ilike' => $f };
|
$f =~ s/\*/%/g;
|
||||||
|
$f =~ s/\?/_/g;
|
||||||
|
# set wilcards at param boundaries
|
||||||
|
$f =~ s/^\%*/%/;
|
||||||
|
$f =~ s/\%*$/%/;
|
||||||
|
# enable ILIKE op
|
||||||
|
$f = { '-ilike' => $f };
|
||||||
|
}
|
||||||
|
|
||||||
if ($set->search({'me.port' => $f})->count) {
|
if ($set->search({'me.port' => $f})->count) {
|
||||||
$set = $set->search({'me.port' => $f});
|
$set = $set->search({'me.port' => $f});
|
||||||
|
|||||||
@@ -385,6 +385,23 @@ td > form.nd_inline-form {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fixup for prepended partial port name checkbox in sidebar */
|
||||||
|
.nd_port-partial-checkbox {
|
||||||
|
width: 136px;
|
||||||
|
padding: 0px 0px 0px 11px !important;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nd_port-partial-label {
|
||||||
|
padding: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nd_port-partial {
|
||||||
|
margin-left: 5px !important;
|
||||||
|
margin-top: -5px;
|
||||||
|
margin-bottom: 5px !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* fixup for prepended checkbox in sidebar */
|
/* fixup for prepended checkbox in sidebar */
|
||||||
.nd_sidebar .input-prepend {
|
.nd_sidebar .input-prepend {
|
||||||
margin-left: -2px;
|
margin-left: -2px;
|
||||||
|
|||||||
@@ -7,6 +7,15 @@
|
|||||||
<input id="nd_port-query" placeholder="Port, Name or VLAN"
|
<input id="nd_port-query" placeholder="Port, Name or VLAN"
|
||||||
name="f" value="[% params.f | html_entity %]" type="text"
|
name="f" value="[% params.f | html_entity %]" type="text"
|
||||||
rel="tooltip" data-placement="left" data-offset="5" data-title="Filter by Port, Name or VLAN"/>
|
rel="tooltip" data-placement="left" data-offset="5" data-title="Filter by Port, Name or VLAN"/>
|
||||||
|
<div class="clearfix input-prepend nd_port-partial">
|
||||||
|
<label class="add-on nd_port-partial-label">
|
||||||
|
<input type="checkbox" id="partial"
|
||||||
|
name="partial"[% ' checked="checked"' IF params.partial %]/>
|
||||||
|
</label>
|
||||||
|
<label class="nd_checkboxlabel" for="partial">
|
||||||
|
<span class="nd_port-partial-checkbox uneditable-input">Partial Match</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<span data-toggle="collapse" data-target="#nd_legend">
|
<span data-toggle="collapse" data-target="#nd_legend">
|
||||||
|
|||||||
Reference in New Issue
Block a user