1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

vault listing page fixes

This commit is contained in:
Kyle Spearrin
2017-10-13 23:11:42 -04:00
parent b5c70c4941
commit 5a1bf8299f
9 changed files with 71 additions and 54 deletions

View File

@@ -0,0 +1,18 @@
angular
.module('bit.components')
.component('actionButtonsComponent', {
bindings: {
uri: '<'
},
template: '',
controller: function (stateService) {
this.$onInit = (function () {
}).bind(this);
this.$onChanges = (function () {
}).bind(this);
}
});

View File

@@ -1,13 +1,14 @@
angular
.module('bit.components')
.component('icon', {
bindings: {
uri: '<'
},
bindings: {
uri: '<'
},
template: '<div class="icon" ng-if="$ctrl.enabled()"><img src="{{$ctrl.url}}"></div>',
controller: function(stateService) {
this.$onInit = (function() {
this.enabled = function() {
controller: function (stateService) {
this.$onInit = (function () {
this.enabled = function () {
return stateService.getState('faviconEnabled');
};
}).bind(this);

View File

@@ -51,11 +51,11 @@
});
promises.push(folderPromise);
var loginPromise = $q.when(loginService.getAllDecrypted());
loginPromise.then(function (logins) {
decLogins = logins;
var cipherPromise = loginService.getAllDecrypted();
cipherPromise.then(function (ciphers) {
decLogins = ciphers;
});
promises.push(loginPromise);
promises.push(cipherPromise);
$q.all(promises).then(function () {
$scope.loaded = true;

View File

@@ -39,17 +39,17 @@
promises.push(folderDeferred.promise);
}
var loginPromise = $q.when(loginService.getAllDecryptedForFolder($scope.folder.id));
loginPromise.then(function (logins) {
var cipherPromise = loginService.getAllDecryptedForFolder($scope.folder.id);
cipherPromise.then(function (ciphers) {
if (utilsService.isEdge()) {
// Edge is super slow at sorting
decLogins = logins;
decLogins = ciphers;
}
else {
decLogins = logins.sort(loginSort);
decLogins = ciphers.sort(cipherSort);
}
});
promises.push(loginPromise);
promises.push(cipherPromise);
$q.all(promises).then(function () {
$scope.loaded = true;
@@ -68,7 +68,7 @@
});
}
function loginSort(a, b) {
function cipherSort(a, b) {
if (!a.name) {
return -1;
}
@@ -85,19 +85,19 @@
return -1;
}
if (!a.username) {
if (!a.subTitle) {
return -1;
}
if (!b.username) {
if (!b.subTitle) {
return 1;
}
var aUsername = a.username.toLowerCase(),
bUsername = b.username.toLowerCase();
if (aUsername > bUsername) {
var aSubTitle = a.subTitle.toLowerCase(),
bSubTitle = b.subTitle.toLowerCase();
if (aSubTitle > bSubTitle) {
return 1;
}
if (aUsername < bUsername) {
if (aSubTitle < bSubTitle) {
return -1;
}
@@ -123,7 +123,7 @@
var matchedLogins = [];
for (var i = 0; i < decLogins.length; i++) {
if (searchLogin(decLogins[i])) {
if (searchCipher(decLogins[i])) {
matchedLogins.push(decLogins[i]);
}
}
@@ -149,15 +149,15 @@
$scope.loadMore();
}
function searchLogin(login) {
function searchCipher(cipher) {
var searchTerm = $scope.searchText.toLowerCase();
if (login.name && login.name.toLowerCase().indexOf(searchTerm) !== -1) {
if (cipher.name && cipher.name.toLowerCase().indexOf(searchTerm) !== -1) {
return true;
}
if (login.username && login.username.toLowerCase().indexOf(searchTerm) !== -1) {
if (cipher.subTitle && cipher.subTitle.toLowerCase().indexOf(searchTerm) !== -1) {
return true;
}
if (login.uri && login.uri.toLowerCase().indexOf(searchTerm) !== -1) {
if (cipher.login && cipher.login.uri && cipher.login.uri.toLowerCase().indexOf(searchTerm) !== -1) {
return true;
}

View File

@@ -40,7 +40,7 @@
<a href="#" stop-click ng-click="viewLogin(login)"
class="list-grouped-item condensed" title="{{i18n.edit}} {{login.name}}"
ng-repeat="login in vaultFolderLogins = (vaultLogins | filter: { folderId: folder.id }
| filter: searchLogins() | orderBy: ['name', 'username']) track by $index">
| filter: searchLogins() | orderBy: ['name', 'subTitle']) track by $index">
<span class="btn-list" stop-prop stop-click title="{{i18n.copyPassword}}" ngclipboard
ngclipboard-error="clipboardError(e)" ngclipboard-success="clipboardSuccess(e, i18n.password)"
data-clipboard-text="{{login.password}}" ng-class="{'disabled': !login.password}">
@@ -61,7 +61,7 @@
<i class="fa fa-share-alt text-muted" ng-if="login.organizationId" title="{{i18n.shared}}"></i>
<i class="fa fa-paperclip text-muted" ng-if="login.attachments" title="{{i18n.attachments}}"></i>
</span>
<span class="detail">{{login.username}}</span>
<span class="detail">{{login.subTitle}}</span>
</a>
</div>
</div>
@@ -72,7 +72,7 @@
<div class="list-section" style="padding-top: 0; padding-bottom: 0;">
<a href="#" stop-click ng-click="viewLogin(login)"
class="list-section-item condensed" title="{{i18n.edit}} {{login.name}}"
ng-repeat="login in searchResults = (vaultLogins | filter: searchLogins() | orderBy: ['name', 'username'])
ng-repeat="login in searchResults = (vaultLogins | filter: searchLogins() | orderBy: ['name', 'subTitle'])
track by $index">
<span class="btn-list" stop-prop stop-click title="{{i18n.copyPassword}}" ngclipboard
ngclipboard-error="clipboardError(e)" ngclipboard-success="clipboardSuccess(e, i18n.password)"
@@ -94,7 +94,7 @@
<i class="fa fa-share-alt text-muted" ng-if="login.organizationId" title="{{i18n.shared}}"></i>
<i class="fa fa-paperclip text-muted" ng-if="login.attachments" title="{{i18n.attachments}}"></i>
</span>
<span class="detail">{{login.username}}</span>
<span class="detail">{{login.subTitle}}</span>
</a>
</div>
</div>

View File

@@ -61,6 +61,7 @@
<script src="app/components/componentsModule.js"></script>
<script src="app/components/iconComponent.js"></script>
<script src="app/components/actionButtonsComponent.js"></script>
<script src="app/services/servicesModule.js"></script>
<script src="app/services/backgroundService.js"></script>