mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #277 from cmgustavo/feature/backup-form
Feature/backup form
This commit is contained in:
commit
ad836250f5
27
index.html
27
index.html
|
@ -182,7 +182,7 @@
|
||||||
<span ng-show="wallets.length">
|
<span ng-show="wallets.length">
|
||||||
<a href="#/setup">Create a new wallet</a> ·
|
<a href="#/setup">Create a new wallet</a> ·
|
||||||
</span>
|
</span>
|
||||||
<a ng-href="#import">Import from file</a>
|
<a ng-href="#import">Import a backup</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- End !loading -->
|
</div> <!-- End !loading -->
|
||||||
|
@ -191,14 +191,23 @@
|
||||||
|
|
||||||
<script type="text/ng-template" id="import.html">
|
<script type="text/ng-template" id="import.html">
|
||||||
<div ng-controller="ImportController">
|
<div ng-controller="ImportController">
|
||||||
<h3>{{title}}</h3>
|
<div class="large-6 large-centered medium-6 medium-centered columns" ng-init="choosefile=0; pastetext=0">
|
||||||
<div class="large-6 columns">
|
<h2>{{title}}</h2>
|
||||||
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus required>
|
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||||
<h6>Select a backup file</h6>
|
<fieldset>
|
||||||
<input type="file" class="form-control" placeholder="Select a backup file" ng-model="backupFile" ng-file-select>
|
<legend>Select which method want to use to restore</legend>
|
||||||
<h6>Or just paste the backup text here</h6>
|
<label for="backupFile" ng-click="choosefile=!choosefile" class="m10b"><i class="fi-upload"></i> Choose backup file from your computer</label>
|
||||||
<textarea class="form-control" ng-model="backupText"></textarea>
|
<input type="file" class="form-control" placeholder="Select a backup file" name="backupFile" ng-model="backupFile" ng-file-select ng-show="choosefile">
|
||||||
<button class="button primary expand radius" ng-click="import()">Import backup</button>
|
<label for="backupText" ng-click="pastetext=!pastetext" class="m10b"><i class="fi-paperclip"></i> Paste backup plain text code</label>
|
||||||
|
<textarea class="form-control" name="backupText" ng-model="backupText" rows="5" ng-show="pastetext"></textarea>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<label for="password">Password <small>Required</small></label>
|
||||||
|
<input type="password" class="form-control" placeholder="Your wallet password" name="password" ng-model="password" required>
|
||||||
|
<button type="submit" class="button primary radius" ng-disabled="importForm.$invalid" loading="Importing">
|
||||||
|
Import backup
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -21,13 +21,31 @@ angular.module('copay.import').controller('ImportController',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.import = function() {
|
$scope.import = function(form) {
|
||||||
if ($scope.password) {
|
if (form.$invalid) {
|
||||||
if ($scope.backupText) {
|
$rootScope.flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
|
||||||
_importBackup($scope.backupText);
|
return;
|
||||||
} else {
|
|
||||||
reader.readAsBinaryString($scope.file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var backupFile = $scope.file;
|
||||||
|
var backupText = form.backupText.$modelValue;
|
||||||
|
var password = form.password.$modelValue;
|
||||||
|
|
||||||
|
if (!backupFile && !backupText) {
|
||||||
|
$rootScope.flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
|
if (backupFile) {
|
||||||
|
reader.readAsBinaryString(backupFile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_importBackup(backupText);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.loading = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,6 +65,8 @@ WalletFactory.prototype.fromObj = function(obj) {
|
||||||
}
|
}
|
||||||
this.log('### WALLET OPENED:', w.id);
|
this.log('### WALLET OPENED:', w.id);
|
||||||
|
|
||||||
|
// store imported wallet
|
||||||
|
w.store();
|
||||||
return w;
|
return w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue