Merge pull request #2310 from cmgustavo/ux/wallet-info01
Removes "Manage wallets" and moves info to "Settings"
This commit is contained in:
commit
373f12c2a0
19 changed files with 288 additions and 310 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');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,13 +41,6 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
$scope.passwordStrength = null;
|
||||
|
||||
_firstpin = null;
|
||||
|
||||
$scope.setPinForm.newpin.$setViewValue('');
|
||||
$scope.setPinForm.newpin.$render();
|
||||
$scope.setPinForm.repeatpin.$setViewValue('');
|
||||
$scope.setPinForm.repeatpin.$render();
|
||||
$scope.setPinForm.$setPristine();
|
||||
|
||||
$scope.error = 'Entered PINs were not equal. Try again';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
|
|
@ -79,7 +72,6 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
_credentials = null;
|
||||
$scope.askForPin = 0;
|
||||
$rootScope.hasPin = true;
|
||||
$rootScope.starting = null;
|
||||
$scope.createDefaultWallet();
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -123,8 +115,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
/* Last step. Will emit after creation so the UX gets updated */
|
||||
$scope.createDefaultWallet = function() {
|
||||
$rootScope.hideNavigation = false;
|
||||
$rootScope.starting = true;
|
||||
identityService.createDefaultWallet(function(err) {
|
||||
$scope.askForPin = 0;
|
||||
$rootScope.starting = null;
|
||||
|
||||
if (err) {
|
||||
var msg = err.toString();
|
||||
|
|
@ -143,10 +137,8 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
preconditions.checkArgument(_.isString(password));
|
||||
|
||||
$rootScope.hideNavigation = false;
|
||||
$rootScope.starting = true;
|
||||
|
||||
identityService.create(emailOrUsername, password, function(err) {
|
||||
$rootScope.starting = null;
|
||||
$scope.error = null;
|
||||
if (err) {
|
||||
var msg = err.toString();
|
||||
|
|
@ -162,6 +154,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
} else {
|
||||
// mobile
|
||||
if ($scope.isMobile) {
|
||||
$rootScope.starting = null;
|
||||
_credentials = {
|
||||
email: emailOrUsername,
|
||||
password: password,
|
||||
|
|
@ -206,6 +199,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
|||
|
||||
$scope.saveSettings(function(err) {
|
||||
preconditions.checkState(!err, err);
|
||||
$rootScope.starting = true;
|
||||
|
||||
$scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) {
|
||||
$timeout(function() {
|
||||
|
|
|
|||
|
|
@ -127,13 +127,13 @@ angular.module('copayApp.controllers').controller('JoinController',
|
|||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
$rootScope.starting = true;
|
||||
identityService.joinWallet({
|
||||
secret: $scope.connectionId,
|
||||
nickname: $scope.nickname,
|
||||
privateHex: $scope.private,
|
||||
}, function(err) {
|
||||
$scope.loading = false;
|
||||
$rootScope.starting = false;
|
||||
if (err) {
|
||||
if (err === 'joinError')
|
||||
notification.error('Fatal error connecting to Insight server');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova) {
|
||||
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova, notification) {
|
||||
$scope.username = $rootScope.iden.getName();
|
||||
$scope.isSafari = isMobile.Safari();
|
||||
$scope.isCordova = isCordova;
|
||||
|
|
@ -25,86 +25,21 @@ 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() {
|
||||
$scope.loading = true;
|
||||
identityService.deleteProfile(function(err, res) {
|
||||
$scope.loading = false;
|
||||
if (err) {
|
||||
log.warn(err);
|
||||
notification.error('Error', 'Could not delete profile');
|
||||
return;
|
||||
$timeout(function () { $scope.$digest(); });
|
||||
}
|
||||
$location.path('/');
|
||||
$timeout(function() {
|
||||
notification.error('Success', 'Profile successfully deleted');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$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);
|
||||
}
|
||||
else {
|
||||
$location.path('/');
|
||||
$timeout(function() {
|
||||
notification.success('Success', 'Profile successfully deleted');
|
||||
});
|
||||
};
|
||||
|
||||
$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