add invert port search option, fix wildcarding on partial

This commit is contained in:
Oliver Gorwits
2013-09-22 16:40:10 +01:00
parent 230c6e3c0c
commit 108e1b5201
4 changed files with 41 additions and 6 deletions

View File

@@ -36,10 +36,15 @@ ajax '/ajax/content/device/ports' => require_login sub {
$f =~ s/\*/%/g;
$f =~ s/\?/_/g;
# set wilcards at param boundaries
if ($f !~ m/[%_]/) {
$f =~ s/^\%*/%/;
$f =~ s/\%*$/%/;
}
# enable ILIKE op
$f = { '-ilike' => $f };
$f = { (param('invert') ? '-not_ilike' : '-ilike') => $f };
}
elsif (param('invert')) {
$f = { '!=' => $f };
}
if ($set->search({'me.port' => $f})->count) {

View File

@@ -406,8 +406,8 @@ td > form.nd_inline-form {
/* fixup for prepended partial port name checkbox in sidebar */
.nd_port-partial-checkbox {
width: 136px;
padding: 0px 0px 0px 11px !important;
width: 84px;
padding: 0px 0px 0px 5px !important;
cursor: pointer;
}
@@ -421,6 +421,27 @@ td > form.nd_inline-form {
margin-bottom: 5px !important;
}
/* fixup for prepended invert port name checkbox in sidebar */
.nd_port-invert-checkbox {
width: 30px;
padding: 0px 0px 0px 5px !important;
cursor: pointer;
}
.nd_port-invert-label {
padding: 0px !important;
/* for some reason only .add-on:first-child gets these */
-webkit-border-radius: 4px 0 0 4px !important;
-moz-border-radius: 4px 0 0 4px !important;
border-radius: 4px 0 0 4px !important;
}
.nd_port-invert {
margin-left: 5px !important;
margin-top: -5px;
margin-bottom: 5px !important;
}
/* fixup for prepended checkbox in sidebar */
.nd_sidebar .input-prepend {
margin-left: -2px;

View File

@@ -93,7 +93,9 @@
// form reset icon on ports tab
$('#nd_sidebar-reset-link').attr('href', '/device?tab=ports&reset=on&' +
$('#ports_form').find('input[name="q"],input[name="f"],input[name="partial"]').serialize())
$('#ports_form')
.find('input[name="q"],input[name="f"],input[name="partial"],input[name="invert"]')
.serialize())
[% END %]
do_search(event, '[% tab.tag %]');

View File

@@ -15,6 +15,13 @@
<label class="nd_checkboxlabel" for="partial">
<span class="nd_port-partial-checkbox uneditable-input">Partial Match</span>
</label>
<label class="add-on nd_port-invert-label">
<input type="checkbox" id="invert"
name="invert"[% ' checked="checked"' IF params.invert %]/>
</label>
<label class="nd_checkboxlabel" for="invert">
<span class="nd_port-invert-checkbox uneditable-input">Not</span>
</label>
</div>
</div>
<div class="clearfix">