Filter tag list

This commit is contained in:
brantje 2016-09-20 18:38:49 +02:00
parent 51ae8754ed
commit f3b945454f
7 changed files with 65 additions and 4 deletions

View file

@ -102,12 +102,32 @@ angular.module('passmanApp')
label: ''
};
$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;

View file

@ -24,6 +24,27 @@ angular.module('passmanApp')
return TagService.searchTag($query);
};
$scope.filtered_tags = [];
$rootScope.$on('limit_tags_in_list', function (evt, tags) {
$scope.filtered_tags = [];
for (var i = 0; i < tags.length; i++) {
var tag = {
text: tags[i]
};
var found = false;
for (var x = 0; x < $scope.selectedTags.length; x++) {
if($scope.selectedTags[x].text === tag.text){
found = true;
}
}
if(found === false){
$scope.filtered_tags.push(tag);
}
}
});
$scope.$watch('selectedTags', function () {
$rootScope.$broadcast('selected_tags_updated', $scope.selectedTags)
}, true);
@ -35,7 +56,11 @@ angular.module('passmanApp')
$scope.available_tags = TagService.getTags();
$scope.$watch(function () {
return TagService.getTags();
if ($scope.selectedTags.length === 0) {
return TagService.getTags();
} else {
return $scope.filtered_tags;
}
}, function (tags) {
$scope.available_tags = tags;
}, true);

16
js/app/filters/as.js Normal file
View file

@ -0,0 +1,16 @@
'use strict';
/**
* @ngdoc filter
* @name passmanApp.filter:as
* @function
* @description
* # as
* Filter in the passmanApp.
*/
angular.module('passmanApp')
.filter("as", function($parse) {
return function(value, context, path) {
return $parse(path).assign(context, value);
};
});

View file

@ -47,7 +47,7 @@ angular.module('views/partials/password-meter.html', []).run(['$templateCache',
angular.module('views/show_vault.html', []).run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('views/show_vault.html',
'<div id="controls"><div class="breadcrumb"></div><div class="actions creatable"><span ng-click="menuOpen = !menuOpen" class="button new" ng-init="menuOpen = false" off-click="menuOpen = false;"><span>New</span></span><div class="actionList popovermenu bubble menu" ng-show="menuOpen"><ul><li><span ng-click="addCredential()" class="menuitem action"><span class="icon icon-rename"></span> <span>New credential</span></span></li><li><span href="#" class="menuitem action"><span class="icon icon-shared"></span> <span>New shared credential</span></span></li></ul></div><input type="text" ng-model="itemFilter.label"> <span class="title" ng-if="delete_time">Showing deleted since: <span ng-if="delete_time == 1">All time</span> <span ng-if="delete_time > 1">{{delete_time | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</span></span></div></div><div off-click="closeSelected()"><table class="credential-table" ng-init="menuOpen = false;"><tr ng-repeat="credential in credentials | filter:itemFilter | tagFilter:selectedtags" ng-if="credential.hidden == 0 && showCredentialRow(credential)" ng-click="selectCredential(credential)" ng-class="{\'selected\': selectedCredential.credential_id == credential.credential_id}"><td><span class="label">{{credential.label}}</span> <span class="tags"><span class="tag" ng-repeat="tag in credential.tags_raw">{{tag.text}}</span></span></td></tr></table><div id="app-sidebar" class="detailsView scroll-container app_sidebar" ng-show="selectedCredential"><span class="close icon-close" ng-click="closeSelected()" alt="Close"></span><table><tr ng-show="selectedCredential.label"><td>Label</td><td>{{selectedCredential.label}}</td></tr><tr ng-show="selectedCredential.username"><td>Account</td><td><span credential-field value="selectedCredential.username"></span></td></tr><tr ng-show="selectedCredential.password"><td>Password</td><td><span credential-field value="selectedCredential.password" secret="\'true\'"></span></td></tr><tr ng-show="selectedCredential.otp.secret"><td>OTP</td><td><span otp-generator secret="selectedCredential.otp.secret"></span></td></tr><tr ng-show="selectedCredential.email"><td>E-mail</td><td><span credential-field value="selectedCredential.email"></span></td></tr><tr ng-show="selectedCredential.url"><td>URL</td><td><span credential-field value="selectedCredential.url"></span></td></tr><tr ng-show="selectedCredential.files.length > 0"><td>Files</td><td><div ng-repeat="file in selectedCredential.files" class="link" ng-click="downloadFile(file)">{{file.filename}} ({{file.size | bytes}})</div></td></tr><tr ng-repeat="field in selectedCredential.custom_fields"><td>{{field.label}}</td><td><span credential-field value="field.value" secret="field.secret"></span></td></tr><tr ng-show="selectedCredential.changed"><td>Changed</td><td>{{selectedCredential.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr><tr ng-show="selectedCredential.created"><td>Created</td><td>{{selectedCredential.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr></table><div class="tags"><span class="tag" ng-repeat="tag in selectedCredential.tags">{{tag.text}}</span></div><div ng-show="selectedCredential"><span class="button" ng-click="editCredential(selectedCredential)" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-edit"></span> Edit</span> <span class="button" ng-click="deleteCredential(selectedCredential)" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-trash"></span> Delete</span> <span class="button" ng-if="selectedCredential.delete_time > 0" ng-click="recoverCredential(selectedCredential)"><span class="fa fa-recycle"></span> Recover</span> <span class="button" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-share"></span> Share</span></div></div></div>');
'<div id="controls"><div class="breadcrumb"></div><div class="actions creatable"><span ng-click="menuOpen = !menuOpen" class="button new" ng-init="menuOpen = false" off-click="menuOpen = false;"><span>New</span></span><div class="actionList popovermenu bubble menu" ng-show="menuOpen"><ul><li><span ng-click="addCredential()" class="menuitem action"><span class="icon icon-rename"></span> <span>New credential</span></span></li><li><span href="#" class="menuitem action"><span class="icon icon-shared"></span> <span>New shared credential</span></span></li></ul></div><input type="text" ng-model="itemFilter.label"> <span class="title" ng-if="delete_time">Showing deleted since: <span ng-if="delete_time == 1">All time</span> <span ng-if="delete_time > 1">{{delete_time | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</span></span></div></div><div off-click="closeSelected()"><table class="credential-table" ng-init="menuOpen = false;"><tr ng-repeat="credential in credentials | filter:itemFilter | tagFilter:selectedtags | as:this:\'filtered_credentials\'" ng-if="credential.hidden == 0 && showCredentialRow(credential)" ng-click="selectCredential(credential)" ng-class="{\'selected\': selectedCredential.credential_id == credential.credential_id}"><td><span class="label">{{credential.label}}</span> <span class="tags"><span class="tag" ng-repeat="tag in credential.tags_raw">{{tag.text}}</span></span></td></tr></table><div id="app-sidebar" class="detailsView scroll-container app_sidebar" ng-show="selectedCredential"><span class="close icon-close" ng-click="closeSelected()" alt="Close"></span><table><tr ng-show="selectedCredential.label"><td>Label</td><td>{{selectedCredential.label}}</td></tr><tr ng-show="selectedCredential.username"><td>Account</td><td><span credential-field value="selectedCredential.username"></span></td></tr><tr ng-show="selectedCredential.password"><td>Password</td><td><span credential-field value="selectedCredential.password" secret="\'true\'"></span></td></tr><tr ng-show="selectedCredential.otp.secret"><td>OTP</td><td><span otp-generator secret="selectedCredential.otp.secret"></span></td></tr><tr ng-show="selectedCredential.email"><td>E-mail</td><td><span credential-field value="selectedCredential.email"></span></td></tr><tr ng-show="selectedCredential.url"><td>URL</td><td><span credential-field value="selectedCredential.url"></span></td></tr><tr ng-show="selectedCredential.files.length > 0"><td>Files</td><td><div ng-repeat="file in selectedCredential.files" class="link" ng-click="downloadFile(file)">{{file.filename}} ({{file.size | bytes}})</div></td></tr><tr ng-repeat="field in selectedCredential.custom_fields"><td>{{field.label}}</td><td><span credential-field value="field.value" secret="field.secret"></span></td></tr><tr ng-show="selectedCredential.changed"><td>Changed</td><td>{{selectedCredential.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr><tr ng-show="selectedCredential.created"><td>Created</td><td>{{selectedCredential.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr></table><div class="tags"><span class="tag" ng-repeat="tag in selectedCredential.tags">{{tag.text}}</span></div><div ng-show="selectedCredential"><span class="button" ng-click="editCredential(selectedCredential)" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-edit"></span> Edit</span> <span class="button" ng-click="deleteCredential(selectedCredential)" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-trash"></span> Delete</span> <span class="button" ng-if="selectedCredential.delete_time > 0" ng-click="recoverCredential(selectedCredential)"><span class="fa fa-recycle"></span> Recover</span> <span class="button" ng-if="selectedCredential.delete_time == 0"><span class="fa fa-share"></span> Share</span></div></div></div>');
}]);
angular.module('views/vaults.html', []).run(['$templateCache', function($templateCache) {

View file

@ -25,4 +25,3 @@ var time_estimates;time_estimates={estimate_attack_times:function(e){var t,n,s,o
},{}]},{},[4])(4)
});
//# sourceMappingURL=zxcvbn.js.map

View file

@ -33,6 +33,7 @@ script('passman', 'app/filters/range');
script('passman', 'app/filters/propsfilter');
script('passman', 'app/filters/byte');
script('passman', 'app/filters/tagfilter');
script('passman', 'app/filters/as');
script('passman', 'app/services/cacheservice');
script('passman', 'app/services/vaultservice');
script('passman', 'app/services/credentialservice');

View file

@ -40,7 +40,7 @@
</div>
<div off-click="closeSelected()">
<table class="credential-table" ng-init="menuOpen = false;">
<tr ng-repeat="credential in credentials | filter:itemFilter | tagFilter:selectedtags"
<tr ng-repeat="credential in credentials | filter:itemFilter | tagFilter:selectedtags | as:this:'filtered_credentials'"
ng-if="credential.hidden == 0 && showCredentialRow(credential)"
ng-click="selectCredential(credential)"
ng-class="{'selected': selectedCredential.credential_id == credential.credential_id}">