mirror of https://github.com/BTCPrivate/copay.git
Add email wallet backup using iframe
This commit is contained in:
parent
ddebfee8b1
commit
aa4af0a0e9
|
@ -139,7 +139,7 @@
|
|||
<div class="large-12 medium-12 small-12 columns">
|
||||
<div class="line-dashed">
|
||||
<a ng-click="dowloadBackup()"
|
||||
ng-show="!$root.wallet.publicKeyRing.isComplete()">Download seed backup</a>
|
||||
ng-show="!$root.wallet.publicKeyRing.isComplete()">Save seed backup</a>
|
||||
<button class="button primary radius right"
|
||||
ng-click="backup()"
|
||||
ng-show="!$root.wallet.publicKeyRing.isBackupReady()"
|
||||
|
@ -183,6 +183,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<iframe ng-src="{{mobileBackupURI}}" style="width: 0px; height: 0px; margin:0px; border: 0px"></iframe>
|
||||
<div id="footer" data-ng-controller="FooterController" ng-class="{'footer-home': !$root.wallet || !$root.wallet.isReady()}">
|
||||
<link rel="stylesheet" ng-href="{{theme}}">
|
||||
<div ng-show="!$root.wallet">
|
||||
|
@ -850,7 +851,7 @@
|
|||
<h4 class="large-12 columns"><i class="fi-download m10r"></i> Backup </h4>
|
||||
<p class="large-8 columns text-gray"> Its important to back up your wallet so that you can recover your wallet in case of disaster </p>
|
||||
<div class="large-4 columns">
|
||||
<a class="button radius secondary expand" ng-click="download()">Download File</a>
|
||||
<a class="button radius secondary expand" ng-click="download()">Save Backup</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-8 columns large-centered line-dashed-h"> </div>
|
||||
|
|
|
@ -33,6 +33,13 @@ var copayApp = window.copayApp = angular.module('copayApp', [
|
|||
'copayApp.directives',
|
||||
]);
|
||||
|
||||
copayApp.config(function($sceDelegateProvider) {
|
||||
$sceDelegateProvider.resourceUrlWhitelist([
|
||||
'self',
|
||||
'mailto:**'
|
||||
]);
|
||||
});
|
||||
|
||||
angular.module('copayApp.filters', []);
|
||||
angular.module('copayApp.services', []);
|
||||
angular.module('copayApp.controllers', []);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('BackupController',
|
||||
function($scope, $rootScope, $location, $window, $timeout, $modal, backupService, walletFactory, controllerUtils) {
|
||||
function($scope, $rootScope, backupService, walletFactory, controllerUtils) {
|
||||
$scope.download = function() {
|
||||
backupService.download($rootScope.wallet);
|
||||
backupService.download($rootScope.wallet, $rootScope);
|
||||
};
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
|
|
|
@ -90,12 +90,12 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
|||
$scope.backup = function() {
|
||||
var w = $rootScope.wallet;
|
||||
w.setBackupReady();
|
||||
backupService.download(w);
|
||||
backupService.download(w, $rootScope);
|
||||
};
|
||||
|
||||
$scope.dowloadBackup = function() {
|
||||
var w = $rootScope.wallet;
|
||||
backupService.download(w);
|
||||
backupService.download(w, $rootScope);
|
||||
}
|
||||
|
||||
$scope.getVideoURL = function(copayer) {
|
||||
|
|
|
@ -9,7 +9,7 @@ BackupService.prototype.getName = function(wallet) {
|
|||
return (wallet.name ? (wallet.name + '-') : '') + wallet.id;
|
||||
};
|
||||
|
||||
BackupService.prototype.download = function(wallet) {
|
||||
BackupService.prototype.download = function(wallet, scope) {
|
||||
var ew = wallet.toEncryptedObj();
|
||||
var partial = !wallet.publicKeyRing.isComplete();
|
||||
var walletName = this.getName(wallet) + (partial ? '-Partial' : '');
|
||||
|
@ -28,6 +28,17 @@ BackupService.prototype.download = function(wallet) {
|
|||
wallet: ew
|
||||
});
|
||||
}
|
||||
|
||||
// throw an email intent if we are in the mobile version
|
||||
if (window.xwalk && scope) {
|
||||
var name = wallet.name ? wallet.name + ' ' : '';
|
||||
var partial = partial ? 'Partial ' : '';
|
||||
var subject = 'Copay - ' + name + 'Wallet ' + partial + 'Backup';
|
||||
var body = 'This is the encrypted backup of the wallet ' + wallet.id + ':\n\n' + ew;
|
||||
scope.mobileBackupURI = encodeURI('mailto:?subject=' + subject + '&body=' + body);
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise lean on the browser implementation
|
||||
saveAs(blob, filename);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue