Fix fee level, preferences by wallet, delete, info

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-05 17:36:11 -03:00
commit a1672e1e95
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
17 changed files with 106 additions and 128 deletions

View file

@ -2,7 +2,7 @@
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService, fingerprintService, walletService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Preferences'));
$ionicNavBarDelegate.title(gettextCatalog.getString('Wallet Preferences'));
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
$scope.wallet = wallet;
@ -14,9 +14,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
return $ionicHistory.goBack();
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
$scope.color = config.colorFor[walletId] || '#4A90E2';
$scope.encryptEnabled = walletService.isEncrypted(wallet);
if (wallet.isPrivKeyExternal)

View file

@ -8,9 +8,8 @@ angular.module('copayApp.controllers').controller('preferencesAliasController',
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.walletName = wallet.credentials.walletName;
$scope.alias = config.aliasFor[walletId] || wallet.walletName;
$scope.alias = (config.aliasFor && config.aliasFor[walletId]) || wallet.walletName;
$scope.save = function() {
var opts = {

View file

@ -1,32 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet'));
function($scope, $stateParams, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete'));
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.showDeletePopup = function() {
var popup = $ionicPopup.show({
template: '<span>' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '</span>',
title: gettextCatalog.getString('Confirm'),
buttons: [
{
text: gettextCatalog.getString('Cancel'),
onTap: function(e) {
popup.close();
}
},
{
text: gettextCatalog.getString('Accept'),
type: 'button-positive',
onTap: function(e) {
deleteWallet();
popup.close();
}
}
]
var title = gettextCatalog.getString('Warning!');
var message = gettextCatalog.getString('Are you sure you want to delete this wallet?');
popupService.showConfirm(title, message, function(res) {
if (res) deleteWallet();
});
};

View file

@ -1,12 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, feeService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Preferences fee'));
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, feeService, ongoingProcess) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Bitcoin Network Fee Policy'));
$scope.init = function() {
$scope.loading = true;
ongoingProcess.set('gettingFeeLevels', true);
feeService.getFeeLevels(function(levels) {
$scope.loading = false;
ongoingProcess.set('gettingFeeLevels', false);
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.feeLevels = levels;
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
$ionicHistory.goBack();
$timeout(function() {
$scope.$apply();
}, 10);
}, 100);
});
};
});

View file

@ -3,15 +3,14 @@
angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $stateParams, $timeout, $ionicNavBarDelegate, gettextCatalog, storageService, $state, $ionicHistory, profileService, lodash) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Transaction History'));
var wallet = profileService.getWallet($stateParams.walletId);
var c = wallet.credentials;
$scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.csvReady = false;
$scope.csvHistory = function(cb) {
var allTxs = [];
function getHistory(cb) {
storageService.getTxHistory(c.walletId, function(err, txs) {
storageService.getTxHistory($scope.wallet.id, function(err, txs) {
if (err) return cb(err);
var txsFromLocal = [];
@ -40,7 +39,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
var data = txs;
var satToBtc = 1 / 100000000;
$scope.csvContent = [];
$scope.csvFilename = 'Copay-' + ($scope.alias || $scope.walletName) + '.csv';
$scope.csvFilename = 'Copay-' + $scope.wallet.name + '.csv';
$scope.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment'];
var _amount, _note, _copayers, _creator, _comment;
@ -118,7 +117,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
};
$scope.clearTransactionHistory = function() {
storageService.removeTxHistory(c.walletId, function(err) {
storageService.removeTxHistory($scope.wallet.id, function(err) {
if (err) {
$log.error(err);
return;

View file

@ -31,6 +31,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'sweepingWallet': gettext('Sweeping Wallet...'),
'deletingWallet': gettext('Deleting Wallet...'),
'extractingWalletInfo': gettext('Extracting Wallet Information...'),
'gettingFeeLevels': gettext('Getting fee levels...'),
};
root.clear = function() {

View file

@ -31,9 +31,9 @@ angular.module('copayApp.services')
root.updateWalletSettings = function(wallet) {
var defaults = configService.getDefaults();
configService.whenAvailable(function(config){
wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName;
wallet.color = config.colorFor[wallet.id] || '#4A90E2';
wallet.usingCustomBWS = config.bwsFor && config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
wallet.name = (config.aliasFor && config.aliasFor[wallet.id]) || wallet.credentials.walletName;
wallet.color = (config.colorFor && config.colorFor[wallet.id]) || '#4A90E2';
wallet.email = config.emailFor && config.emailFor[wallet.id];
});
}