1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01: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

@ -278,17 +278,13 @@ function buildDomainModel(model, obj, map, alreadyEncrypted, notEncList) {
}
(function () {
var bg = chrome.extension.getBackgroundPage(),
cryptoService = bg ? bg.bg_cryptoService : null;
CipherString.prototype.decrypt = function (orgId) {
if (this.decryptedValue) {
var deferred = Q.defer();
deferred.resolve(this.decryptedValue);
return deferred.promise;
return Q(this.decryptedValue);
}
var self = this;
var self = this,
cryptoService = chrome.extension.getBackgroundPage().bg_cryptoService;
return cryptoService.getOrgKey(orgId).then(function (orgKey) {
return cryptoService.decrypt(self, orgKey);
}).then(function (decValue) {
@ -416,15 +412,19 @@ function buildDomainModel(model, obj, map, alreadyEncrypted, notEncList) {
switch (self.type) {
case 1: // cipherType.login
model.login = decObj;
model.subTitle = model.login.username;
break;
case 2: // cipherType.secureNote
model.secureNote = decObj;
model.subTitle = '-';
break;
case 3: // cipherType.card
model.card = decObj;
model.subTitle = model.identity.brand;
break;
case 4: // cipherType.identity
model.identity = decObj;
model.subTitle = model.identity.firstName;
break;
default:
break;

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>

View File

@ -182,7 +182,7 @@ function initLoginService() {
key = null,
localData = null;
self.userService.getUserIdPromise().then(function (userId) {
return self.userService.getUserIdPromise().then(function (userId) {
key = 'ciphers_' + userId;
return self.utilsService.getObjFromStorage(self.localDataKey);
}).then(function (data) {
@ -191,11 +191,11 @@ function initLoginService() {
localData = {};
}
return self.utilsService.getObjFromStorage(key);
}).then(function (logins) {
}).then(function (ciphers) {
var response = [];
for (var id in logins) {
for (var id in ciphers) {
if (id) {
response.push(new Login(logins[id], false, localData[id]));
response.push(new Cipher(ciphers[id], false, localData[id]));
}
}
@ -205,7 +205,7 @@ function initLoginService() {
LoginService.prototype.getAllDecrypted = function () {
var self = this,
decLogins = [];
decCiphers = [];
return self.cryptoService.getKey().then(function (key) {
if (!key) {
@ -219,19 +219,19 @@ function initLoginService() {
}
return self.getAll();
}).then(function (logins) {
}).then(function (ciphers) {
var promises = [];
for (var i = 0; i < logins.length; i++) {
for (var i = 0; i < ciphers.length; i++) {
/* jshint ignore:start */
promises.push(logins[i].decrypt().then(function (login) {
decLogins.push(login);
promises.push(ciphers[i].decrypt().then(function (cipher) {
decCiphers.push(cipher);
}));
/* jshint ignore:end */
}
return Q.all(promises);
}).then(function () {
self.decryptedCipherCache = decLogins;
self.decryptedCipherCache = decCiphers;
return self.decryptedCipherCache;
});
};

View File

@ -139,14 +139,11 @@ function initSyncService() {
}
function syncCiphers(self, userId, response) {
var logins = {};
var ciphers = {};
for (var i = 0; i < response.length; i++) {
var data = response[i];
if (data.type === 1) {
logins[data.id] = new LoginData(data, userId);
}
ciphers[response[i].id] = new CipherData(response[i], userId);
}
return self.loginService.replace(logins);
return self.loginService.replace(ciphers);
}
function syncSettings(self, userId, response) {