mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-06 11:35:50 +08:00
Add regex search
This commit is contained in:
parent
d79a20e7b6
commit
77c2efd7d0
6 changed files with 52 additions and 20 deletions
12
css/app.css
12
css/app.css
|
@ -443,6 +443,18 @@
|
||||||
right: 10px;
|
right: 10px;
|
||||||
top: 12px;
|
top: 12px;
|
||||||
z-index: 99999999; }
|
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 {
|
#app-content #app-content-wrapper .credential-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 44px; }
|
margin-top: 44px; }
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -35,29 +35,36 @@
|
||||||
return function (credentials, filter) {
|
return function (credentials, filter) {
|
||||||
var _credentials = [];
|
var _credentials = [];
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
if(!filter){
|
if (!filter) {
|
||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
if (filter.filterText.trim() === "") {
|
if (filter.filterText.trim() === "") {
|
||||||
return credentials;
|
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++) {
|
for (var ci = 0; ci < credentials.length; ci++) {
|
||||||
var c = credentials[ci];
|
var c = credentials[ci];
|
||||||
for (var f = 0; f < filter.fields.length; f++) {
|
if (matchedWithFilter(c)) {
|
||||||
var field = filter.fields[f];
|
_credentials.push(c);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _credentials;
|
return _credentials;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -125,6 +125,16 @@
|
||||||
top: 12px;
|
top: 12px;
|
||||||
z-index: 99999999;
|
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 {
|
.credential-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -25,9 +25,12 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="searchboxContainer">
|
<div class="searchboxContainer" ng-init="filterOptionShown = false;" off-click="filterOptionShown = false;">
|
||||||
<input type="text" ng-model="filterOptions.filterText" class="searchbox"
|
<input type="text" ng-model="filterOptions.filterText" class="searchbox" id="searchBox"
|
||||||
placeholder="{{'search.credential' | translate}}" select-on-click clear-btn>
|
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>
|
||||||
<div class="viewModes">
|
<div class="viewModes">
|
||||||
<div class="view-mode" ng-class="{'active': view_mode === 'list' }"
|
<div class="view-mode" ng-class="{'active': view_mode === 'list' }"
|
||||||
|
|
Loading…
Add table
Reference in a new issue