1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-20 16:07:45 +01:00

add cipher page additions

This commit is contained in:
Kyle Spearrin 2017-10-14 17:49:29 -04:00
parent 0fc9f498df
commit abf38e396e
3 changed files with 131 additions and 35 deletions

View File

@ -786,5 +786,20 @@
}, },
"disableFaviconDesc": { "disableFaviconDesc": {
"message": "Website Icons, also known as \"Favicons\", provides an image next to the login vault." "message": "Website Icons, also known as \"Favicons\", provides an image next to the login vault."
},
"type": {
"message": "Type"
},
"typeLogin": {
"message": "Login"
},
"typeSecureNote": {
"message": "Secure Note"
},
"typeCard": {
"message": "Card"
},
"typeIdentity": {
"message": "Identity"
} }
} }

View File

@ -2,24 +2,33 @@
.module('bit.vault') .module('bit.vault')
.controller('vaultAddCipherController', function ($scope, $state, $stateParams, loginService, folderService, .controller('vaultAddCipherController', function ($scope, $state, $stateParams, loginService, folderService,
cryptoService, $q, toastr, utilsService, $analytics, i18nService, constantsService) { cryptoService, toastr, utilsService, $analytics, i18nService, constantsService) {
$scope.i18n = i18nService; $scope.i18n = i18nService;
$scope.constants = constantsService; $scope.constants = constantsService;
$scope.addFieldType = constantsService.fieldType.text.toString(); $scope.addFieldType = constantsService.fieldType.text.toString();
$scope.selectedType = constantsService.cipherType.login.toString();
var from = $stateParams.from, var from = $stateParams.from,
folderId = $stateParams.folderId; folderId = $stateParams.folderId;
$scope.cipher = { $scope.cipher = {
folderId: folderId, folderId: folderId,
name: $stateParams.name, name: $stateParams.name,
uri: $stateParams.uri type: constantsService.cipherType.login,
login: {},
secureNote: {
type: 0 // generic note
}
}; };
if($stateParams.uri) {
$scope.cipher.login.uri = $stateParams.uri;
}
if ($stateParams.cipher) { if ($stateParams.cipher) {
angular.extend($scope.cipher, $stateParams.cipher); angular.extend($scope.cipher, $stateParams.cipher);
} }
if (!$stateParams.cipher && $scope.cipher.name && $scope.cipher.uri) { if (!$stateParams.cipher && $scope.cipher.name && $scope.cipher.login && $scope.cipher.login.uri) {
$('#username').focus(); $('#username').focus();
} }
else { else {
@ -27,24 +36,28 @@
} }
utilsService.initListSectionItemListeners($(document), angular); utilsService.initListSectionItemListeners($(document), angular);
$q.when(folderService.getAllDecrypted()).then(function (folders) { folderService.getAllDecrypted().then(function (folders) {
$scope.folders = folders; $scope.folders = folders;
}); });
$scope.typeChanged = function() {
$scope.cipher.type = parseInt($scope.selectedType);
};
$scope.savePromise = null; $scope.savePromise = null;
$scope.save = function (model) { $scope.save = function () {
if (!model.name) { if (!cipher.name || cipher.name === '') {
toastr.error(i18nService.nameRequired, i18nService.errorsOccurred); toastr.error(i18nService.nameRequired, i18nService.errorsOccurred);
return; return;
} }
$scope.savePromise = loginService.encrypt(model).then(function (cipherModel) { $scope.savePromise = loginService.encrypt($scope.cipher).then(function (cipherModel) {
var cipher = new Cipher(cipherModel, true); var cipher = new Cipher(cipherModel, true);
return loginService.saveWithServer(cipher).then(function (c) { return loginService.saveWithServer(cipher);
$analytics.eventTrack('Added Cipher'); }).then(function (c) {
toastr.success(i18nService.addedLogin); $analytics.eventTrack('Added Cipher');
$scope.close(); toastr.success(i18nService.addedLogin);
}); $scope.close();
}); });
}; };

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="save(login)" bit-form="savePromise" autocomplete="off"> <form name="theForm" ng-submit="save()" bit-form="savePromise" autocomplete="off">
<div class="header"> <div class="header">
<div class="left"> <div class="left">
<a ng-click="close()" href="">{{i18n.cancel}}</a> <a ng-click="close()" href="">{{i18n.cancel}}</a>
@ -16,37 +16,106 @@
{{i18n.loginInformation}} {{i18n.loginInformation}}
</div> </div>
<div class="list-section-items"> <div class="list-section-items">
<div class="list-section-item">
<label for="type" class="item-label">{{i18n.type}}</label>
<select id="type" name="Type" ng-model="selectedType" ng-change="typeChanged()">
<option value="{{constants.cipherType.login}}">{{i18n.typeLogin}}</option>
<option value="{{constants.cipherType.secureNote}}">{{i18n.typeSecureNote}}</option>
<option value="{{constants.cipherType.card}}">{{i18n.typeCard}}</option>
<option value="{{constants.cipherType.identity}}">{{i18n.typeIdentity}}</option>
</select>
</div>
<div class="list-section-item"> <div class="list-section-item">
<label for="name" class="item-label">{{i18n.name}}</label> <label for="name" class="item-label">{{i18n.name}}</label>
<input id="name" type="text" name="Name" ng-model="login.name"> <input id="name" type="text" name="Name" ng-model="cipher.name">
</div> </div>
<div class="list-section-item"> <div ng-if="cipher.type === constants.cipherType.login">
<label for="uri" class="item-label">{{i18n.uri}}</label> <div class="list-section-item">
<input id="uri" type="text" name="Uri" ng-model="login.uri"> <label for="loginUri" class="item-label">{{i18n.uri}}</label>
<input id="loginUri" type="text" name="Login.Uri" ng-model="cipher.login.uri">
</div>
<div class="list-section-item">
<label for="loginUsername" class="item-label">{{i18n.username}}</label>
<input id="loginUsername" type="text" name="Login.Username" ng-model="cipher.login.username">
</div>
<div class="list-section-item">
<label for="loginPassword" class="item-label">{{i18n.password}}</label>
<input id="loginPassword" type="password" name="Login.Password" ng-model="cipher.login.password">
</div>
<a class="list-section-item" href="" ng-click="generatePassword()">
{{i18n.generatePassword}}
<i class="fa fa-chevron-right"></i>
</a>
</div> </div>
<div class="list-section-item"> <div ng-if="cipher.type === constants.cipherType.card">
<label for="username" class="item-label">{{i18n.username}}</label> <div class="list-section-item">
<input id="username" type="text" name="Username" ng-model="login.username"> <label for="cardCardholderName" class="item-label">{{i18n.cardholderName}}</label>
<input id="cardCardholderName" type="text" name="Card.CardholderName"
ng-model="cipher.card.cardholderName">
</div>
<div class="list-section-item">
<label for="cardNumber" class="item-label">{{i18n.number}}</label>
<input id="cardNumber" type="text" name="Card.Number" ng-model="cipher.card.number">
</div>
<div class="list-section-item">
<label for="cardBrand" class="item-label">{{i18n.brand}}</label>
<select id="cardBrand" name="Card.Brand" ng-model="cipher.card.brand">
<option value="{{i18n.visa}}">{{i18n.visa}}</option>
<option value="{{i18n.mastercard}}">{{i18n.mastercard}}</option>
<option value="{{i18n.amex}}">{{i18n.amex}}</option>
<option value="{{i18n.discover}}">{{i18n.discover}}</option>
<option value="{{i18n.dinersClub}}">{{i18n.dinersClub}}</option>
<option value="{{i18n.jcb}}">{{i18n.jcb}}</option>
<option value="{{i18n.maestro}}">{{i18n.maestro}}</option>
<option value="{{i18n.unionPay}}">{{i18n.unionPay}}</option>
<option value="{{i18n.other}}">{{i18n.other}}</option>
</select>
</div>
<div class="list-section-item">
<label for="cardExpMonth" class="item-label">{{i18n.expMonth}}</label>
<select id="cardExpMonth" name="Card.ExpMonth" ng-model="cipher.card.expMonth">
<option value="1">01 - {{i18n.january}}</option>
<option value="2">02 - {{i18n.february}}</option>
<option value="3">03 - {{i18n.march}}</option>
<option value="4">04 - {{i18n.april}}</option>
<option value="5">05 - {{i18n.may}}</option>
<option value="6">06 - {{i18n.june}}</option>
<option value="7">07 - {{i18n.july}}</option>
<option value="8">08 - {{i18n.august}}</option>
<option value="9">09 - {{i18n.september}}</option>
<option value="10">10 - {{i18n.october}}</option>
<option value="11">11 - {{i18n.november}}</option>
<option value="12">12 - {{i18n.december}}</option>
</select>
</div>
<div class="list-section-item">
<label for="cardExpYear" class="item-label">{{i18n.expYear}}</label>
<input id="cardExpYear" type="text" name="Card.ExpYear" ng-model="cipher.card.expYear">
</div>
<div class="list-section-item">
<label for="cardCode" class="item-label">{{i18n.securityCode}}</label>
<input id="cardCode" type="text" name="Card.Code" ng-model="cipher.card.code">
</div>
</div> </div>
<div class="list-section-item"> <div ng-if="cipher.type === constants.cipherType.identity">
<label for="password" class="item-label">{{i18n.password}}</label>
<input id="password" type="password" name="Password" ng-model="login.password"> </div>
<div ng-if="cipher.type === constants.cipherType.secureNote">
</div> </div>
<a class="list-section-item" href="" ng-click="generatePassword()">
{{i18n.generatePassword}}
<i class="fa fa-chevron-right"></i>
</a>
</div> </div>
</div> </div>
<div class="list-section"> <div class="list-section">
<div class="list-section-items"> <div class="list-section-items">
<div class="list-section-item"> <div ng-if="cipher.type === constants.cipherType.login">
<label for="totp" class="item-label">{{i18n.authenticatorKeyTotp}}</label> <div class="list-section-item">
<input id="totp" type="text" name="Totp" ng-model="login.totp"> <label for="loginTotp" class="item-label">{{i18n.authenticatorKeyTotp}}</label>
<input id="loginTotp" type="text" name="Login.Totp" ng-model="cipher.login.totp">
</div>
</div> </div>
<div class="list-section-item"> <div class="list-section-item">
<label for="folder" class="item-label">{{i18n.folder}}</label> <label for="folder" class="item-label">{{i18n.folder}}</label>
<select id="folder" name="FolderId" ng-model="login.folderId"> <select id="folder" name="FolderId" ng-model="cipher.folderId">
<option ng-repeat="folder in folders | orderBy: ['name'] track by $index" value="{{folder.id}}"> <option ng-repeat="folder in folders | orderBy: ['name'] track by $index" value="{{folder.id}}">
{{folder.name}} {{folder.name}}
</option> </option>
@ -54,7 +123,7 @@
</div> </div>
<div class="list-section-item list-section-item-checkbox"> <div class="list-section-item list-section-item-checkbox">
<label for="favorite">{{i18n.favorite}}</label> <label for="favorite">{{i18n.favorite}}</label>
<input id="favorite" name="Favorite" type="checkbox" ng-model="login.favorite"> <input id="favorite" name="Favorite" type="checkbox" ng-model="cipher.favorite">
</div> </div>
</div> </div>
</div> </div>
@ -64,18 +133,17 @@
</div> </div>
<div class="list-section-items"> <div class="list-section-items">
<div class="list-section-item"> <div class="list-section-item">
<textarea id="notes" name="Notes" rows="5" ng-model="login.notes"></textarea> <textarea id="notes" name="Notes" rows="5" ng-model="cipher.notes"></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="list-section"> <div class="list-section">
<div class="list-section-header"> <div class="list-section-header">
{{i18n.customFields}} {{i18n.customFields}}
</div> </div>
<div class="list-section-items"> <div class="list-section-items">
<div class="list-section-item list-section-item-table" <div class="list-section-item list-section-item-table"
ng-if="login.fields && login.fields.length" ng-repeat="field in login.fields" ng-if="cipher.fields && cipher.fields.length" ng-repeat="field in cipher.fields"
ng-class="{'list-section-item-checkbox' : field.type === constants.fieldType.boolean}"> ng-class="{'list-section-item-checkbox' : field.type === constants.fieldType.boolean}">
<a href="#" stop-click ng-click="removeField(field)" class="action-button text-danger"> <a href="#" stop-click ng-click="removeField(field)" class="action-button text-danger">
<i class="fa fa-close fa-lg"></i> <i class="fa fa-close fa-lg"></i>