Move wallet-info to settings. Fix removing last wallet
This commit is contained in:
parent
c0f59adced
commit
5b1463af60
8 changed files with 171 additions and 204 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('CopayersController',
|
angular.module('copayApp.controllers').controller('CopayersController',
|
||||||
function($scope, $rootScope, $timeout, go) {
|
function($scope, $rootScope, $timeout, go, identityService, notification) {
|
||||||
|
var w = $rootScope.wallet;
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
var w = $rootScope.wallet;
|
|
||||||
$rootScope.title = 'Share this secret with your copayers';
|
$rootScope.title = 'Share this secret with your copayers';
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.secret = $rootScope.wallet.getSecret();
|
$scope.secret = $rootScope.wallet.getSecret();
|
||||||
|
|
@ -27,4 +27,25 @@ angular.module('copayApp.controllers').controller('CopayersController',
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.deleteWallet = function() {
|
||||||
|
$scope.loading = true;
|
||||||
|
identityService.deleteWallet(w, function(err) {
|
||||||
|
if (err) {
|
||||||
|
$scope.loading = null;
|
||||||
|
$scope.error = err.message || err;
|
||||||
|
copay.logger.warn(err);
|
||||||
|
$timeout(function () { $scope.$digest(); });
|
||||||
|
} else {
|
||||||
|
$scope.loading = false;
|
||||||
|
if ($rootScope.wallet) {
|
||||||
|
go.walletHome();
|
||||||
|
}
|
||||||
|
$timeout(function() {
|
||||||
|
notification.success('Success', 'The wallet "' + (w.name || w.id) + '" was deleted');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('MoreController',
|
angular.module('copayApp.controllers').controller('MoreController',
|
||||||
function($scope, $rootScope, $location, $filter, balanceService, notification, rateService) {
|
function($scope, $rootScope, $location, $filter, $timeout, balanceService, notification, rateService, backupService, identityService, isMobile, isCordova, go) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
var max = $rootScope.quotaPerItem;
|
||||||
|
$scope.isSafari = isMobile.Safari();
|
||||||
|
$scope.isCordova = isCordova;
|
||||||
|
$scope.wallet = w;
|
||||||
|
$scope.error = null;
|
||||||
|
$scope.success = null;
|
||||||
|
|
||||||
|
var bits = w.sizes().total;
|
||||||
|
w.kb = $filter('noFractionNumber')(bits / 1000, 1);
|
||||||
|
if (max) {
|
||||||
|
w.usage = $filter('noFractionNumber')(bits / max * 100, 0);
|
||||||
|
}
|
||||||
|
|
||||||
$rootScope.title = 'Settings';
|
$rootScope.title = 'Settings';
|
||||||
|
|
||||||
|
|
@ -105,4 +116,34 @@ angular.module('copayApp.controllers').controller('MoreController',
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.deleteWallet = function() {
|
||||||
|
$scope.loading = true;
|
||||||
|
identityService.deleteWallet(w, function(err) {
|
||||||
|
if (err) {
|
||||||
|
$scope.loading = null;
|
||||||
|
$scope.error = err.message || err;
|
||||||
|
copay.logger.warn(err);
|
||||||
|
$timeout(function () { $scope.$digest(); });
|
||||||
|
} else {
|
||||||
|
$scope.loading = false;
|
||||||
|
if ($rootScope.wallet) {
|
||||||
|
go.walletHome();
|
||||||
|
}
|
||||||
|
$timeout(function() {
|
||||||
|
notification.success('Success', 'The wallet "' + (w.name || w.id) + '" was deleted');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.downloadWalletBackup = function() {
|
||||||
|
backupService.walletDownload(w);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.viewWalletBackup = function() {
|
||||||
|
$scope.backupWalletPlainText = backupService.walletEncrypted(w);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,25 +25,6 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
||||||
// no need to add event handlers here. Wallet deletion is handle by callback.
|
// no need to add event handlers here. Wallet deletion is handle by callback.
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setWallets = function() {
|
|
||||||
if (!$rootScope.iden) return;
|
|
||||||
|
|
||||||
var wallets = $rootScope.iden.getWallets();
|
|
||||||
var max = $rootScope.quotaPerItem;
|
|
||||||
|
|
||||||
_.each(wallets, function(w) {
|
|
||||||
var bits = w.sizes().total;
|
|
||||||
w.kb = $filter('noFractionNumber')(bits / 1000, 1);
|
|
||||||
if (max) {
|
|
||||||
w.usage = $filter('noFractionNumber')(bits / max * 100, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$scope.wallets = wallets;
|
|
||||||
$timeout(function(){
|
|
||||||
$scope.$digest();
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.deleteProfile = function() {
|
$scope.deleteProfile = function() {
|
||||||
identityService.deleteProfile(function(err, res) {
|
identityService.deleteProfile(function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -57,54 +38,4 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showWalletInfo = function(w) {
|
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
|
||||||
if (!w) return;
|
|
||||||
$scope.isSafari = isMobile.Safari();
|
|
||||||
$scope.isCordova = isCordova;
|
|
||||||
$scope.item = w;
|
|
||||||
$scope.error = null;
|
|
||||||
$scope.success = null;
|
|
||||||
|
|
||||||
$scope.deleteWallet = function() {
|
|
||||||
|
|
||||||
$scope.loading = true;
|
|
||||||
identityService.deleteWallet($scope.item, function(err) {
|
|
||||||
if (err) {
|
|
||||||
$scope.loading = null;
|
|
||||||
$scope.error = err.message || err;
|
|
||||||
copay.logger.warn(err);
|
|
||||||
$timeout(function () { $scope.$digest(); });
|
|
||||||
} else {
|
|
||||||
$modalInstance.close($scope.item.name || $scope.item.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.downloadWalletBackup = function() {
|
|
||||||
backupService.walletDownload($scope.item);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.viewWalletBackup = function() {
|
|
||||||
$scope.backupWalletPlainText = backupService.walletEncrypted($scope.item);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.close = function() {
|
|
||||||
$modalInstance.dismiss('cancel');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var modalInstance = $modal.open({
|
|
||||||
templateUrl: 'views/modals/wallet-info.html',
|
|
||||||
windowClass: 'medium',
|
|
||||||
controller: ModalInstanceCtrl
|
|
||||||
});
|
|
||||||
|
|
||||||
modalInstance.result.then(function(walletName) {
|
|
||||||
$scope.loading = false;
|
|
||||||
$scope.success = 'The wallet "' + walletName + '" was deleted';
|
|
||||||
$scope.setWallets();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,9 @@ Identity.prototype.deleteWallet = function(walletId, cb) {
|
||||||
self.storage.removeItem(Wallet.getStorageKey(walletId), function(err) {
|
self.storage.removeItem(Wallet.getStorageKey(walletId), function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
self.emitAndKeepAlive('walletDeleted', walletId);
|
self.emitAndKeepAlive('walletDeleted', walletId);
|
||||||
|
if (!self.walletIds.length) {
|
||||||
|
self.emitAndKeepAlive('noWallets')
|
||||||
|
}
|
||||||
self.store({
|
self.store({
|
||||||
noWallets: true
|
noWallets: true
|
||||||
}, cb);
|
}, cb);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,32 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- end of row -->
|
<!-- end of row -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-12 columns size-12">
|
||||||
|
<button class="warning" ng-show="!confirmDelete" ng-click="confirmDelete=!confirmDelete">
|
||||||
|
<i class="fi-trash"></i> Cancel
|
||||||
|
</button>
|
||||||
|
<div ng-show="confirmDelete">
|
||||||
|
<h2>Are you sure you want to cancel and delete this wallet</h2>
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-6 medium-6 small-6 columns">
|
||||||
|
<button class="gray" ng-disabled="loading"
|
||||||
|
ng-click="confirmDelete=!confirmDelete">No</button>
|
||||||
|
</div>
|
||||||
|
<div class="large-6 medium-6 small-6 columns">
|
||||||
|
<button class="warning" ng-disabled="loading" ng-click="deleteWallet()">
|
||||||
|
<span ng-show="!loading">
|
||||||
|
<i class="fi-trash"></i> Yes
|
||||||
|
</span>
|
||||||
|
<span ng-show="loading">
|
||||||
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i> Deleting...
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="extra-margin-bottom"></div>
|
<div class="extra-margin-bottom"></div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
<div class="text-center" ng-init="isComplete = item.isComplete(); networkName = item.getNetworkName()">
|
|
||||||
<div ng-show="!confirmDelete">
|
|
||||||
<h1>{{item.name || item.id }}</h1>
|
|
||||||
<h3>
|
|
||||||
{{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}}
|
|
||||||
, {{isComplete ? 'Complete' : 'Waiting for copayers...'}}
|
|
||||||
</h3>
|
|
||||||
<div class="m10b" ng-if="isComplete">
|
|
||||||
<b>{{item.balanceInfo.totalBalance || 0}} {{item.settings.unitName}}</b>
|
|
||||||
</div>
|
|
||||||
<div class="m20b">
|
|
||||||
Approximate size: {{item.kb}} kB
|
|
||||||
<span ng-if="item.usage">({{item.usage}}%) </span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="box-notification" ng-show="error">
|
|
||||||
<div class="box-icon error">
|
|
||||||
<i class="fi-x size-24"></i>
|
|
||||||
</div>
|
|
||||||
<span class="text-warning size-14">
|
|
||||||
{{error|translate}}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row" ng-show="!backupWalletPlainText && !error">
|
|
||||||
<div class="large-6 medium-6 small-12 columns">
|
|
||||||
<button class="primary expand" ng-click="downloadWalletBackup()" ng-disabled="loading"
|
|
||||||
ng-show="!isSafari && !isCordova"><i class="fi-download"></i> Download backup</button>
|
|
||||||
<button class="primary expand" ng-click="viewWalletBackup()" ng-disabled="loading"
|
|
||||||
ng-show="isSafari || isCordova"><i class="fi-eye"></i> View Backup</button>
|
|
||||||
</div>
|
|
||||||
<div class="large-6 medium-6 small-12 columns">
|
|
||||||
<button class="warning expand" ng-click="confirmDelete=!confirmDelete">
|
|
||||||
<i class="fi-trash"></i> Delete
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-show="backupWalletPlainText">
|
|
||||||
<h3>Copy backup in a safe place</h3>
|
|
||||||
<div class="input">
|
|
||||||
<textarea class="show-for-large-up" readonly rows="7">{{backupWalletPlainText}}</textarea>
|
|
||||||
<textarea class="hide-for-large-up" rows="12">{{backupWalletPlainText}}</textarea>
|
|
||||||
<i class="icon-compose"></i>
|
|
||||||
</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="close()"><i class="fi-x size-18"></i></a>
|
|
||||||
</div>
|
|
||||||
<div class="row" ng-show="confirmDelete">
|
|
||||||
<h1>Are you sure you want to delete the wallet
|
|
||||||
<strong>{{(item.name || item.id)}}</strong>
|
|
||||||
</h1>
|
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
|
||||||
<button class="gray" ng-disabled="loading"
|
|
||||||
ng-click="confirmDelete=!confirmDelete">Cancel</button>
|
|
||||||
</div>
|
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
|
||||||
<button class="warning" ng-disabled="loading" ng-click="deleteWallet()">
|
|
||||||
<span ng-show="!loading">
|
|
||||||
<i class="fi-trash"></i> Delete
|
|
||||||
</span>
|
|
||||||
<span ng-show="loading">
|
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i> Deleting...
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -22,6 +22,77 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div class="text-center" ng-init="isComplete = wallet.isComplete(); networkName = wallet.getNetworkName()">
|
||||||
|
<div ng-show="!confirmDelete">
|
||||||
|
<h1>{{wallet.name || wallet.id }}</h1>
|
||||||
|
<h3>
|
||||||
|
{{wallet.requiredCopayers}} of {{wallet.totalCopayers}} - {{networkName}}
|
||||||
|
, {{isComplete ? 'Complete' : 'Waiting for copayers...'}}
|
||||||
|
</h3>
|
||||||
|
<div class="m10b" ng-if="isComplete">
|
||||||
|
<b>{{wallet.balanceInfo.totalBalance || 0}} {{wallet.settings.unitName}}</b>
|
||||||
|
</div>
|
||||||
|
<div class="m20b">
|
||||||
|
Approximate size: {{wallet.kb}} kB
|
||||||
|
<span ng-if="wallet.usage">({{wallet.usage}}%) </span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box-notification" ng-show="error">
|
||||||
|
<div class="box-icon error">
|
||||||
|
<i class="fi-x size-24"></i>
|
||||||
|
</div>
|
||||||
|
<span class="text-warning size-14">
|
||||||
|
{{error|translate}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" ng-show="!backupWalletPlainText && !error">
|
||||||
|
<div class="large-6 medium-6 small-12 columns">
|
||||||
|
<button class="primary expand" ng-click="downloadWalletBackup()" ng-disabled="loading"
|
||||||
|
ng-show="!isSafari && !isCordova"><i class="fi-download"></i> Download backup</button>
|
||||||
|
<button class="primary expand" ng-click="viewWalletBackup()" ng-disabled="loading"
|
||||||
|
ng-show="isSafari || isCordova"><i class="fi-eye"></i> View Backup</button>
|
||||||
|
</div>
|
||||||
|
<div class="large-6 medium-6 small-12 columns">
|
||||||
|
<button class="warning expand" ng-click="confirmDelete=!confirmDelete">
|
||||||
|
<i class="fi-trash"></i> Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="backupWalletPlainText">
|
||||||
|
<h3>Copy backup in a safe place</h3>
|
||||||
|
<div class="input">
|
||||||
|
<textarea class="show-for-large-up" readonly rows="7">{{backupWalletPlainText}}</textarea>
|
||||||
|
<textarea class="hide-for-large-up" rows="12">{{backupWalletPlainText}}</textarea>
|
||||||
|
<i class="icon-compose"></i>
|
||||||
|
</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 class="row" ng-show="confirmDelete">
|
||||||
|
<h1>Are you sure you want to delete the wallet
|
||||||
|
<strong>{{(wallet.name || wallet.id)}}</strong>
|
||||||
|
</h1>
|
||||||
|
<div class="large-6 medium-6 small-6 columns">
|
||||||
|
<button class="gray" ng-disabled="loading"
|
||||||
|
ng-click="confirmDelete=!confirmDelete">Cancel</button>
|
||||||
|
</div>
|
||||||
|
<div class="large-6 medium-6 small-6 columns">
|
||||||
|
<button class="warning" ng-disabled="loading" ng-click="deleteWallet()">
|
||||||
|
<span ng-show="!loading">
|
||||||
|
<i class="fi-trash"></i> Delete
|
||||||
|
</span>
|
||||||
|
<span ng-show="loading">
|
||||||
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i> Deleting...
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="m20b row">
|
<div class="m20b row">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
|
|
|
||||||
|
|
@ -35,68 +35,13 @@
|
||||||
|
|
||||||
<div class="line-dashed-h m20b"></div>
|
<div class="line-dashed-h m20b"></div>
|
||||||
|
|
||||||
<div class="row" ng-init="setWallets()">
|
<div class="row size-12 m20b">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<h2>Manage wallets</h2>
|
<div ng-if="perItem">
|
||||||
|
Your current server usage quotas are: <b>{{perItem}}kB</b> per wallet and up to <b>{{nrWallets}}</b> wallets.
|
||||||
<div class="box-notification" ng-show="success">
|
|
||||||
<div class="box-icon success">
|
|
||||||
<i class="fi-check size-24"></i>
|
|
||||||
</div>
|
|
||||||
<span class="text-success size-14">
|
|
||||||
{{success|translate}}
|
|
||||||
</span>
|
|
||||||
<a href ng-click="success=false" class="close-notification success">×</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if="$root.needsEmailConfirmation" class="m10t">
|
||||||
<table class="manage-wallets">
|
<i class="fi-alert"></i> Confirm your email address to increase storage usage limits.
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th class="hide-for-small-only">Status</th>
|
|
||||||
<th class="hide-for-small-only">Balance</th>
|
|
||||||
<th class="hide-for-small-only">Approx Size</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr
|
|
||||||
data-ng-repeat="item in wallets | orderBy:'name'"
|
|
||||||
ng-init="isComplete = item.isComplete(); networkName = item.getNetworkName()"
|
|
||||||
ng-click="showWalletInfo(item)">
|
|
||||||
<td>
|
|
||||||
<span ng-show="loading == item.id"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
|
||||||
<span ng-show="loading != item.id">
|
|
||||||
{{item.name || item.id }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}}</td>
|
|
||||||
<td class="hide-for-small-only">
|
|
||||||
{{isComplete ? 'Complete' : 'Waiting for copayers...'}}
|
|
||||||
</td>
|
|
||||||
<td class="hide-for-small-only">
|
|
||||||
<span ng-if="!isComplete">-</span>
|
|
||||||
<span ng-if="isComplete">
|
|
||||||
{{item.balanceInfo.totalBalance || 0}} {{item.settings.unitName}}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="hide-for-small-only">
|
|
||||||
<span>
|
|
||||||
{{item.kb}} kB
|
|
||||||
<span ng-if="item.usage">({{item.usage}}%) </span>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="size-12">
|
|
||||||
<div ng-if="perItem">
|
|
||||||
Your current server usage quotas are: <b>{{perItem}}kB</b> per wallet and up to <b>{{nrWallets}}</b> wallets.
|
|
||||||
</div>
|
|
||||||
<div ng-if="$root.needsEmailConfirmation" class="m10t">
|
|
||||||
<i class="fi-alert"></i> Confirm your email address to increase storage usage limits.
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue