Skip to content

Commit 7157976

Browse files
committed
- ES Settings : Force left menu to refresh, when ES plugin enable/disable
- Settings : move plugins divider to ES plugin settings extends.
1 parent 25205ba commit 7157976

File tree

13 files changed

+77
-51
lines changed

13 files changed

+77
-51
lines changed

config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
xmlns="http://www.w3.org/ns/widgets"
44
xmlns:cdv="http://cordova.apache.org/ns/1.0"
55
id="fr.duniter.cesium"
6-
version="0.1.27"
7-
android-versionCode="14"
6+
version="0.1.28"
7+
android-versionCode="15"
88
>
99
<name>Cesium</name>
1010
<description>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cesium",
3-
"version": "0.1.27",
3+
"version": "0.1.28",
44
"description": "Unhosted webapp client for Duniter network",
55
"dependencies": {
66
"delete-empty": "^0.1.3",

www/i18n/locale-en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"BTN_MARKET": "Market place",
7070
"BTN_CURRENCIES": "Explore currencies",
7171
"BTN_CURRENCY": "Explore currency",
72-
"BTN_ABOUT": "About",
72+
"BTN_ABOUT": "about",
7373
"BTN_ACCOUNT": "My Account",
7474
"REPORT_ISSUE": "Report an issue"
7575
},

www/i18n/locale-fr-FR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"BTN_MARKET": "Offres/demandes",
7070
"BTN_CURRENCIES": "Explorer les monnaies",
7171
"BTN_CURRENCY": "Explorer la monnaie",
72-
"BTN_ABOUT": "A propos",
72+
"BTN_ABOUT": "à propos",
7373
"BTN_ACCOUNT": "Mon compte",
7474
"REPORT_ISSUE": "anomalie"
7575
},

www/js/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ angular.module("cesium.config", [])
1313
"NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug",
1414
"TIMEOUT": 4000,
1515
"DEBUG": false,
16-
"VERSION": "0.1.27",
17-
"BUILD_DATE": "2016-08-18T14:32:54.704Z"
16+
"VERSION": "0.1.28",
17+
"BUILD_DATE": "2016-08-18T16:43:00.994Z"
1818
})
1919

2020
;

www/js/services/wallet-services.js

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser
88
Wallet = function(id) {
99

1010
var
11+
events = {
12+
SETTINGS: 'wallet-settings-changed'
13+
},
1114

1215
defaultSettings = {
1316
useRelative: true,
@@ -201,41 +204,51 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser
201204
return isLogin() && data.pubkey === pubkey;
202205
},
203206

204-
store = function() {
207+
store = function(options) {
205208
if (data.settings.useLocalStorage) {
206-
localStorage.setObject('CESIUM_SETTINGS', data.settings);
207209

208-
if (isLogin() && data.settings.rememberMe) {
209-
var dataToStore = {
210-
keypair: data.keypair,
211-
pubkey: data.pubkey
212-
};
210+
if (!options || options.settings) {
211+
localStorage.setObject('CESIUM_SETTINGS', data.settings);
212+
// Send event when settings changed
213+
$rootScope.$broadcast(events.SETTINGS);
214+
}
213215

214-
if (data.tx && data.tx.pendings && data.tx.pendings.length>0) {
215-
var pendings = data.tx.pendings.reduce(function(res, tx){
216-
return tx.time ? res.concat({
217-
amount: tx.amount,
218-
time: tx.time,
219-
hash: tx.hash
220-
}) : res;
221-
}, []);
222-
if (pendings.length) {
223-
dataToStore.tx = {
224-
pendings: pendings
225-
};
216+
if (!options || options.data) {
217+
if (isLogin() && data.settings.rememberMe) {
218+
var dataToStore = {
219+
keypair: data.keypair,
220+
pubkey: data.pubkey
221+
};
222+
223+
if (data.tx && data.tx.pendings && data.tx.pendings.length>0) {
224+
var pendings = data.tx.pendings.reduce(function(res, tx){
225+
return tx.time ? res.concat({
226+
amount: tx.amount,
227+
time: tx.time,
228+
hash: tx.hash
229+
}) : res;
230+
}, []);
231+
if (pendings.length) {
232+
dataToStore.tx = {
233+
pendings: pendings
234+
};
235+
}
226236
}
227-
}
228237

229-
localStorage.setObject('CESIUM_DATA', dataToStore);
230-
}
231-
else {
232-
localStorage.setObject('CESIUM_DATA', null);
238+
localStorage.setObject('CESIUM_DATA', dataToStore);
239+
}
240+
else {
241+
localStorage.setObject('CESIUM_DATA', null);
242+
}
233243
}
234244
}
235245
else {
236246
localStorage.setObject('CESIUM_SETTINGS', null);
237247
localStorage.setObject('CESIUM_DATA', null);
248+
// Send event when settings changed
249+
$rootScope.$broadcast(events.SETTINGS);
238250
}
251+
239252
},
240253

241254
restore = function() {
@@ -1059,7 +1072,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser
10591072
toJson: toJson,
10601073
fromJson: fromJson,
10611074
defaultSettings: defaultSettings,
1062-
api: api
1075+
api: api,
1076+
events: events
10631077
};
10641078
};
10651079

www/plugins/es/i18n/locale-en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@
143143
"PROFILE_SAVED": "Profile saved"
144144
}
145145
},
146-
"SETTINGS": {
146+
"ES_SETTINGS": {
147147
"PLUGIN_NAME": "Registry and market place",
148148
"ENABLE_TOGGLE": "Enable extension ?",
149-
"ES_NODE": "Data node address",
150-
"ES_NODE_HELP": "server.domain.com:port",
149+
"NODE": "Data node address",
150+
"NODE_HELP": "server.domain.com:port",
151151
"POPUP_NODE": {
152152
"TITLE" : "Data Node",
153153
"HELP" : "Set the address of the node to use:"

www/plugins/es/js/controllers/common-controllers.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module('cesium.es.common.controllers', ['cesium.es.services'])
1+
angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.services'])
22

33
// Configure menu items
44
.config(function(PluginServiceProvider, APP_CONFIG) {
@@ -36,13 +36,19 @@ angular.module('cesium.es.common.controllers', ['cesium.es.services'])
3636
/**
3737
* Control menu extension
3838
*/
39-
function ESMenuExtendController($scope, PluginService, Wallet) {
39+
function ESMenuExtendController($scope, $rootScope, PluginService, Wallet, APP_CONFIG) {
4040
'ngInject';
4141
$scope.extensionPoint = PluginService.extensions.points.current.get();
4242

43-
$scope.es = Wallet.data.settings.plugins && Wallet.data.settings.plugins.es ? Wallet.data.settings.plugins.es : {
44-
enable: false
43+
$scope.refreshEnable = function() {
44+
$scope.enable = Wallet.data && Wallet.data.settings.plugins && Wallet.data.settings.plugins.es ?
45+
Wallet.data.settings.plugins.es.enable :
46+
!!APP_CONFIG.DUNITER_NODE_ES
4547
};
48+
49+
$rootScope.$on(Wallet.events.SETTINGS, $scope.refreshEnable);
50+
51+
$scope.refreshEnable();
4652
}
4753

4854
function ESPicturesEditController($scope, $ionicModal, Wallet, esMarket, UIUtils, $state, CryptoUtils, $q, $ionicPopup, Device, $timeout, ModalUtils) {

www/plugins/es/js/controllers/settings-controllers.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ angular.module('cesium.es.settings.controllers', ['cesium.es.services'])
3838
/*
3939
* Settings extend controller
4040
*/
41-
function ESExtendSettingsController ($scope, Wallet, PluginService, APP_CONFIG) {
41+
function ESExtendSettingsController ($scope, $rootScope, Wallet, PluginService, APP_CONFIG) {
42+
'ngInject';
4243

4344
$scope.extensionPoint = PluginService.extensions.points.current.get();
4445
$scope.enable = false;
@@ -59,20 +60,27 @@ function ESExtendSettingsController ($scope, Wallet, PluginService, APP_CONFIG)
5960
/*
6061
* Settings extend controller
6162
*/
62-
function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, $ionicHistory, UIUtils, APP_CONFIG, esHttp, esMarket,
63+
function ESPluginSettingsController ($scope, $rootScope, $q, $translate, $ionicPopup, $ionicHistory, UIUtils, APP_CONFIG, esHttp, esMarket,
6364
esRegistry, esUser, Wallet) {
65+
'ngInject';
6466

6567
$scope.formData = {};
68+
$scope.loading = true;
6669

6770
$scope.$on('$ionicView.enter', function(e, $state) {
68-
if (!$scope.formData.node && APP_CONFIG.DUNITER_NODE_ES) {
71+
if (!$scope.formData.node) {
6972
if (Wallet.data.settings && Wallet.data.settings.plugins && Wallet.data.settings.plugins.es) {
7073
angular.merge($scope.formData, Wallet.data.settings.plugins.es);
7174
}
7275
else {
7376
$scope.formData.enable = !!APP_CONFIG.DUNITER_NODE_ES;
77+
78+
}
79+
if (!$scope.formData.node) {
80+
$scope.formData.node = APP_CONFIG.DUNITER_NODE_ES;
7481
}
7582
}
83+
$scope.loading = false;
7684
});
7785

7886
$scope.setSettingsForm = function(settingsForm) {
@@ -155,11 +163,9 @@ function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, $ioni
155163

156164
$scope.onSettingsChanged = function() {
157165
if ($scope.loading) {
158-
$timeout(function() {
159-
$scope.onSettingsChanged();
160-
}, 200);
161166
return;
162167
}
168+
163169
$scope.loading = true;
164170

165171
if (!Wallet.data.settings.plugins) {
@@ -176,7 +182,7 @@ function ESPluginSettingsController ($scope, $q, $translate, $ionicPopup, $ioni
176182
esHttp.setEnable($scope.formData.enable);
177183
esUser.refreshListeners();
178184

179-
Wallet.store();
185+
Wallet.store({settings: true, data: false});
180186

181187
// Clean cache
182188
$ionicHistory.clearCache();

www/plugins/es/templates/menu_extend.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!-- Main section -->
3-
<ng-if ng-if="es.enable && extensionPoint === 'menu-main'">
3+
<ng-if ng-if="enable && extensionPoint === 'menu-main'">
44

55
<!-- professionals registry-->
66
<ion-item menu-close class="item item-icon-left" active-link="active"
@@ -18,7 +18,7 @@
1818
</ng-if>
1919

2020
<!-- User section -->
21-
<ng-if ng-if="es.enable && extensionPoint === 'menu-user'">
21+
<ng-if ng-if="enable && extensionPoint === 'menu-user'">
2222
<!-- user profile -->
2323
<ion-item menu-close class="item item-icon-left" active-link="active"
2424
ng-if="isLogin()"

0 commit comments

Comments
 (0)