mirror of
https://github.com/nextcloud/passman.git
synced 2026-01-04 06:37:12 +08:00
Implemented special filters
Signed-off-by: Felix Nüsse <Felix.nuesse@t-online.de>
This commit is contained in:
parent
f218b126ba
commit
e44fea71c8
4 changed files with 175 additions and 79 deletions
|
|
@ -351,95 +351,146 @@
|
|||
});
|
||||
}
|
||||
|
||||
$scope.filtered_credentials = [];
|
||||
$scope.$watch('[selectedtags, filterOptions, delete_time, active_vault.credentials]', function () {
|
||||
if (!$scope.active_vault) {
|
||||
return;
|
||||
}
|
||||
if ($scope.active_vault.credentials) {
|
||||
var credentials = angular.copy($scope.active_vault.credentials);
|
||||
var filtered_credentials = $filter('credentialSearch')(credentials, $scope.filterOptions);
|
||||
filtered_credentials = $filter('tagFilter')(filtered_credentials, $scope.selectedtags);
|
||||
filtered_credentials = $filter('filter')(filtered_credentials, {hidden: 0});
|
||||
$scope.filtered_credentials = filtered_credentials;
|
||||
$scope.filterOptions.selectedtags = angular.copy($scope.selectedtags);
|
||||
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
var _credential = $scope.active_vault.credentials[i];
|
||||
if (_credential.tags) {
|
||||
TagService.addTags(_credential.tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.filtered_credentials = [];
|
||||
$scope.$watch('[selectedtags, filterOptions, delete_time, active_vault.credentials]', function () {
|
||||
if (!$scope.active_vault) {
|
||||
return;
|
||||
}
|
||||
if ($scope.active_vault.credentials) {
|
||||
var credentials = angular.copy($scope.active_vault.credentials);
|
||||
var filtered_credentials = $filter('credentialSearch')(credentials, $scope.filterOptions);
|
||||
filtered_credentials = $filter('tagFilter')(filtered_credentials, $scope.selectedtags);
|
||||
filtered_credentials = $filter('filter')(filtered_credentials, {hidden: 0});
|
||||
$scope.filtered_credentials = filtered_credentials;
|
||||
$scope.filterOptions.selectedtags = angular.copy($scope.selectedtags);
|
||||
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
var _credential = $scope.active_vault.credentials[i];
|
||||
if (_credential.tags) {
|
||||
TagService.addTags(_credential.tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, true);
|
||||
}, true);
|
||||
|
||||
$scope.selectedtags = [];
|
||||
var to;
|
||||
$rootScope.$on('selected_tags_updated', function (evt, _sTags) {
|
||||
var _selectedTags = [];
|
||||
for (var x = 0; x < _sTags.length; x++) {
|
||||
_selectedTags.push(_sTags[x].text);
|
||||
}
|
||||
$scope.selectedtags = _selectedTags;
|
||||
$timeout.cancel(to);
|
||||
if (_selectedTags.length > 0) {
|
||||
to = $timeout(function () {
|
||||
if ($scope.filtered_credentials) {
|
||||
var _filtered_tags = [];
|
||||
for (var i = 0; i < $scope.filtered_credentials.length; i++) {
|
||||
var tags = $scope.filtered_credentials[i].tags_raw;
|
||||
for (var x = 0; x < tags.length; x++) {
|
||||
var tag = tags[x].text;
|
||||
if (_filtered_tags.indexOf(tag) === -1) {
|
||||
_filtered_tags.push(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
//watch for special tags
|
||||
$scope.$on('filterSpecial', function(event, args) {
|
||||
console.log("strength: "+args);
|
||||
switch (args) {
|
||||
case "strength_good": $scope.filterStrength(3,1000); break;
|
||||
case "strength_medium": $scope.filterStrength(2,3); break;
|
||||
case "strength_low": $scope.filterStrength(0,1); break;
|
||||
case "expired": $scope.filterExpired(); break;
|
||||
case "all": $scope.filterAll(); break;
|
||||
|
||||
$rootScope.$emit('limit_tags_in_list', _filtered_tags);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.delete_time = 0;
|
||||
$scope.showCredentialRow = function (credential) {
|
||||
if ($scope.delete_time === 0) {
|
||||
return credential.delete_time === 0;
|
||||
} else {
|
||||
return credential.delete_time > $scope.delete_time;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
$scope.filterAll = function(){
|
||||
$scope.selectedtags=[];
|
||||
$scope.filterOptions.filterText="";
|
||||
$scope.filtered_credentials=$scope.active_vault.credentials;
|
||||
};
|
||||
|
||||
$rootScope.$on('set_delete_time', function (event, time) {
|
||||
$scope.delete_time = time;
|
||||
});
|
||||
$scope.filterStrength = function(strength_min, strength_max){
|
||||
var initialCredentials=$scope.active_vault.credentials;
|
||||
var postFiltered=[];
|
||||
for (var i = 0; i < initialCredentials.length; i++) {
|
||||
var _credential = initialCredentials[i];
|
||||
var zxcvbn_result = zxcvbn(_credential.password);
|
||||
|
||||
$scope.setDeleteTime = function (delete_time) {
|
||||
$scope.delete_time = delete_time;
|
||||
};
|
||||
if(zxcvbn_result.score>=strength_min && zxcvbn_result.score<=strength_max){
|
||||
postFiltered.push(initialCredentials[i]);
|
||||
}
|
||||
}
|
||||
$scope.filtered_credentials=postFiltered;
|
||||
};
|
||||
|
||||
$scope.selectedCredential = false;
|
||||
$scope.selectCredential = function (credential) {
|
||||
if(credential.description) {
|
||||
credential.description_html = $sce.trustAsHtml(angular.copy(credential.description).replace("\n", '<br />'));
|
||||
}
|
||||
$scope.selectedCredential = angular.copy(credential);
|
||||
$rootScope.$emit('app_menu', true);
|
||||
};
|
||||
$scope.filterExpired = function(){
|
||||
var initialCredentials=$scope.active_vault.credentials;
|
||||
var now = Date.now();
|
||||
console.log(now);
|
||||
var postFiltered=[];
|
||||
|
||||
$scope.closeSelected = function () {
|
||||
$rootScope.$emit('app_menu', false);
|
||||
$scope.selectedCredential = false;
|
||||
};
|
||||
for (var i = 0; i < initialCredentials.length; i++) {
|
||||
var _credential = initialCredentials[i];
|
||||
|
||||
$rootScope.$on('logout', function () {
|
||||
if($scope.active_vault) {
|
||||
$rootScope.vaultCache[$scope.active_vault.guid] = null;
|
||||
}
|
||||
$scope.active_vault = null;
|
||||
$scope.credentials = [];
|
||||
if(_credential.expire_time!==0 && _credential.expire_time <= now){
|
||||
postFiltered.push(initialCredentials[i]);
|
||||
}
|
||||
}
|
||||
$scope.filtered_credentials=postFiltered;
|
||||
};
|
||||
|
||||
|
||||
$scope.selectedtags = [];
|
||||
var to;
|
||||
$rootScope.$on('selected_tags_updated', function (evt, _sTags) {
|
||||
var _selectedTags = [];
|
||||
for (var x = 0; x < _sTags.length; x++) {
|
||||
_selectedTags.push(_sTags[x].text);
|
||||
}
|
||||
$scope.selectedtags = _selectedTags;
|
||||
$timeout.cancel(to);
|
||||
if (_selectedTags.length > 0) {
|
||||
to = $timeout(function () {
|
||||
if ($scope.filtered_credentials) {
|
||||
var _filtered_tags = [];
|
||||
for (var i = 0; i < $scope.filtered_credentials.length; i++) {
|
||||
var tags = $scope.filtered_credentials[i].tags_raw;
|
||||
for (var x = 0; x < tags.length; x++) {
|
||||
var tag = tags[x].text;
|
||||
if (_filtered_tags.indexOf(tag) === -1) {
|
||||
_filtered_tags.push(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rootScope.$emit('limit_tags_in_list', _filtered_tags);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.delete_time = 0;
|
||||
$scope.showCredentialRow = function (credential) {
|
||||
if ($scope.delete_time === 0) {
|
||||
return credential.delete_time === 0;
|
||||
} else {
|
||||
return credential.delete_time > $scope.delete_time;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$rootScope.$on('set_delete_time', function (event, time) {
|
||||
$scope.delete_time = time;
|
||||
});
|
||||
|
||||
$scope.setDeleteTime = function (delete_time) {
|
||||
$scope.delete_time = delete_time;
|
||||
};
|
||||
|
||||
$scope.selectedCredential = false;
|
||||
$scope.selectCredential = function (credential) {
|
||||
if (credential.description) {
|
||||
credential.description_html = $sce.trustAsHtml(angular.copy(credential.description).replace("\n", '<br />'));
|
||||
}
|
||||
$scope.selectedCredential = angular.copy(credential);
|
||||
$rootScope.$emit('app_menu', true);
|
||||
};
|
||||
|
||||
$scope.closeSelected = function () {
|
||||
$rootScope.$emit('app_menu', false);
|
||||
$scope.selectedCredential = false;
|
||||
};
|
||||
|
||||
$rootScope.$on('logout', function () {
|
||||
if ($scope.active_vault) {
|
||||
$rootScope.vaultCache[$scope.active_vault.guid] = null;
|
||||
}
|
||||
$scope.active_vault = null;
|
||||
$scope.credentials = [];
|
||||
// $scope.$parent.selectedVault = false;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
$scope.filterCredentialBySpecial = function (string) {
|
||||
$rootScope.$broadcast('filterSpecial',string);
|
||||
};
|
||||
|
||||
$scope.tagCollapsibleClicked = function () {
|
||||
if ($scope.tagCollapsibleOpen === true)
|
||||
$scope.tagCollapsibleOpen = false;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@
|
|||
background-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.bullet-color-red {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.bullet-color-yellow {
|
||||
background-color: #ffe300;
|
||||
}
|
||||
|
||||
.bullet-color-green {
|
||||
background-color: greenyellow;
|
||||
}
|
||||
|
||||
|
||||
.highlight-selected{
|
||||
background-color: var(--color-primary);
|
||||
|
|
@ -97,4 +109,10 @@
|
|||
> ul ul {
|
||||
display: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//source https://material.io/tools/icons/?icon=restore&style=baseline
|
||||
.icon-expired{
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M0 0h24v24H0z' fill='none'/><path d='M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z'/></svg>");
|
||||
}
|
||||
|
|
@ -134,6 +134,10 @@ style('passman', 'app');
|
|||
</a>
|
||||
</li>-->
|
||||
|
||||
<li>
|
||||
<a class="icon-toggle svg" ng-click="filterCredentialBySpecial('all')">{{ 'Show All' | translate }}</a>
|
||||
</li>
|
||||
|
||||
<li class="collapsible open" ng-class="{'open':tagCollapsibleState()}">
|
||||
<button class="collapse" ng-click="tagCollapsibleClicked()"></button>
|
||||
|
||||
|
|
@ -146,6 +150,25 @@ style('passman', 'app');
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="app-navigation-entry-bullet bullet-color-red"></div>
|
||||
<a ng-click="filterCredentialBySpecial('strength_low')">{{ 'Bad Strength' | translate }}</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="app-navigation-entry-bullet bullet-color-yellow"></div>
|
||||
<a ng-click="filterCredentialBySpecial('strength_medium')">{{ 'Medium Strength' | translate }}</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="app-navigation-entry-bullet bullet-color-green"></div>
|
||||
<a ng-click="filterCredentialBySpecial('strength_good')">{{ 'Good Strength' | translate }}</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="icon-expired svg" ng-click="filterCredentialBySpecial('expired')">{{ 'Expired' | translate }}</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li data-id="trashbin" class="nav-trashbin pinned first-pinned">
|
||||
<a ng-click="toggleDeleteTime()" ng-class="{'active': delete_time > 0}" class="icon-delete svg">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue