Add regex search

This commit is contained in:
brantje 2017-01-03 16:19:53 +01:00
parent d79a20e7b6
commit 77c2efd7d0
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
6 changed files with 52 additions and 20 deletions

View file

@ -443,6 +443,18 @@
right: 10px;
top: 12px;
z-index: 99999999; }
#app-content #app-content-wrapper .searchboxContainer .searchOptions {
position: relative;
bottom: 5px;
background: #fff;
border: 1px solid #ddd;
padding: 5px;
width: calc(100% - 3px);
-webkit-border-bottom-right-radius: 3px;
border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
background-clip: padding-box; }
#app-content #app-content-wrapper .credential-table {
width: 100%;
margin-top: 44px; }

File diff suppressed because one or more lines are too long

View file

@ -35,29 +35,36 @@
return function (credentials, filter) {
var _credentials = [];
if (credentials) {
if(!filter){
if (!filter) {
return credentials;
}
if (filter.filterText.trim() === "") {
return credentials;
}
var matchedWithFilter = function (c) {
for (var f = 0; f < filter.fields.length; f++) {
var field = filter.fields[f];
var fieldValue = (typeof c[field] === 'string') ? c[field] : JSON.stringify(c[field]);
if (filter.hasOwnProperty('useRegex') && filter.useRegex === true) {
var patt;
patt = new RegExp(filter.filterText);
if (patt.test(fieldValue)) {
return true;
}
}
if (fieldValue.toLowerCase().indexOf(filter.filterText.toLowerCase()) >= 0) {
return true;
}
}
return false;
};
for (var ci = 0; ci < credentials.length; ci++) {
var c = credentials[ci];
for (var f = 0; f < filter.fields.length; f++) {
var field = filter.fields[f];
if (typeof c[field] === 'string') {
if (c[field].toLowerCase().indexOf(filter.filterText.toLowerCase()) >= 0) {
_credentials.push(c);
break;
}
} else {
var t = JSON.stringify(c[field]);
if (t.indexOf(filter.filterText) >= 0) {
_credentials.push(c);
break;
}
}
if (matchedWithFilter(c)) {
_credentials.push(c);
}
}
return _credentials;

File diff suppressed because one or more lines are too long

View file

@ -125,6 +125,16 @@
top: 12px;
z-index: 99999999;
}
.searchOptions{
position: relative;
bottom: 5px;
background: #fff;
border: 1px solid #ddd;
padding: 5px;
width: calc(100% - 3px);
box-shadow: 3px 3px 5px #888888;
@include border-bottom-radius(3px);
}
}
.credential-table {
width: 100%;

View file

@ -25,9 +25,12 @@
>
</div>
<div class="searchboxContainer">
<input type="text" ng-model="filterOptions.filterText" class="searchbox"
placeholder="{{'search.credential' | translate}}" select-on-click clear-btn>
<div class="searchboxContainer" ng-init="filterOptionShown = false;" off-click="filterOptionShown = false;">
<input type="text" ng-model="filterOptions.filterText" class="searchbox" id="searchBox"
placeholder="{{'search.credential' | translate}}" select-on-click clear-btn ng-click="filterOptionShown = true;">
<div class="searchOptions" ng-show="filterOptionShown">
<input type="checkbox" ng-model="filterOptions.useRegex"> Use regex
</div>
</div>
<div class="viewModes">
<div class="view-mode" ng-class="{'active': view_mode === 'list' }"