Merge pull request #197 from colkito/feature/import-backups

Feature/import backups
This commit is contained in:
Matias Alejo Garcia 2014-04-26 11:31:58 -03:00
commit d08d0aa875
6 changed files with 73 additions and 13 deletions

22
js/controllers/import.js Normal file
View file

@ -0,0 +1,22 @@
'use strict';
angular.module('copay.import').controller('ImportController',
function($scope, $rootScope, walletFactory, controllerUtils) {
$scope.title = 'Import a backup';
$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
var obj = JSON.parse(evt.target.result);
$rootScope.wallet = walletFactory.fromObj(obj);
controllerUtils.startNetwork($rootScope.wallet);
}
};
reader.readAsBinaryString($scope.file);
};
});