Wallet/src/js/controllers/tab-settings.js

78 lines
3 KiB
JavaScript
Raw Normal View History

2016-08-15 17:42:04 -03:00
'use strict';
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
configService.whenAvailable(function(config) {
$scope.selectedAlternative = {
name: config.wallet.settings.alternativeName,
isoCode: config.wallet.settings.alternativeIsoCode
};
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
// TODO move this to a generic service
bitpayAccountService.getAccounts(function(err, data) {
2017-01-31 17:45:19 -03:00
if (err) $log.error(err);
$scope.bitpayAccounts = !lodash.isEmpty(data);
$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 = {
value: config.cashSupport
2017-09-08 05:03:30 -03:00
};
// TODO move this to a generic service
bitpayCardService.getCards(function(err, cards) {
if (err) $log.error(err);
$scope.bitpayCards = cards && cards.length > 0;
$timeout(function() {
$rootScope.$apply();
}, 10);
});
});
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');
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$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;
$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
});
});
$scope.$on("$ionicView.enter", function(event, data) {
$ionicNavBarDelegate.showBar(true);
2016-09-21 17:12:25 -03:00
updateConfig();
});
2016-08-15 17:42:04 -03:00
});