advanced settings

This commit is contained in:
Gabriel Bazán 2016-09-27 15:57:39 -03:00
commit d75af58ddf
9 changed files with 239 additions and 86 deletions

View file

@ -0,0 +1,113 @@
'use strict';
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var updateConfig = function() {
var config = configService.getSync();
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.bitpayCardEnabled = {
value: config.bitpayCard.enabled
};
$scope.amazonEnabled = {
value: config.amazon.enabled
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = {
value: config.coinbase.enabled
};
$scope.recentTransactionsEnabled = {
value: config.recentTransactions.enabled
};
$scope.frequentlyUsedEnabled = {
value: config.frequentlyUsed.enabled
};
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.bitpayCardChange = function() {
var opts = {
bitpayCard: {
enabled: $scope.bitpayCardEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.amazonChange = function() {
var opts = {
amazon: {
enabled: $scope.amazonEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.recentTransactionsChange = function() {
var opts = {
recentTransactions: {
enabled: $scope.recentTransactionsEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.frequentlyUsedChange = function() {
var opts = {
frequentlyUsed: {
enabled: $scope.frequentlyUsedEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});
});

View file

@ -209,6 +209,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
$scope.amazonEnabled = config.amazon.enabled;
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
$scope.nextStepEnabled = $scope.glideraEnabled || $scope.coinbaseEnabled || $scope.amazonEnabled || $scope.bitpayCardEnabled;
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
});
$scope.nextStep();
$scope.updateAllWallets();

View file

@ -28,13 +28,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
$scope.$digest();
});
}
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = config.coinbase.enabled;
$scope.pushNotifications = {
value: config.pushNotifications.enabled
};
@ -52,17 +46,6 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
});
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
@ -78,28 +61,6 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});

View file

@ -390,6 +390,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
}
})
.state('tabs.advanced', {
url: '/advanced',
views: {
'tab-settings@tabs': {
controller: 'advancedSettingsController',
templateUrl: 'views/advancedSettings.html'
}
}
})
/*
*

View file

@ -39,10 +39,28 @@ angular.module('copayApp.services').factory('configService', function(storageSer
},
coinbase: {
enabled: true,
enabled: false, //disable coinbase for this release
testnet: false
},
bitpayCard: {
enabled: true
},
amazon: {
enabled: true
},
//Experimental Features
recentTransactions: {
enabled: true
},
frequentlyUsed: {
enabled: true
},
rates: {
url: 'https://insight.bitpay.com:443/api/rates',
},
@ -111,6 +129,18 @@ angular.module('copayApp.services').factory('configService', function(storageSer
if (!configCache.coinbase) {
configCache.coinbase = defaultConfig.coinbase;
}
if (!configCache.amazon) {
configCache.amazon = defaultConfig.amazon;
}
if (!configCache.bitpayCard) {
configCache.bitpayCard = defaultConfig.bitpayCard;
}
if (!configCache.recentTransactions) {
configCache.recentTransactions = defaultConfig.recentTransactions;
}
if (!configCache.frequentlyUsed) {
configCache.frequentlyUsed = defaultConfig.frequentlyUsed;
}
if (!configCache.pushNotifications) {
configCache.pushNotifications = defaultConfig.pushNotifications;
}

View file

@ -780,21 +780,11 @@ angular.module('copayApp.services')
var TIME_STAMP = 60 * 60 * 24 * 7;
var MAX = 100;
var typeFilter1 = {
'NewBlock': 1,
'BalanceUpdated': 1,
'NewOutgoingTxByThirdParty': 1,
'NewAddress': 1,
'TxProposalFinallyAccepted': 1,
'TxProposalFinallyRejected': 1,
var typeFilter = {
'NewOutgoingTx': 1,
'NewIncomingTx': 1
};
var typeFilter2 = {
'TxProposalAcceptedBy': 1,
'TxProposalRejectedBy': 1,
'NewTxProposal': 1,
}
var w = root.getWallets();
if (lodash.isEmpty(w)) return cb();
@ -895,15 +885,9 @@ angular.module('copayApp.services')
var n;
n = lodash.filter(wallet.cachedActivity.n, function(x) {
return !typeFilter1[x.type];
return typeFilter[x.type];
});
if (wallet.m == 1) {
n = lodash.filter(n, function(x) {
return !typeFilter2[x.type];
});
}
var idToName = {};
if (wallet.cachedStatus) {
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {