2016-08-15 17:42:04 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-11-22 12:35:51 -03:00
|
|
|
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $window, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService) {
|
2016-08-15 17:42:04 -03:00
|
|
|
|
2016-09-21 17:12:25 -03:00
|
|
|
var updateConfig = function() {
|
2016-09-05 14:59:11 -03:00
|
|
|
|
2016-10-28 10:13:40 -03:00
|
|
|
var config = configService.getSync();
|
2016-10-28 12:07:59 -04:00
|
|
|
var isCordova = platformInfo.isCordova;
|
|
|
|
|
var isWP = platformInfo.isWP;
|
2016-11-22 12:35:51 -03:00
|
|
|
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
|
2016-10-28 12:07:59 -04:00
|
|
|
|
|
|
|
|
$scope.usePushNotifications = isCordova && !isWP;
|
2016-11-16 16:57:36 -03:00
|
|
|
$scope.isCordova = isCordova;
|
2016-10-28 12:07:59 -04:00
|
|
|
|
|
|
|
|
$scope.appName = $window.appConfig.nameCase;
|
|
|
|
|
|
2016-08-15 17:42:04 -03:00
|
|
|
$scope.unitName = config.wallet.settings.unitName;
|
|
|
|
|
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
|
|
|
|
|
$scope.selectedAlternative = {
|
|
|
|
|
name: config.wallet.settings.alternativeName,
|
|
|
|
|
isoCode: config.wallet.settings.alternativeIsoCode
|
|
|
|
|
};
|
|
|
|
|
$scope.feeOpts = feeService.feeOpts;
|
|
|
|
|
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
|
2016-09-27 15:57:39 -03:00
|
|
|
|
2016-08-31 16:41:53 -03:00
|
|
|
$scope.wallets = profileService.getWallets();
|
2016-11-21 11:36:41 -03:00
|
|
|
|
|
|
|
|
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
|
2016-11-22 12:35:51 -03:00
|
|
|
|
|
|
|
|
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
|
2016-08-15 17:42:04 -03:00
|
|
|
};
|
|
|
|
|
|
2016-10-12 15:29:06 -04:00
|
|
|
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
|
|
|
|
|
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) {
|
2016-09-21 17:12:25 -03:00
|
|
|
updateConfig();
|
2016-11-21 11:36:41 -03:00
|
|
|
|
|
|
|
|
bitpayCardService.getBitpayDebitCards(function(err, data) {
|
2016-11-22 12:35:51 -03:00
|
|
|
if (err) $log.error(err);
|
2016-11-21 11:36:41 -03:00
|
|
|
if (!lodash.isEmpty(data)) {
|
|
|
|
|
$scope.bitpayCards = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-11-22 12:35:51 -03:00
|
|
|
|
|
|
|
|
storageService.getGlideraToken(glideraService.getEnvironment(), function(err, token) {
|
|
|
|
|
if (err) $log.error(err);
|
|
|
|
|
$scope.glideraToken = token;
|
|
|
|
|
});
|
2016-09-21 17:12:25 -03:00
|
|
|
});
|
|
|
|
|
|
2016-08-15 17:42:04 -03:00
|
|
|
});
|