From 308616c2549387a72eaecd435249fb9e15b629d8 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 9 Nov 2015 15:20:15 -0300 Subject: [PATCH] Moves the global preferences to the sidebar --- public/views/includes/sidebar.html | 10 +++ public/views/preferences.html | 60 +---------------- public/views/preferencesAbout.html | 2 +- public/views/preferencesAltCurrency.html | 2 +- public/views/preferencesFee.html | 2 +- public/views/preferencesGlobal.html | 78 +++++++++++++++++++++++ public/views/preferencesLanguage.html | 2 +- public/views/preferencesLogs.html | 2 +- public/views/preferencesUnit.html | 2 +- public/views/translators.html | 2 +- public/views/walletHome.html | 4 +- src/js/controllers/preferences.js | 58 +---------------- src/js/controllers/preferencesGlobal.js | 63 ++++++++++++++++++ src/js/controllers/preferencesLanguage.js | 4 +- src/js/routes.js | 13 ++-- src/js/services/animationService.js | 3 +- 16 files changed, 177 insertions(+), 130 deletions(-) create mode 100644 public/views/preferencesGlobal.html create mode 100644 src/js/controllers/preferencesGlobal.js diff --git a/public/views/includes/sidebar.html b/public/views/includes/sidebar.html index 9ad4c1617..106bf4af7 100644 --- a/public/views/includes/sidebar.html +++ b/public/views/includes/sidebar.html @@ -36,5 +36,15 @@
Glidera
+
  • + + + +
    + Settings +
    +
    Global preferences
    +
    +
  • diff --git a/public/views/preferences.html b/public/views/preferences.html index 48cc5e9d4..a124cdf9e 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -2,7 +2,7 @@
    + ng-init="titleSection='Wallet Preferences'; closeToHome = true">
    @@ -17,7 +17,7 @@ {{index.alias||index.walletName}} -
    Wallet Alias
    +
    Alias
  • @@ -77,62 +77,6 @@
  • -

    diff --git a/public/views/preferencesAbout.html b/public/views/preferencesAbout.html index c584a6c46..703534699 100644 --- a/public/views/preferencesAbout.html +++ b/public/views/preferencesAbout.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='About Copay'; goBackToState = 'preferencesGlobal'; noColor = true">
    diff --git a/public/views/preferencesAltCurrency.html b/public/views/preferencesAltCurrency.html index 19caee5da..faab726c8 100644 --- a/public/views/preferencesAltCurrency.html +++ b/public/views/preferencesAltCurrency.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
    diff --git a/public/views/preferencesFee.html b/public/views/preferencesFee.html index 5fed61128..73b10bf7d 100644 --- a/public/views/preferencesFee.html +++ b/public/views/preferencesFee.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Bitcoin Network Fee Policy'; goBackToState = 'preferencesGlobal'; noColor = true">

    diff --git a/public/views/preferencesGlobal.html b/public/views/preferencesGlobal.html new file mode 100644 index 000000000..54da4fa4b --- /dev/null +++ b/public/views/preferencesGlobal.html @@ -0,0 +1,78 @@ + +
    +
    + + +
    + +
      +

      + +
    • +
      + {{prefGlobal.currentLanguageName|translate}} + +
      +
      Language
      +
    • +
    +
      +

      +
    • +
      + {{prefGlobal.unitName}} + +
      +
      Unit
      +
    • +
    • +
      + {{prefGlobal.selectedAlternative.name}} + +
      +
      Alternative Currency
      +
    • +
    +
      +

      +
    • +
      + {{index.feeOpts[index.currentFeeLevel]|translate}} + +
      +
      Bitcoin Network Fee Policy
      +
    • +
    • + +
      Use Unconfirmed Funds
      +
    • +
    +
      +

      +
    • + +
      Enable Glidera Service
      +
    • + + +
    +
      +

      +
    • + +
      About Copay
      +
    • +
    +

    + +
    +
    diff --git a/public/views/preferencesLanguage.html b/public/views/preferencesLanguage.html index c0fbc3abc..ebe614bcb 100644 --- a/public/views/preferencesLanguage.html +++ b/public/views/preferencesLanguage.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Language'; goBackToState = 'preferencesGlobal'; noColor = true">
    diff --git a/public/views/preferencesLogs.html b/public/views/preferencesLogs.html index c561c2668..aca235e8a 100644 --- a/public/views/preferencesLogs.html +++ b/public/views/preferencesLogs.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Session log'; goBackToState = 'about'; noColor = true">
    diff --git a/public/views/preferencesUnit.html b/public/views/preferencesUnit.html index 4ab852b35..eccd26b4c 100644 --- a/public/views/preferencesUnit.html +++ b/public/views/preferencesUnit.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Unit'; goBackToState = 'preferencesGlobal'; noColor = true">
    diff --git a/public/views/translators.html b/public/views/translators.html index 24415ca38..f0989984a 100644 --- a/public/views/translators.html +++ b/public/views/translators.html @@ -1,7 +1,7 @@
    + ng-init="titleSection='Translators'; goBackToState = 'about'; noColor = true">
    diff --git a/public/views/walletHome.html b/public/views/walletHome.html index be1b3adca..a9fe07f5b 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -11,8 +11,8 @@
    -
    - +
    +
    diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index b06098502..1701f16be 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -1,20 +1,10 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesController', - function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService, uxLanguage) { + function($scope, $rootScope, $timeout, $log, configService, profileService) { this.init = function() { var config = configService.getSync(); - this.unitName = config.wallet.settings.unitName; - this.bwsurl = config.bws.url; - this.currentLanguageName = uxLanguage.getCurrentLanguageName(); - this.selectedAlternative = { - name: config.wallet.settings.alternativeName, - isoCode: config.wallet.settings.alternativeIsoCode - }; - $scope.spendUnconfirmed = config.wallet.spendUnconfirmed; - $scope.glideraEnabled = config.glidera.enabled; - $scope.glideraTestnet = config.glidera.testnet; var fc = profileService.focusedClient; if (fc) { $scope.encrypt = fc.hasPrivKeyEncrypted(); @@ -31,20 +21,7 @@ angular.module('copayApp.controllers').controller('preferencesController', } }; - var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) { - if (newVal == oldVal) return; - var opts = { - wallet: { - spendUnconfirmed: newVal - } - }; - configService.set(opts, function(err) { - $rootScope.$emit('Local/SpendUnconfirmedUpdated'); - if (err) $log.debug(err); - }); - }); - - var unwatch = $scope.$watch('encrypt', function(val) { + var unwatchEncrypt = $scope.$watch('encrypt', function(val) { var fc = profileService.focusedClient; if (!fc) return; @@ -80,32 +57,6 @@ angular.module('copayApp.controllers').controller('preferencesController', } }); - var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) { - if (newVal == oldVal) return; - var opts = { - glidera: { - enabled: newVal - } - }; - configService.set(opts, function(err) { - $rootScope.$emit('Local/GlideraUpdated'); - if (err) $log.debug(err); - }); - }); - - var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) { - if (newVal == oldVal) return; - var opts = { - glidera: { - testnet: newVal - } - }; - configService.set(opts, function(err) { - $rootScope.$emit('Local/GlideraUpdated'); - if (err) $log.debug(err); - }); - }); - var unwatchRequestTouchid = $scope.$watch('touchid', function(newVal, oldVal) { if (newVal == oldVal || $scope.touchidError) { $scope.touchidError = false; @@ -139,10 +90,7 @@ angular.module('copayApp.controllers').controller('preferencesController', }); $scope.$on('$destroy', function() { - unwatch(); - unwatchSpendUnconfirmed(); - unwatchGlideraEnabled(); - unwatchGlideraTestnet(); + unwatchEncrypt(); unwatchRequestTouchid(); }); }); diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js new file mode 100644 index 000000000..a3733882b --- /dev/null +++ b/src/js/controllers/preferencesGlobal.js @@ -0,0 +1,63 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('preferencesGlobalController', + function($scope, $rootScope, $log, configService, uxLanguage) { + + this.init = function() { + var config = configService.getSync(); + this.unitName = config.wallet.settings.unitName; + this.currentLanguageName = uxLanguage.getCurrentLanguageName(); + this.selectedAlternative = { + name: config.wallet.settings.alternativeName, + isoCode: config.wallet.settings.alternativeIsoCode + }; + $scope.spendUnconfirmed = config.wallet.spendUnconfirmed; + $scope.glideraEnabled = config.glidera.enabled; + $scope.glideraTestnet = config.glidera.testnet; + }; + + var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) { + if (newVal == oldVal) return; + var opts = { + wallet: { + spendUnconfirmed: newVal + } + }; + configService.set(opts, function(err) { + $rootScope.$emit('Local/SpendUnconfirmedUpdated'); + if (err) $log.debug(err); + }); + }); + + var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) { + if (newVal == oldVal) return; + var opts = { + glidera: { + enabled: newVal + } + }; + configService.set(opts, function(err) { + $rootScope.$emit('Local/GlideraUpdated'); + if (err) $log.debug(err); + }); + }); + + var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) { + if (newVal == oldVal) return; + var opts = { + glidera: { + testnet: newVal + } + }; + configService.set(opts, function(err) { + $rootScope.$emit('Local/GlideraUpdated'); + if (err) $log.debug(err); + }); + }); + + $scope.$on('$destroy', function() { + unwatchSpendUnconfirmed(); + unwatchGlideraEnabled(); + unwatchGlideraTestnet(); + }); + }); diff --git a/src/js/controllers/preferencesLanguage.js b/src/js/controllers/preferencesLanguage.js index 4b2d39021..45170e7eb 100644 --- a/src/js/controllers/preferencesLanguage.js +++ b/src/js/controllers/preferencesLanguage.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLanguageController', - function($scope, $log, $timeout, configService, go, uxLanguage) { + function($scope, $log, $timeout, configService, uxLanguage) { this.availableLanguages = uxLanguage.getLanguages(); @@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController if (err) $log.warn(err); $scope.$emit('Local/LanguageSettingUpdated'); $timeout(function() { - go.preferences(); + $scope.$apply(); }, 100); }); }; diff --git a/src/js/routes.js b/src/js/routes.js index 326527899..44f7ca551 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -433,11 +433,14 @@ angular }, } }) - .state('settings', { - url: '/settings', - controller: 'settingsController', - templateUrl: 'views/settings.html', - needProfile: false + .state('preferencesGlobal', { + url: '/preferencesGlobal', + needProfile: true, + views: { + 'main': { + templateUrl: 'views/preferencesGlobal.html', + }, + } }) .state('warning', { url: '/warning', diff --git a/src/js/services/animationService.js b/src/js/services/animationService.js index 6ce701cbe..c1dbbd549 100644 --- a/src/js/services/animationService.js +++ b/src/js/services/animationService.js @@ -21,6 +21,7 @@ angular.module('copayApp.services').factory('animationService', function(isCordo uriglidera: -1, preferences: 11, + preferencesGlobal: 11, glidera: 11, preferencesColor: 12, backup: 12, @@ -151,4 +152,4 @@ angular.module('copayApp.services').factory('animationService', function(isCordo } return root; -}); \ No newline at end of file +});