Add backup to list of wallets in "manage wallets". Support for safari.
This commit is contained in:
parent
4b8e18735d
commit
c5f810c069
6 changed files with 74 additions and 80 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('MoreController',
|
||||
function($scope, $rootScope, $location, $filter, backupService, controllerUtils, notification, rateService) {
|
||||
function($scope, $rootScope, $location, $filter, controllerUtils, notification, rateService) {
|
||||
controllerUtils.redirIfNotComplete();
|
||||
var w = $rootScope.wallet;
|
||||
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
||||
|
|
@ -76,26 +76,7 @@ angular.module('copayApp.controllers').controller('MoreController',
|
|||
});
|
||||
notification.success('Success', $filter('translate')('settings successfully updated'));
|
||||
controllerUtils.updateBalance();
|
||||
};
|
||||
|
||||
$scope.downloadBackup = function() {
|
||||
backupService.walletDownload(w);
|
||||
}
|
||||
|
||||
$scope.viewBackup = function() {
|
||||
$scope.backupPlainText = backupService.walletEncrypted(w);
|
||||
$scope.hideViewBackup = true;
|
||||
};
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
$scope.loading = true;
|
||||
controllerUtils.deleteWallet($scope, $rootScope.wallet, function() {
|
||||
$rootScope.wallet = null;
|
||||
var lastFocused = $rootScope.iden.getLastFocusedWallet();
|
||||
controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused);
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
$scope.purge = function(deleteAll) {
|
||||
var removed = w.purgeTxProposals(deleteAll);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, controllerUtils, backupService) {
|
||||
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, controllerUtils, backupService) {
|
||||
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
||||
|
||||
$rootScope.title = 'Profile';
|
||||
|
||||
$scope.downloadBackup = function() {
|
||||
$scope.downloadProfileBackup = function() {
|
||||
backupService.profileDownload($rootScope.iden);
|
||||
};
|
||||
|
||||
$scope.viewBackup = function() {
|
||||
$scope.backupPlainText = backupService.profileEncrypted($rootScope.iden);
|
||||
$scope.hideViewBackup = true;
|
||||
$scope.viewProfileBackup = function() {
|
||||
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
|
||||
$scope.hideViewProfileBackup = true;
|
||||
};
|
||||
|
||||
$scope.getWallets = function() {
|
||||
if (!$rootScope.iden) return;
|
||||
$scope.wallets = [];
|
||||
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
|
||||
_.each(wids, function(wid) {
|
||||
|
|
@ -29,8 +30,37 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
|||
if (!w) return;
|
||||
$scope.loading = w.id;
|
||||
controllerUtils.deleteWallet($scope, w, function() {
|
||||
if ($rootScope.wallet.id === w.id) {
|
||||
$rootScope.wallet = null;
|
||||
var lastFocused = $rootScope.iden.getLastFocusedWallet();
|
||||
controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused);
|
||||
}
|
||||
$scope.loading = false;
|
||||
$scope.getWallets();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.downloadWalletBackup = function(w) {
|
||||
if (!w) return;
|
||||
backupService.walletDownload(w);
|
||||
}
|
||||
|
||||
$scope.viewWalletBackup = function(w) {
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
||||
if (!w) return;
|
||||
$scope.backupWalletPlainText = backupService.walletEncrypted(w);
|
||||
$scope.hideViewWalletBackup = true;
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
|
||||
$modal.open({
|
||||
templateUrl: 'views/modals/backup-text.html',
|
||||
windowClass: 'tiny',
|
||||
controller: ModalInstanceCtrl
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
|||
};
|
||||
|
||||
$scope.getWallets = function() {
|
||||
if (!$rootScope.iden) return;
|
||||
$scope.wallets = [];
|
||||
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
|
||||
_.each(wids, function(wid) {
|
||||
|
|
|
|||
14
views/modals/backup-text.html
Normal file
14
views/modals/backup-text.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<div class="text-center">
|
||||
<h1>Copy backup in a safe place</h1>
|
||||
<div class="show-for-large-up">
|
||||
<textarea readonly rows="7">{{backupWalletPlainText}}</textarea>
|
||||
<span translate class="size-12">Copy to clipboard</span>
|
||||
<span class="btn-copy" clip-copy="backupWalletPlainText"> </span>
|
||||
</div>
|
||||
<div class="hide-for-large-up">
|
||||
<textarea rows="12">{{backupWalletPlainText}}</textarea>
|
||||
</div>
|
||||
<div translate class="m10t size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
|
||||
</div>
|
||||
|
||||
<a class="close-reveal-modal" ng-click="cancel()">×</a>
|
||||
|
|
@ -18,46 +18,6 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="line-dashed-h m20b"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<div class="panel">
|
||||
<h2><i class="fi-download m10r"></i> <span translate>Backup</span></h2>
|
||||
<p translate class="text-gray">
|
||||
It's important to backup your wallet so that you can recover it in case of disaster
|
||||
</p>
|
||||
<a translate class="button primary m0" ng-click="downloadBackup()"
|
||||
ng-show="!isSafari">Download File</a>
|
||||
<a translate class="button primary m0" ng-click="viewBackup()"
|
||||
ng-show="isSafari && !hideViewBackup">View Backup</a>
|
||||
<div ng-show="backupPlainText">
|
||||
<div class="show-for-large-up">
|
||||
<textarea readonly rows="5">{{backupPlainText}}</textarea>
|
||||
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
|
||||
</div>
|
||||
<div class="hide-for-large-up">
|
||||
<textarea rows="10">{{backupPlainText}}</textarea>
|
||||
</div>
|
||||
<div translate class="m10t size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<div class="panel">
|
||||
<h2><i class="fi-minus-circle m10r"></i> <span translate>Delete Wallet</span></h2>
|
||||
<p translate class="text-gray">If all funds have been removed from your wallet and you do not wish to have the wallet data stored on your computer anymore, you can delete your wallet.</p>
|
||||
<a class="button warning m0"
|
||||
ng-really-message="{{'Are you sure you want to delete this wallet?'|translate}}"
|
||||
ng-really-click="deleteWallet()"
|
||||
ng-class="{'disabled':loading}">
|
||||
<span ng-show="!loading">Delete</span>
|
||||
<span ng-show="loading">Deleting...</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="line-dashed-h m20b"></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@
|
|||
<div class="panel">
|
||||
<h2><i class="fi-download m10r"></i> <span translate>Backup Profile</span></h2>
|
||||
<p translate class="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>
|
||||
<a translate class="button primary m0" ng-click="downloadBackup()"
|
||||
<a translate class="button primary m0" ng-click="downloadProfileBackup()"
|
||||
ng-show="!isSafari">Backup profile</a>
|
||||
<a translate class="button primary m0" ng-click="viewBackup()"
|
||||
ng-show="isSafari && !hideViewBackup">View profile backup</a>
|
||||
<div ng-show="backupPlainText">
|
||||
<textarea rows="5">{{backupPlainText}}</textarea>
|
||||
<a translate class="button primary m0" ng-click="viewProfileBackup()"
|
||||
ng-show="isSafari && !hideViewProfileBackup">View profile backup</a>
|
||||
<div ng-show="backupProfilePlainText">
|
||||
<textarea rows="5">{{backupProfilePlainText}}</textarea>
|
||||
<div class="show-for-large-up">
|
||||
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
|
||||
<span translate class="size-12">Copy to clipboard</span> <span
|
||||
class="btn-copy" clip-copy="backupProfilePlainText"> </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>
|
||||
|
|
@ -41,8 +42,8 @@
|
|||
<tr
|
||||
data-ng-repeat="item in wallets | orderBy:'name'"
|
||||
ng-init="isReady = item.isReady();
|
||||
activeWallet = $root.wallet.id; networkName = item.getNetworkName()"
|
||||
ng-class="{'active':activeWallet == item.id, 'deleting':loading==item.id}">
|
||||
networkName = item.getNetworkName()"
|
||||
ng-class="{'deleting':loading==item.id}">
|
||||
<td>{{item.name || item.id }}</td>
|
||||
<td width="120">{{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}}</td>
|
||||
<td width="200">{{isReady ? 'Complete' : 'Waiting for copayers...'}}</td>
|
||||
|
|
@ -53,13 +54,20 @@
|
|||
</span>
|
||||
</td>
|
||||
<td width="70" class="text-center">
|
||||
<a translate
|
||||
class="warning"
|
||||
ng-really-message="{{'Are you sure you want to delete the wallet'}} {{(item.name || item.id)}}"
|
||||
ng-really-click="deleteWallet(item)"
|
||||
ng-show="activeWallet != item.id && loading != item.id">Delete</a>
|
||||
|
||||
<div ng-show="loading != item.id">
|
||||
<a title="Download Backup" ng-click="downloadWalletBackup(item)"
|
||||
ng-show="!isSafari"><i class="fi-download"></i></a>
|
||||
<a title="View Backup" ng-click="viewWalletBackup(item)"
|
||||
ng-show="isSafari"><i class="fi-eye"></i></a>
|
||||
|
||||
<a title="Delete Wallet"
|
||||
class="text-warning"
|
||||
ng-really-message="{{'Are you sure you want to delete the wallet'}} {{(item.name || item.id)}}"
|
||||
ng-really-click="deleteWallet(item)"
|
||||
ng-show="loading != item.id"><i class="fi-trash"></i></a>
|
||||
</div>
|
||||
<span ng-show="loading == item.id"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||
<span ng-show="activeWallet == item.id">Active</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue