Merge pull request #319 from JDonadio/ref/password-and-advanced-options

Ref/password and advanced options
This commit is contained in:
Gustavo Maximiliano Cortez 2016-10-10 11:53:18 -03:00 committed by GitHub
commit 4f06b3f672
7 changed files with 147 additions and 78 deletions

View File

@ -37,9 +37,24 @@ angular.module('copayApp.controllers').controller('createController',
};
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
});
checkPasswordFields();
};
function checkPasswordFields() {
if (!$scope.encrypt) {
$scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = null;
$timeout(function() {
$scope.$apply();
});
}
};
function updateRCSelect(n) {
@ -160,7 +175,6 @@ angular.module('copayApp.controllers').controller('createController',
function _create(opts) {
ongoingProcess.set('creatingWallet', true);
$timeout(function() {
profileService.createWallet(opts, function(err, client) {
ongoingProcess.set('creatingWallet', false);
if (err) {
@ -173,11 +187,12 @@ angular.module('copayApp.controllers').controller('createController',
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
});
if ($scope.seedSource.id == 'set') {
profileService.setBackupFlag(client.credentials.walletId);
}
$ionicHistory.removeBackView();
if (!client.isComplete()) {
$ionicHistory.nextViewOptions({
disableAnimate: true
@ -188,8 +203,7 @@ angular.module('copayApp.controllers').controller('createController',
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
} else $state.go('tabs.home');
});
}, 100);
}

View File

@ -1,9 +1,20 @@
'use strict';
angular.module('copayApp.controllers').controller('exportController',
function($scope, $timeout, $log, $ionicHistory, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
});
};
var init = function() {
$scope.formData = {};
$scope.isEncrypted = wallet.isPrivKeyEncrypted();

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, $ionicHistory, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -12,6 +12,26 @@ angular.module('copayApp.controllers').controller('joinController',
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
});
checkPasswordFields();
};
function checkPasswordFields() {
if (!$scope.encrypt) {
$scope.passphrase = $scope.createPassphrase = $scope.passwordSaved = null;
$timeout(function() {
$scope.$apply();
});
}
};
this.onQrCodeScanned = function(data) {
$scope.secret = data;
@ -156,11 +176,10 @@ angular.module('copayApp.controllers').controller('joinController',
$state.transitionTo('tabs.copayers', {
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
});
} else $state.go('tabs.home');
});
}, 100);
});
};
updateSeedSourceSelect();

View File

@ -40,10 +40,12 @@
</div>
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<div class="item item-divider"></div>
<a class="item" ng-click="showAdvChange()">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
</a>
<div ng-show="showAdv">
@ -69,23 +71,6 @@
<input type="number" id="account" ng-model="account" ignore-mouse-wheel>
</label>
<div class="card" ng-show="join.seedSourceId=='new' && createPassphrase">
<div class="item item-text-wrap">
<span translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</span>
</div>
</div>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId=='new'">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
name="createPassphrase"
ng-model="createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId=='set'">
<span class="input-label" translate>Wallet Recovery Phrase</span>
<input id="ext-master"
@ -96,8 +81,21 @@
ng-model="privateKey">
</label>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId=='set'">
<span class="input-label" translate>Password</span>
<ion-toggle ng-model="encrypt" toggle-class="toggle-positive" ng-change="resizeView()" ng-show="join.seedSourceId == 'new' || join.seedSourceId == 'set'">
<span translate>Encrypt with a Password</span>
</ion-toggle>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId == 'new' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
name="createPassphrase"
ng-model="createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId == 'set' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off"
@ -105,6 +103,14 @@
ng-model="passphrase">
</label>
<div class="text-center box-notification error" ng-show="(join.seedSourceId =='new' || join.seedSourceId =='set') && encrypt">
<strong translate>This password cannot be recovered. If the password is lost, funds can only be recovered with a valid backup.</strong>
</div>
<ion-checkbox ng-model="passwordSaved" class="checkbox-positive" ng-show="encrypt">
<span class="toggle-label" translate>I have written it down</span>
</ion-checkbox>
<label class="item item-input item-stacked-label" ng-show="join.seedSourceId == 'set'">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
@ -116,8 +122,9 @@
</div> <!-- advanced -->
</div> <!-- list -->
<button type="submit" class="button button-block button-positive" ng-disabled="joinForm.$invalid" translate>
Join
<button type="submit" class="button button-block button-positive"
ng-disabled="joinForm.$invalid || ((encrypt && !passwordSaved) || encrypt && ((join.seedSourceId == 'new' && !createPassphrase) || (join.seedSourceId == 'set' && !passphrase)))"
translate>Join
</button>
</form>
</ion-content>

View File

@ -18,10 +18,12 @@
ng-blur="formFocus(false)">
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()">
<div class="item item-divider"></div>
<a class="item" ng-click="showAdvChange()">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
</a>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
@ -41,20 +43,6 @@
<input type="number" ng-model="formData.account" ignore-mouse-wheel>
</label>
<div class="card" ng-show="seedSource.id == 'new' && createPassphrase">
<div class="item item-text-wrap" translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</div>
</div>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new'">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
ng-model="formData.createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Wallet Recovery Phrase</span>
<input placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}"
@ -63,14 +51,34 @@
ng-model="formData.privateKey">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Password</span>
<ion-toggle ng-model="encrypt" toggle-class="toggle-positive" ng-change="resizeView()" ng-show="seedSource.id == 'new' || seedSource.id == 'set'">
<span translate>Encrypt with a Password</span>
</ion-toggle>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
ng-model="formData.createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off"
ng-model="formData.passphrase">
</label>
<div class="text-center box-notification error" ng-show="(seedSource.id =='new' || seedSource.id =='set') && encrypt">
<strong translate>This password cannot be recovered. If the password is lost, funds can only be recovered with a valid backup.</strong>
</div>
<ion-checkbox ng-model="formData.passwordSaved" class="checkbox-positive" ng-show="encrypt">
<span class="toggle-label" translate>I have written it down</span>
</ion-checkbox>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
@ -90,7 +98,8 @@
</div> <!-- advanced -->
</div> <!-- list -->
<button type="submit" class="button button-block button-positive" ng-disabled="setupForm.$invalid">
<button type="submit" class="button button-block button-positive"
ng-disabled="setupForm.$invalid || ((encrypt && !formData.passwordSaved) || encrypt && ((seedSource.id == 'new' && !formData.createPassphrase) || (seedSource.id == 'set' && !formData.passphrase)))">
<span translate>Create new wallet</span>
</button>
</form>

View File

@ -48,10 +48,12 @@
</select>
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()">
<div class="item item-divider"></div>
<a class="item" ng-click="showAdvChange()">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
</a>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
@ -71,20 +73,6 @@
<input type="number" ng-model="formData.account" ignore-mouse-wheel>
</label>
<div class="card" ng-show="seedSource.id =='new' && formData.createPassphrase">
<div class="item item-text-wrap" translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</div>
</div>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new'">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
ng-model="formData.createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Wallet Recovery Phrase</span>
<input placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}"
@ -93,14 +81,34 @@
ng-model="formData.privateKey">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Password</span>
<ion-toggle ng-model="encrypt" toggle-class="toggle-positive" ng-change="resizeView()" ng-show="seedSource.id == 'new' || seedSource.id == 'set'">
<span translate>Encrypt with a Password</span>
</ion-toggle>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
ng-model="formData.createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set' && encrypt">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off"
ng-model="formData.passphrase">
</label>
<div class="text-center box-notification error" ng-show="(seedSource.id =='new' || seedSource.id =='set') && encrypt">
<strong translate>This password cannot be recovered. If the password is lost, funds can only be recovered with a valid backup.</strong>
</div>
<ion-checkbox ng-model="formData.passwordSaved" class="checkbox-positive" ng-show="encrypt">
<span class="toggle-label" translate>I have written it down</span>
</ion-checkbox>
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
@ -120,7 +128,8 @@
</div> <!-- advanced -->
</div> <!-- list -->
<button type="submit" class="button button-block button-positive" ng-disabled="setupForm.$invalid">
<button type="submit" class="button button-block button-positive"
ng-disabled="setupForm.$invalid || ((encrypt && !formData.passwordSaved) || encrypt && ((seedSource.id == 'new' && !formData.createPassphrase) || (seedSource.id == 'set' && !formData.passphrase)))">
<span translate>Create {{formData.requiredCopayers}}-of-{{formData.totalCopayers}} wallet</span>
</button>
</form>

View File

@ -18,13 +18,13 @@
</div>
</form>
<ion-toggle ng-show="canSign" ng-model="formData.showAdvanced" toggle-class="toggle-balanced">
<span translate ng-show="!formData.showAdvanced">Show advanced options</span>
<span translate ng-show="formData.showAdvanced">Hide advanced options</span>
</ion-toggle>
<div class="list card" ng-show="canSign">
<a class="item" ng-click="showAdvChange()">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</a>
<div class="card" ng-show="formData.showAdvanced">
<ion-checkbox ng-model="formData.noSignEnabled" class="checkbox-balanced" ng-change="noSignEnabledChange()">
<ion-checkbox ng-show="showAdv" ng-model="formData.noSignEnabled" class="checkbox-balanced" ng-change="noSignEnabledChange(); resizeView()">
<span class="toggle-label" translate>Do not include private key</span>
</ion-checkbox>
</div>