Move wallet-info to settings. Fix removing last wallet

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-14 14:53:20 -03:00
commit 5b1463af60
8 changed files with 171 additions and 204 deletions

View file

@ -25,25 +25,6 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
// 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() {
identityService.deleteProfile(function(err, res) {
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();
});
};
});