added import from backup text

This commit is contained in:
Mario Colque 2014-05-01 19:39:01 -03:00
parent 850d88e458
commit fc6a24c6b1
2 changed files with 4 additions and 6 deletions

View File

@ -187,7 +187,7 @@
<div ng-controller="ImportController">
<h3>{{title}}</h3>
<div class="large-6 columns">
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus>
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus required>
<h6>Select a backup file</h6>
<input type="file" class="form-control" placeholder="Select a backup file" ng-model="backupFile" ng-file-select>
<h6>Or just paste the backup text here</h6>

View File

@ -4,7 +4,7 @@ angular.module('copay.import').controller('ImportController',
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
$scope.title = 'Import a backup';
var reader = new FileReader();
var _importBackup = function(encryptedObj) {
var passphrase = Passphrase.getBase64($scope.password);
$rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
@ -12,8 +12,6 @@ angular.module('copay.import').controller('ImportController',
};
$scope.getFile = function() {
var reader = new FileReader();
// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
@ -24,8 +22,8 @@ angular.module('copay.import').controller('ImportController',
};
$scope.import = function() {
if ($scope.password != '') {
if ($scope.backupText != '') {
if ($scope.password) {
if ($scope.backupText) {
_importBackup($scope.backupText);
} else {
reader.readAsBinaryString($scope.file);