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';
|
||||
|
||||
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() {
|
||||
var w = $rootScope.wallet;
|
||||
$rootScope.title = 'Share this secret with your copayers';
|
||||
$scope.loading = false;
|
||||
$scope.secret = $rootScope.wallet.getSecret();
|
||||
|
|
@ -27,4 +27,25 @@ angular.module('copayApp.controllers').controller('CopayersController',
|
|||
$rootScope.$digest();
|
||||
}, 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';
|
||||
|
||||
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;
|
||||
$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';
|
||||
|
||||
|
|
@ -105,4 +116,34 @@ angular.module('copayApp.controllers').controller('MoreController',
|
|||
}, 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.
|
||||
};
|
||||
|
||||
$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();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue