Skip to content
Snippets Groups Projects
Commit 31a2a7e4 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

- Settings : Add a top menu, with option to reset

- Extension state enable/disable not same in all settings pages
parent d070edc2
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}, },
"plugins":{ "plugins":{
"es": { "es": {
"enable": "false", "enable": false,
"host": "test-net.duniter.fr", "host": "test-net.duniter.fr",
"port": "9203" "port": "9203"
} }
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
}, },
"plugins":{ "plugins":{
"es": { "es": {
"enable": "false", "enable": false,
"host": "192.168.0.28", "host": "192.168.0.5",
"port": "9203" "port": "9203"
} }
} }
......
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
"AUTHENTICATION_SETTINGS": "Authentication", "AUTHENTICATION_SETTINGS": "Authentication",
"REMEMBER_ME": "Remember me", "REMEMBER_ME": "Remember me",
"PLUGINS_SETTINGS": "Extensions", "PLUGINS_SETTINGS": "Extensions",
"MENU_TITLE": "Options",
"BTN_RESET": "Restore default values",
"POPUP_NODE": { "POPUP_NODE": {
"TITLE" : "Duniter Node", "TITLE" : "Duniter Node",
"HELP" : "Set the address of the node to use:" "HELP" : "Set the address of the node to use:"
......
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
"AUTHENTICATION_SETTINGS": "Authentification", "AUTHENTICATION_SETTINGS": "Authentification",
"REMEMBER_ME": "Se souvenir de moi", "REMEMBER_ME": "Se souvenir de moi",
"PLUGINS_SETTINGS": "Extensions", "PLUGINS_SETTINGS": "Extensions",
"MENU_TITLE": "Options",
"BTN_RESET": "Restaurer les valeurs par défaut",
"POPUP_NODE": { "POPUP_NODE": {
"TITLE" : "Noeud Duniter", "TITLE" : "Noeud Duniter",
"HELP" : "Saisissez l'adresse du noeud que vous voulez utiliser :" "HELP" : "Saisissez l'adresse du noeud que vous voulez utiliser :"
...@@ -161,7 +163,7 @@ ...@@ -161,7 +163,7 @@
}, },
"ACCOUNT": { "ACCOUNT": {
"TITLE": "Mon compte", "TITLE": "Mon compte",
"MENU_TITLE": "Options du portefeuille", "MENU_TITLE": "Options",
"BALANCE": "Solde", "BALANCE": "Solde",
"LAST_TX": "Dernières transactions", "LAST_TX": "Dernières transactions",
"NO_TX": "Aucune transaction", "NO_TX": "Aucune transaction",
......
...@@ -20,14 +20,14 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren ...@@ -20,14 +20,14 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren
.controller('SettingsCtrl', SettingsController) .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'; 'ngInject';
$scope.formData = angular.copy(csSettings.data); $scope.formData = angular.copy(csSettings.data);
$scope.popupData = {}; // need for the node popup $scope.popupData = {}; // need for the node popup
$scope.loading = true; $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.loading = true; // to avoid the call of Wallet.store()
$scope.locales = UIUtils.locales; $scope.locales = UIUtils.locales;
$scope.formData.locale = _.findWhere($scope.locales, {id: $translate.use()}); $scope.formData.locale = _.findWhere($scope.locales, {id: $translate.use()});
...@@ -43,12 +43,33 @@ function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, csHtt ...@@ -43,12 +43,33 @@ function SettingsController($scope, $q, $ionicPopup, $timeout, $translate, csHtt
// Set Ink // Set Ink
UIUtils.ink({selector: '.item'}); UIUtils.ink({selector: '.item'});
}, 100); }, 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.setPopupForm = function(popupForm) {
$scope.popupForm = 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) { $scope.changeLanguage = function(langKey) {
$translate.use(langKey); $translate.use(langKey);
}; };
......
...@@ -4,7 +4,7 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.service ...@@ -4,7 +4,7 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.service
.config(function(PluginServiceProvider, csConfig) { .config(function(PluginServiceProvider, csConfig) {
'ngInject'; 'ngInject';
var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; var enable = csConfig.plugins && csConfig.plugins.es;
if (enable) { if (enable) {
// Menu extension points // Menu extension points
PluginServiceProvider.extendState('app', { PluginServiceProvider.extendState('app', {
......
...@@ -4,7 +4,7 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services']) ...@@ -4,7 +4,7 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services'])
.config(function(PluginServiceProvider, $stateProvider, csConfig) { .config(function(PluginServiceProvider, $stateProvider, csConfig) {
'ngInject'; 'ngInject';
var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; var enable = csConfig.plugins && csConfig.plugins.es;
if (enable) { if (enable) {
// Extend settings via extension points // Extend settings via extension points
PluginServiceProvider.extendState('app.settings', { PluginServiceProvider.extendState('app.settings', {
...@@ -42,15 +42,7 @@ function ESExtendSettingsController ($scope, PluginService, csSettings) { ...@@ -42,15 +42,7 @@ function ESExtendSettingsController ($scope, PluginService, csSettings) {
'ngInject'; 'ngInject';
$scope.extensionPoint = PluginService.extensions.points.current.get(); $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);
} }
/* /*
......
...@@ -2,7 +2,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se ...@@ -2,7 +2,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se
.config(function(PluginServiceProvider, csConfig) { .config(function(PluginServiceProvider, csConfig) {
'ngInject'; 'ngInject';
var enable = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.enable; var enable = csConfig.plugins && csConfig.plugins.es;
if (enable) { if (enable) {
// Will force to load this service // Will force to load this service
PluginServiceProvider.registerEagerLoadingService('esUser'); PluginServiceProvider.registerEagerLoadingService('esUser');
...@@ -213,8 +213,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se ...@@ -213,8 +213,7 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se
function isEnable() { function isEnable() {
return csSettings.data.plugins && return csSettings.data.plugins &&
csSettings.data.plugins.es && csSettings.data.plugins.es &&
csSettings.data.plugins.es.enable && host && csSettings.data.plugins.es.enable;
!!esHttp.getServer(host, port);
} }
function refreshListeners() { function refreshListeners() {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<div class="input-label ng-binding" translate>ES_SETTINGS.PLUGIN_NAME</div> <div class="input-label ng-binding" translate>ES_SETTINGS.PLUGIN_NAME</div>
<h3 class="item-note"> <h3 class="item-note">
<span class="dark" ng-if="enable" translate>COMMON.ENABLE</span> <span class="dark" ng-if="formData.plugins.es.enable" translate>COMMON.ENABLE</span>
<span ng-if="!enable" translate>COMMON.DISABLE</span> <span ng-if="!formData.plugins.es.enable" translate>COMMON.DISABLE</span>
</h3> </h3>
</div> </div>
<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>
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
class="settings"> class="settings">
<ion-nav-title translate>SETTINGS.TITLE</ion-nav-title> <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 > <ion-content >
<div class="item item-toggle dark"> <div class="item item-toggle dark">
<div class="input-label"> <div class="input-label">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment