From 31a2a7e47ae36b26ae912f2662e0118a587dffb1 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Fri, 26 Aug 2016 00:30:20 +0200 Subject: [PATCH] - Settings : Add a top menu, with option to reset - Extension state enable/disable not same in all settings pages --- app/config.json | 6 ++--- www/i18n/locale-en.json | 2 ++ www/i18n/locale-fr-FR.json | 4 ++- www/js/controllers/settings-controllers.js | 25 +++++++++++++++++-- .../es/js/controllers/common-controllers.js | 2 +- .../es/js/controllers/settings-controllers.js | 10 +------- www/plugins/es/js/services/user-services.js | 7 +++--- .../templates/settings/settings_extend.html | 4 +-- www/templates/settings/popover_actions.html | 15 +++++++++++ www/templates/settings/settings.html | 6 +++++ 10 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 www/templates/settings/popover_actions.html diff --git a/app/config.json b/app/config.json index 409b72c95..64f9fcd2e 100644 --- a/app/config.json +++ b/app/config.json @@ -14,7 +14,7 @@ }, "plugins":{ "es": { - "enable": "false", + "enable": false, "host": "test-net.duniter.fr", "port": "9203" } @@ -36,8 +36,8 @@ }, "plugins":{ "es": { - "enable": "false", - "host": "192.168.0.28", + "enable": false, + "host": "192.168.0.5", "port": "9203" } } diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index b44dd9051..ed7d9a479 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -88,6 +88,8 @@ "AUTHENTICATION_SETTINGS": "Authentication", "REMEMBER_ME": "Remember me", "PLUGINS_SETTINGS": "Extensions", + "MENU_TITLE": "Options", + "BTN_RESET": "Restore default values", "POPUP_NODE": { "TITLE" : "Duniter Node", "HELP" : "Set the address of the node to use:" diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 2baf9ea99..31a7dd194 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -88,6 +88,8 @@ "AUTHENTICATION_SETTINGS": "Authentification", "REMEMBER_ME": "Se souvenir de moi", "PLUGINS_SETTINGS": "Extensions", + "MENU_TITLE": "Options", + "BTN_RESET": "Restaurer les valeurs par défaut", "POPUP_NODE": { "TITLE" : "Noeud Duniter", "HELP" : "Saisissez l'adresse du noeud que vous voulez utiliser :" @@ -161,7 +163,7 @@ }, "ACCOUNT": { "TITLE": "Mon compte", - "MENU_TITLE": "Options du portefeuille", + "MENU_TITLE": "Options", "BALANCE": "Solde", "LAST_TX": "Dernières transactions", "NO_TX": "Aucune transaction", diff --git a/www/js/controllers/settings-controllers.js b/www/js/controllers/settings-controllers.js index 8e498c79e..641e2f764 100644 --- a/www/js/controllers/settings-controllers.js +++ b/www/js/controllers/settings-controllers.js @@ -20,14 +20,14 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren .controller('SettingsCtrl', SettingsController) ; -function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, csHttp, UIUtils, BMA, csSettings) { +function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, csHttp, UIUtils, BMA, csSettings, $ionicPopover) { 'ngInject'; $scope.formData = angular.copy(csSettings.data); $scope.popupData = {}; // need for the node popup $scope.loading = true; - $scope.$on('$ionicView.enter', function(e, $state) { + $scope.$on('$ionicView.enter', function(e) { $scope.loading = true; // to avoid the call of Wallet.store() $scope.locales = UIUtils.locales; $scope.formData.locale = _.findWhere($scope.locales, {id: $translate.use()}); @@ -43,12 +43,33 @@ function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, csHtt // Set Ink UIUtils.ink({selector: '.item'}); }, 100); + + + }); + + $ionicPopover.fromTemplateUrl('templates/settings/popover_actions.html', { + scope: $scope + }).then(function(popover) { + $scope.actionsPopover = popover; + }); + + //Cleanup the popover when we're done with it! + $scope.$on('$destroy', function() { + $scope.actionsPopover.remove(); }); $scope.setPopupForm = function(popupForm) { $scope.popupForm = popupForm; }; + $scope.reset = function() { + if ($scope.actionsPopover) { + $scope.actionsPopover.hide(); + } + csSettings.reset(); + angular.merge($scope.formData, csSettings.data); + }; + $scope.changeLanguage = function(langKey) { $translate.use(langKey); }; diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index 983d60f58..5af39d644 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -4,7 +4,7 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.service .config(function(PluginServiceProvider, csConfig) { 'ngInject'; - var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; + var enable = csConfig.plugins && csConfig.plugins.es; if (enable) { // Menu extension points PluginServiceProvider.extendState('app', { diff --git a/www/plugins/es/js/controllers/settings-controllers.js b/www/plugins/es/js/controllers/settings-controllers.js index da91a34fa..a9bc5f0a8 100644 --- a/www/plugins/es/js/controllers/settings-controllers.js +++ b/www/plugins/es/js/controllers/settings-controllers.js @@ -4,7 +4,7 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services']) .config(function(PluginServiceProvider, $stateProvider, csConfig) { 'ngInject'; - var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; + var enable = csConfig.plugins && csConfig.plugins.es; if (enable) { // Extend settings via extension points PluginServiceProvider.extendState('app.settings', { @@ -42,15 +42,7 @@ function ESExtendSettingsController ($scope, PluginService, csSettings) { 'ngInject'; $scope.extensionPoint = PluginService.extensions.points.current.get(); - $scope.enable = false; - // Update settings if need - $scope.onSettingsLoaded = function() { - if ($scope.loading) { - $scope.enable = csSettings.data.plugins && csSettings.data.plugins.es && csSettings.data.plugins.es.enable; - } - }; - $scope.$watch('formData', $scope.onSettingsLoaded, true); } /* diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index 5936fcfe5..3f1910634 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -2,7 +2,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se .config(function(PluginServiceProvider, csConfig) { 'ngInject'; - var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; + var enable = csConfig.plugins && csConfig.plugins.es; if (enable) { // Will force to load this service PluginServiceProvider.registerEagerLoadingService('esUser'); @@ -212,9 +212,8 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se function isEnable() { return csSettings.data.plugins && - csSettings.data.plugins.es && - csSettings.data.plugins.es.enable && - !!esHttp.getServer(host, port); + csSettings.data.plugins.es && + host && csSettings.data.plugins.es.enable; } function refreshListeners() { diff --git a/www/plugins/es/templates/settings/settings_extend.html b/www/plugins/es/templates/settings/settings_extend.html index 0d9d277f9..4cdf3c353 100644 --- a/www/plugins/es/templates/settings/settings_extend.html +++ b/www/plugins/es/templates/settings/settings_extend.html @@ -5,7 +5,7 @@ <div class="input-label ng-binding" translate>ES_SETTINGS.PLUGIN_NAME</div> <h3 class="item-note"> - <span class="dark" ng-if="enable" translate>COMMON.ENABLE</span> - <span ng-if="!enable" translate>COMMON.DISABLE</span> + <span class="dark" ng-if="formData.plugins.es.enable" translate>COMMON.ENABLE</span> + <span ng-if="!formData.plugins.es.enable" translate>COMMON.DISABLE</span> </h3> </div> diff --git a/www/templates/settings/popover_actions.html b/www/templates/settings/popover_actions.html new file mode 100644 index 000000000..8dbdb691a --- /dev/null +++ b/www/templates/settings/popover_actions.html @@ -0,0 +1,15 @@ +<ion-popover-view class="fit has-header"> + <ion-header-bar> + <h1 class="title" translate>SETTINGS.MENU_TITLE</h1> + </ion-header-bar> + <ion-content scroll="false"> + <div class="list item-text-wrap"> + + <a class="item item-icon-left ink" + ng-click="reset()"> + <i class="icon ion-refresh"></i> + {{'SETTINGS.BTN_RESET' | translate}} + </a> + </div> + </ion-content> +</ion-popover-view> diff --git a/www/templates/settings/settings.html b/www/templates/settings/settings.html index 500ac2aac..0712e6625 100644 --- a/www/templates/settings/settings.html +++ b/www/templates/settings/settings.html @@ -3,6 +3,12 @@ class="settings"> <ion-nav-title translate>SETTINGS.TITLE</ion-nav-title> + <ion-nav-buttons side="secondary"> + <button class="button button-icon button-clear" ng-click="actionsPopover.show($event)"> + <i class="icon ion-android-more-vertical"></i> + </button> + </ion-nav-buttons> + <ion-content > <div class="item item-toggle dark"> <div class="input-label"> -- GitLab