backup a wallet during creation. View wallet/profile backup in plain text for safari

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-21 15:11:04 -03:00 committed by Matias Alejo Garcia
commit 93907dbfd1
5 changed files with 29 additions and 4 deletions

View file

@ -21,11 +21,11 @@ angular.module('copayApp.controllers').controller('CopayersController',
};
$scope.downloadBackup = function(w) {
backupService.download(w);
backupService.walletDownload(w);
};
$scope.viewBackup = function(w) {
$scope.backupPlainText = backupService.getBackup(w);
$scope.backupPlainText = backupService.walletEncrypted(w);
$scope.hideViewBackup = true;
};

View file

@ -1,7 +1,13 @@
'use strict';
angular.module('copayApp.controllers').controller('ManageController', function($scope, $rootScope, $location, controllerUtils, backupService) {
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$scope.downloadBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewBackup = function() {
$scope.backupPlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewBackup = true;
};
});

View file

@ -79,7 +79,7 @@ angular.module('copayApp.controllers').controller('MoreController',
}
$scope.viewBackup = function() {
$scope.backupPlainText = backupService.getBackup(w);
$scope.backupPlainText = backupService.walletEncrypted(w);
$scope.hideViewBackup = true;
};

View file

@ -39,6 +39,9 @@ BackupService.prototype._download = function(ew, walletName, filename) {
saveAs(blob, filename);
};
BackupService.prototype.walletEncrypted = function(wallet) {
return wallet.toEncryptedObj();
}
BackupService.prototype.walletDownload = function(wallet) {
var ew = wallet.toEncryptedObj();
@ -48,6 +51,10 @@ BackupService.prototype.walletDownload = function(wallet) {
this._download(ew, walletName, filename)
};
BackupService.prototype.profileEncrypted = function(iden) {
return iden.toEncryptedObj();
}
BackupService.prototype.profileDownload = function(iden) {
var ew = iden.toEncryptedObj();
var name = iden.profile.getName();

View file

@ -4,7 +4,19 @@
<h3><i class="fi-download m10r"></i> <span translate>Manage Wallets</span> </h3>
<p translate class="large-8 columns text-gray">It's important to backup your profile so that you can recover it in case of disaster. The backup will include all your profile's wallets</p>
<div class="large-4 columns">
<a translate class="button primary expand" ng-click="downloadBackup()">Backup profile</a>
<a translate class="button primary m0" ng-click="downloadBackup()"
ng-show="!isSafari">Backup profile</a>
<a translate class="button primary m0" ng-click="viewBackup()"
ng-show="isSafari && !hideViewBackup">View profile backup</a>
</div>
<div ng-show="backupPlainText">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<div class="show-for-large-up">
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
</div>
<div class="hide-for-large-up">
<span translate class="size-12">Copy this text as it is in a safe place (notepad or email)</span>
</div>
</div>
</div>
<div class="large-12 columns line-dashed-h m15b"></div>