refactor settings tab

This commit is contained in:
Gabriel Bazán 2016-08-15 17:42:04 -03:00
commit 41cc509d47
21 changed files with 462 additions and 252 deletions

View file

@ -3,13 +3,15 @@
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
function($scope, $log, $timeout, configService, rateService, lodash, go, profileService, walletService) {
var config = configService.getSync();
var next = 10;
var completeAlternativeList;
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
$scope.listComplete = false;
$scope.init = function() {
var config = configService.getSync();
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
$scope.listComplete = false;
rateService.whenAvailable(function() {
completeAlternativeList = rateService.listAlternatives();
lodash.remove(completeAlternativeList, function(c) {

View file

@ -2,14 +2,16 @@
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, configService, feeService) {
$scope.loading = true;
feeService.getFeeLevels(function(levels) {
$scope.loading = false;
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.feeLevels = levels;
$scope.$apply();
});
$scope.init = function() {
$scope.loading = true;
feeService.getFeeLevels(function(levels) {
$scope.loading = false;
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.feeLevels = levels;
$scope.$apply();
});
}
$scope.save = function(newFee) {
var opts = {

View file

@ -3,14 +3,14 @@
angular.module('copayApp.controllers').controller('preferencesGlobalController',
function($scope, $rootScope, $log, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var isCordova = platformInfo.isCordova;
if (isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#4B6178");
}
$scope.init = function() {
var config = configService.getSync();
var isCordova = platformInfo.isCordova;
if (isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#4B6178");
}
$scope.unitName = config.wallet.settings.unitName;
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
$scope.selectedAlternative = {

View file

@ -1,10 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesLanguageController',
function($scope, $log, configService, profileService, uxLanguage, walletService, go) {
function($scope, $log, $state, configService, profileService, uxLanguage, walletService, go) {
$scope.availableLanguages = uxLanguage.getLanguages();
$scope.currentLanguage = uxLanguage.getCurrentLanguage();
$scope.init = function() {
$scope.availableLanguages = uxLanguage.getLanguages();
$scope.currentLanguage = uxLanguage.getCurrentLanguage();
}
$scope.save = function(newLang) {
var opts = {

View file

@ -1,25 +1,28 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesLogs',
function(historicLog) {
this.logs = historicLog.get();
function($scope, historicLog) {
this.sendLogs = function() {
var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
body += '\n\n';
body += this.logs.map(function(v) {
return v.msg;
}).join('\n');
$scope.init = function() {
$scope.logs = historicLog.get();
}
window.plugins.socialsharing.shareViaEmail(
body,
'Copay Logs',
null, // TO: must be null or an array
null, // CC: must be null or an array
null, // BCC: must be null or an array
null, // FILES: can be null, a string, or an array
function() {},
function() {}
);
};
});
$scope.sendLogs = function() {
var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
body += '\n\n';
body += $scope.logs.map(function(v) {
return v.msg;
}).join('\n');
window.plugins.socialsharing.shareViaEmail(
body,
'Copay Logs',
null, // TO: must be null or an array
null, // CC: must be null or an array
null, // BCC: must be null or an array
null, // FILES: can be null, a string, or an array
function() {},
function() {}
);
};
});

View file

@ -2,9 +2,10 @@
angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, go, walletService, profileService) {
var config = configService.getSync();
$scope.currentUnit = config.wallet.settings.unitCode;
$scope.init = function() {
var config = configService.getSync();
$scope.currentUnit = config.wallet.settings.unitCode;
}
$scope.unitList = [
{

View file

@ -0,0 +1,109 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
$scope.init = function() {
var config = configService.getSync();
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
$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();
$scope.usePushNotifications = isCordova && !isWP;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
}
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.coinbaseEnabled = config.coinbase.enabled;
$scope.pushNotifications = config.pushNotifications.enabled;
if (isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#4B6178");
}
$scope.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
return w.id != self.walletId;
});
};
$scope.openAddressbookModal = function() {
$ionicModal.fromTemplateUrl('views/modals/addressbook.html', {
scope: $scope
}).then(function(modal) {
$scope.addressbookModal = modal;
$scope.addressbookModal.show();
});
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
}
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/SpendUnconfirmedUpdated', $scope.spendUnconfirmed);
if (err) $log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications
}
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
else
pushNotificationsService.disableNotifications(profileService.walletClients);
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled
}
};
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);
});
};
});

View file

@ -160,11 +160,16 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
}
})
.state('unsupported', {
.state('feedback', {
url: '/feedback',
needProfile: true,
views: {
'main': {
templateUrl: 'views/feedback.html',
},
}
})
.state('unsupported', {
url: '/unsupported',
needProfile: false,
views: {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services').factory('feeService', function($log, bwcService, profileService, configService, gettext, lodash) {
angular.module('copayApp.services').factory('feeService', function($log, bwcService, walletService, configService, gettext, lodash) {
var root = {};
// Constant fee options to translate
@ -16,7 +16,7 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ
};
root.getCurrentFeeValue = function(cb) {
var fc = profileService.focusedClient;
var fc = walletService.focusedClient;
var feeLevel = root.getCurrentFeeLevel();
fc.getFeeLevels(fc.credentials.network, function(err, levels) {
@ -49,8 +49,8 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ
if (errLivenet || errTestnet) $log.debug('Could not get dynamic fee');
else {
for (var i = 0; i < 4; i++) {
levelsLivenet[i]['feePerKBUnit'] = profileService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName;
levelsTestnet[i]['feePerKBUnit'] = profileService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName;
levelsLivenet[i]['feePerKBUnit'] = walletService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName;
levelsTestnet[i]['feePerKBUnit'] = walletService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName;
}
}

View file

@ -56,7 +56,7 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe
};
root.preferencesGlobal = function() {
$state.transitionTo('preferencesGlobal');
$state.transitionTo('tabs.settings');
};
root.reload = function() {