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 @@
},
"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"
}
}
......
......@@ -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:"
......
......@@ -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",
......
......@@ -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);
};
......
......@@ -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', {
......
......@@ -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);
}
/*
......
......@@ -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');
......@@ -213,8 +213,7 @@ 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);
host && csSettings.data.plugins.es.enable;
}
function refreshListeners() {
......
......@@ -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>
<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 @@
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">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment