From abf38e396ec11a93025788b9a7dfbdeff02fdffc Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 14 Oct 2017 17:49:29 -0400 Subject: [PATCH] add cipher page additions --- src/_locales/en/messages.json | 15 +++ .../app/vault/vaultAddCipherController.js | 37 ++++-- src/popup/app/vault/views/vaultAddCipher.html | 114 ++++++++++++++---- 3 files changed, 131 insertions(+), 35 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index ed722ddf..dffbb062 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -786,5 +786,20 @@ }, "disableFaviconDesc": { "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" } } diff --git a/src/popup/app/vault/vaultAddCipherController.js b/src/popup/app/vault/vaultAddCipherController.js index 32fc95fb..37ceec89 100644 --- a/src/popup/app/vault/vaultAddCipherController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -2,24 +2,33 @@ .module('bit.vault') .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.constants = constantsService; $scope.addFieldType = constantsService.fieldType.text.toString(); + $scope.selectedType = constantsService.cipherType.login.toString(); var from = $stateParams.from, folderId = $stateParams.folderId; $scope.cipher = { folderId: folderId, 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) { 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(); } else { @@ -27,24 +36,28 @@ } utilsService.initListSectionItemListeners($(document), angular); - $q.when(folderService.getAllDecrypted()).then(function (folders) { + folderService.getAllDecrypted().then(function (folders) { $scope.folders = folders; }); + $scope.typeChanged = function() { + $scope.cipher.type = parseInt($scope.selectedType); + }; + $scope.savePromise = null; - $scope.save = function (model) { - if (!model.name) { + $scope.save = function () { + if (!cipher.name || cipher.name === '') { toastr.error(i18nService.nameRequired, i18nService.errorsOccurred); return; } - $scope.savePromise = loginService.encrypt(model).then(function (cipherModel) { + $scope.savePromise = loginService.encrypt($scope.cipher).then(function (cipherModel) { var cipher = new Cipher(cipherModel, true); - return loginService.saveWithServer(cipher).then(function (c) { - $analytics.eventTrack('Added Cipher'); - toastr.success(i18nService.addedLogin); - $scope.close(); - }); + return loginService.saveWithServer(cipher); + }).then(function (c) { + $analytics.eventTrack('Added Cipher'); + toastr.success(i18nService.addedLogin); + $scope.close(); }); }; diff --git a/src/popup/app/vault/views/vaultAddCipher.html b/src/popup/app/vault/views/vaultAddCipher.html index b2f3139e..7811d34b 100644 --- a/src/popup/app/vault/views/vaultAddCipher.html +++ b/src/popup/app/vault/views/vaultAddCipher.html @@ -1,4 +1,4 @@ -
+
{{i18n.cancel}} @@ -16,37 +16,106 @@ {{i18n.loginInformation}}
+
+ + +
- +
-
- - +
+
+ + +
+
+ + +
+
+ + +
+ + {{i18n.generatePassword}} + +
-
- - +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
-
- - +
+ +
+
+
- - {{i18n.generatePassword}} - -
-
- - +
+
+ + +
- @@ -54,7 +123,7 @@
- +
@@ -64,18 +133,17 @@
- +
-
{{i18n.customFields}}