password generator from vault add/edit

This commit is contained in:
Kyle Spearrin 2016-09-19 22:24:55 -04:00
parent 6ef3ff9f4d
commit e5c58c12fe
8 changed files with 89 additions and 18 deletions

View File

@ -89,14 +89,14 @@
templateUrl: 'app/vault/views/vaultAddSite.html',
controller: 'vaultAddSiteController',
data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null, site: null }
params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null, site: null, fromCurrent: false }
})
.state('editSite', {
url: '/edit-site?siteId',
templateUrl: 'app/vault/views/vaultEditSite.html',
controller: 'vaultEditSiteController',
data: { authorize: true },
params: { animation: null, fromView: true, returnScrollY: 0, returnSearchText: null }
params: { animation: null, fromView: true, returnScrollY: 0, returnSearchText: null, site: null }
})
.state('passwordGenerator', {

View File

@ -5,6 +5,8 @@
var addState = $stateParams.addState,
editState = $stateParams.editState;
$scope.showSelect = $stateParams.addState || $stateParams.editState;
popupUtils.initListSectionItemListeners();
$scope.password = '-';
@ -61,16 +63,38 @@
};
$scope.close = function () {
dismiss();
};
$scope.select = function () {
if (addState) {
addState.site.password = $scope.password;
}
else if (editState) {
editState.site.password = $scope.password;
}
dismiss();
};
function dismiss() {
if (addState) {
$state.go('addSite', {
animation: 'out-slide-down',
site: addState
fromCurrent: addState.fromCurrent,
site: addState.site,
returnScrollY: addState.returnScrollY,
returnSearchText: addState.returnSearchText
});
}
else if (editState) {
$state.go('editSite', {
animation: 'out-slide-down',
siteId: editState
site: editState.site,
fromView: editState.fromView,
siteId: editState.siteId,
returnScrollY: editState.returnScrollY,
returnSearchText: editState.returnSearchText
});
}
else {
@ -78,5 +102,5 @@
animation: 'out-slide-down'
});
}
};
}
});

View File

@ -3,7 +3,7 @@
<a ng-click="close()" href="">Close</a>
</div>
<div class="right">
<a ng-click="select()" href="">Select</a>
<a ng-click="select()" ng-show="showSelect" href="">Select</a>
</div>
<div class="title">Generate Password</div>
</div>

View File

@ -4,7 +4,7 @@
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.uri !== null;
var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null;
$scope.site = {
folderId: null,
@ -12,7 +12,11 @@
uri: $stateParams.uri
};
if ($scope.site.name && $scope.site.uri) {
if ($stateParams.site) {
angular.extend($scope.site, $stateParams.site);
}
if (!$stateParams.site && $scope.site.name && $scope.site.uri) {
$('#username').focus();
}
else {
@ -52,4 +56,16 @@
});
}
};
$scope.generatePassword = function () {
$state.go('passwordGenerator', {
animation: 'in-slide-up',
addState: {
fromCurrent: fromCurrent,
site: $scope.site,
returnScrollY: returnScrollY,
returnSearchText: returnSearchText
}
});
};
});

View File

@ -4,16 +4,23 @@ angular
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var siteId = $stateParams.siteId;
var fromView = $stateParams.fromView;
$scope.site = {
folderId: null
};
siteService.get($stateParams.siteId, function (site) {
$q.when(site.decrypt()).then(function (model) {
$scope.site = model;
if ($stateParams.site) {
angular.extend($scope.site, $stateParams.site);
}
else {
siteService.get(siteId, function (site) {
$q.when(site.decrypt()).then(function (model) {
$scope.site = model;
});
});
});
}
$q.when(folderService.getAllDecrypted()).then(function (folders) {
$scope.folders = folders.concat([{
@ -36,9 +43,9 @@ angular
};
$scope.close = function () {
if ($stateParams.fromView) {
if (fromView) {
$state.go('viewSite', {
siteId: $stateParams.siteId,
siteId: siteId,
animation: 'out-slide-down',
returnScrollY: returnScrollY || 0,
returnSearchText: returnSearchText
@ -52,4 +59,21 @@ angular
});
}
};
$scope.generatePassword = function () {
if ($scope.site.password) {
// TODO: confirmation
}
$state.go('passwordGenerator', {
animation: 'in-slide-up',
editState: {
fromView: fromView,
siteId: siteId,
site: $scope.site,
returnScrollY: returnScrollY,
returnSearchText: returnSearchText
}
});
};
});

View File

@ -32,9 +32,9 @@
<label for="password" class="item-label">Password</label>
<input id="password" type="password" name="Password" ng-model="site.password" bit-field>
</div>
<a class="list-section-item" href="#">
<a class="list-section-item" href="" ng-click="generatePassword()">
Generate Password
<i class="fa fa-chevron-right pull-right"></i>
<i class="fa fa-chevron-right"></i>
</a>
</div>
</div>

View File

@ -32,9 +32,9 @@
<label for="password" class="item-label">Password</label>
<input id="password" type="password" name="Password" ng-model="site.password" bit-field>
</div>
<a class="list-section-item" href="#">
<a class="list-section-item" href="" ng-click="generatePassword()">
Generate Password
<i class="fa fa-chevron-right pull-right"></i>
<i class="fa fa-chevron-right"></i>
</a>
</div>
</div>

View File

@ -284,6 +284,12 @@
}
}
.fa-chevron-right {
float: right;
margin-top: 3px;
color: @gray-light;
}
&.condensed {
padding: 3px 10px;
@ -359,4 +365,5 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-family: @font-family-monospace;
}