filter cipher list by type

This commit is contained in:
Kyle Spearrin 2017-10-07 21:48:02 -04:00
parent 52f4a9d961
commit 4046339569
2 changed files with 49 additions and 3 deletions

View File

@ -2,11 +2,13 @@
.module('bit.vault')
.controller('vaultController', function ($scope, $uibModal, apiService, $filter, cryptoService, authService, toastr,
cipherService, $q, $localStorage, $timeout, $rootScope, $state, $analytics) {
cipherService, $q, $localStorage, $timeout, $rootScope, $state, $analytics, constants) {
$scope.loading = true;
$scope.ciphers = [];
$scope.constants = constants;
$scope.favoriteCollapsed = $localStorage.collapsedFolders && 'favorite' in $localStorage.collapsedFolders;
$scope.folderIdFilter = undefined;
$scope.typeFilter = undefined;
if ($state.params.refreshFromServer) {
$rootScope.vaultFolders = $rootScope.vaultCiphers = null;
@ -347,8 +349,19 @@
}
};
$scope.filterType = function (type) {
$scope.typeFilter = type;
if ($.AdminLTE && $.AdminLTE.layout) {
$timeout(function () {
$.AdminLTE.layout.fix();
}, 0);
}
};
$scope.clearFilters = function () {
$scope.folderIdFilter = undefined;
$scope.typeFilter = undefined;
if ($.AdminLTE && $.AdminLTE.layout) {
$timeout(function () {
@ -361,6 +374,10 @@
return $scope.folderIdFilter === undefined || folder.id === $scope.folderIdFilter;
};
$scope.cipherFilter = function (cipher) {
return $scope.typeFilter === undefined || cipher.type === $scope.typeFilter;
};
$scope.unselectAll = function () {
selectAll(false);
};

View File

@ -183,8 +183,8 @@
<div class="table-responsive" ng-show="folderCiphers.length">
<table class="table table-striped table-hover table-vmiddle">
<tbody>
<tr ng-repeat="cipher in folderCiphers = (ciphers | filter: { folderId: folder.id } |
filter: (main.searchVaultText || '')) track by cipher.id">
<tr ng-repeat="cipher in folderCiphers = (ciphers | filter: { folderId: folder.id } |
filter: cipherFilter | filter: (main.searchVaultText || '')) track by cipher.id">
<td style="width: 70px;">
<div class="btn-group" data-append-to="body">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
@ -254,6 +254,35 @@
</a>
</li>
</ul>
<h3 class="control-sidebar-heading">
<i class="fa fa-tag fa-fw"></i> Types
</h3>
<ul class="control-sidebar-menu">
<li>
<a href="#" stop-click ng-click="filterType(constants.cipherType.login)">
<i class="fa fa-check" ng-if="constants.cipherType.login === typeFilter"></i>
Login
</a>
</li>
<li>
<a href="#" stop-click ng-click="filterType(constants.cipherType.card)">
<i class="fa fa-check" ng-if="constants.cipherType.card === typeFilter"></i>
Card
</a>
</li>
<li>
<a href="#" stop-click ng-click="filterType(constants.cipherType.identity)">
<i class="fa fa-check" ng-if="constants.cipherType.identity === typeFilter"></i>
Identity
</a>
</li>
<li>
<a href="#" stop-click ng-click="filterType(constants.cipherType.secureNote)">
<i class="fa fa-check" ng-if="constants.cipherType.secureNote === typeFilter"></i>
Secure Note
</a>
</li>
</ul>
<h3 class="control-sidebar-heading">
<i class="fa fa-folder fa-fw"></i> Folders
</h3>