2016-08-15 17:42:04 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2018-02-28 14:15:44 +05:00
|
|
|
angular.module('copayApp.controllers').controller('tabSettingsController', function($rootScope, $timeout, $scope, appConfigService, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayAccountService, bitpayCardService, storageService, glideraService, gettextCatalog, buyAndSellService, $ionicNavBarDelegate) {
|
2016-08-15 17:42:04 -03:00
|
|
|
|
2016-09-21 17:12:25 -03:00
|
|
|
var updateConfig = function() {
|
2016-08-15 17:42:04 -03:00
|
|
|
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
|
|
|
|
|
$scope.feeOpts = feeService.feeOpts;
|
|
|
|
|
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
|
2017-10-05 17:13:26 -03:00
|
|
|
$scope.walletsBtc = profileService.getWallets({ coin: 'btc' });
|
|
|
|
|
$scope.walletsBch = profileService.getWallets({ coin: 'bch' });
|
2017-01-30 19:38:52 -03:00
|
|
|
$scope.buyAndSellServices = buyAndSellService.getLinked();
|
2016-12-27 15:19:53 -03:00
|
|
|
|
2016-12-12 18:28:58 -03:00
|
|
|
configService.whenAvailable(function(config) {
|
|
|
|
|
$scope.selectedAlternative = {
|
|
|
|
|
name: config.wallet.settings.alternativeName,
|
|
|
|
|
isoCode: config.wallet.settings.alternativeIsoCode
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-25 13:59:25 +09:00
|
|
|
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
|
|
|
|
|
2017-02-22 12:16:38 -05:00
|
|
|
// TODO move this to a generic service
|
2017-01-06 12:11:47 -05:00
|
|
|
bitpayAccountService.getAccounts(function(err, data) {
|
2017-01-31 17:45:19 -03:00
|
|
|
if (err) $log.error(err);
|
2017-01-06 12:11:47 -05:00
|
|
|
$scope.bitpayAccounts = !lodash.isEmpty(data);
|
2017-02-22 12:34:19 -05:00
|
|
|
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$rootScope.$apply();
|
|
|
|
|
}, 10);
|
2017-01-31 17:45:19 -03:00
|
|
|
});
|
2016-11-21 11:36:41 -03:00
|
|
|
|
2017-09-08 05:03:30 -03:00
|
|
|
$scope.cashSupport = {
|
2017-09-08 16:37:26 -03:00
|
|
|
value: config.cashSupport
|
2017-09-08 05:03:30 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2017-02-22 12:16:38 -05:00
|
|
|
// TODO move this to a generic service
|
|
|
|
|
bitpayCardService.getCards(function(err, cards) {
|
|
|
|
|
if (err) $log.error(err);
|
|
|
|
|
$scope.bitpayCards = cards && cards.length > 0;
|
2017-02-22 12:34:19 -05:00
|
|
|
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$rootScope.$apply();
|
|
|
|
|
}, 10);
|
2017-02-22 12:16:38 -05:00
|
|
|
});
|
2016-12-12 18:28:58 -03:00
|
|
|
});
|
2016-08-15 17:42:04 -03:00
|
|
|
};
|
|
|
|
|
|
2016-12-12 17:29:11 -03:00
|
|
|
$scope.openExternalLink = function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
var appName = appConfigService.name;
|
2017-06-18 18:44:26 +09:00
|
|
|
var url = appName == 'copay' ? 'https://github.com/bitcoin-com/wallet/issues' : 'https://www.bitcoin.com/wallet-support';
|
2017-03-09 16:56:35 -03:00
|
|
|
var optIn = true;
|
2017-03-10 11:42:34 -03:00
|
|
|
var title = null;
|
|
|
|
|
var message = gettextCatalog.getString('Help and support information is available at the website.');
|
2017-03-09 16:48:38 -03:00
|
|
|
var okText = gettextCatalog.getString('Open');
|
2016-12-12 17:29:11 -03:00
|
|
|
var cancelText = gettextCatalog.getString('Go Back');
|
2016-10-12 15:29:06 -04:00
|
|
|
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
2016-10-07 11:35:43 -04:00
|
|
|
};
|
|
|
|
|
|
2016-09-30 13:19:29 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
2017-02-21 14:03:55 -05:00
|
|
|
$scope.isCordova = platformInfo.isCordova;
|
2017-06-07 15:23:45 -03:00
|
|
|
$scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
2017-03-30 12:38:23 -03:00
|
|
|
$scope.isDevel = platformInfo.isDevel;
|
2017-02-21 14:03:55 -05:00
|
|
|
$scope.appName = appConfigService.nameCase;
|
2017-03-30 12:38:23 -03:00
|
|
|
configService.whenAvailable(function(config) {
|
2017-04-18 13:19:16 -03:00
|
|
|
$scope.locked = config.lock && config.lock.method;
|
2017-04-20 15:48:05 -03:00
|
|
|
if (!$scope.locked || $scope.locked == 'none')
|
|
|
|
|
$scope.method = gettextCatalog.getString('Disabled');
|
|
|
|
|
else
|
|
|
|
|
$scope.method = $scope.locked.charAt(0).toUpperCase() + config.lock.method.slice(1);
|
2017-03-30 12:38:23 -03:00
|
|
|
});
|
2017-02-21 14:03:55 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$scope.$on("$ionicView.enter", function(event, data) {
|
2018-02-28 14:15:44 +05:00
|
|
|
$ionicNavBarDelegate.showBar(true);
|
2016-09-21 17:12:25 -03:00
|
|
|
updateConfig();
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-15 17:42:04 -03:00
|
|
|
});
|