Merge pull request #1769 from cmgustavo/bug/manage-profile-createWallet

Bug/manage profile create wallet
This commit is contained in:
Matias Alejo Garcia 2014-11-11 17:07:09 -03:00
commit 6926bb9b04
17 changed files with 175 additions and 165 deletions

View file

@ -0,0 +1,5 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateWalletController', function($scope, $rootScope) {
$rootScope.title = 'Create Wallet';
});

View file

@ -1,36 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('ManageController', function($scope, $rootScope, $location, controllerUtils, backupService) {
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$rootScope.title = 'Manage wallets';
$scope.downloadBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewBackup = function() {
$scope.backupPlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewBackup = true;
};
$scope.getWallets = function() {
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
_.each(wids, function(wid) {
var w = $rootScope.iden.getWalletById(wid);
$scope.wallets.push(w);
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
}, true);
});
};
$scope.deleteWallet = function(w) {
if (!w) return;
$scope.loading = w.id;
controllerUtils.deleteWallet($scope, w, function() {
$scope.loading = false;
$scope.getWallets();
});
};
});

View file

@ -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);

66
js/controllers/profile.js Normal file
View file

@ -0,0 +1,66 @@
'use strict';
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.downloadProfileBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$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) {
var w = $rootScope.iden.getWalletById(wid);
$scope.wallets.push(w);
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
}, true);
});
};
$scope.deleteWallet = function(w) {
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
});
};
});

View file

@ -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) {