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

- Disable cache on network peers BMA

 - Fix tabs padding on smal screens
parent 55895baa
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -5,7 +5,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
.factory('BMA', function($q, csSettings, csHttp, $rootScope) { .factory('BMA', function($q, csSettings, csHttp, $rootScope) {
'ngInject'; 'ngInject';
function factory(host, port) { function factory(host, port, cacheEnable) {
var var
errorCodes = { errorCodes = {
...@@ -48,7 +48,9 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -48,7 +48,9 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
return host2 == host && ((!port && !port2) ||(port == port2)); return host2 == host && ((!port && !port2) ||(port == port2));
} }
var getMembers = csHttp.getWithCache(host, port, '/wot/members'); var getMembers = cacheEnable ?
csHttp.getWithCache(host, port, '/wot/members') :
csHttp.get(host, port, '/wot/members');
function getMemberUidsByPubkey() { function getMemberUidsByPubkey() {
return getMembers() return getMembers()
...@@ -71,8 +73,12 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -71,8 +73,12 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
}); });
} }
var getBlockchainWithUd = csHttp.getWithCache(host, port, '/blockchain/with/ud', csHttp.cache.SHORT); var getBlockchainWithUd = cacheEnable ?
var getBlockchainBlock = csHttp.getWithCache(host, port, '/blockchain/block/:block', csHttp.cache.SHORT); csHttp.getWithCache(host, port, '/blockchain/with/ud', csHttp.cache.SHORT) :
csHttp.get(host, port, '/blockchain/with/ud');
var getBlockchainBlock = cacheEnable ?
csHttp.getWithCache(host, port, '/blockchain/block/:block', csHttp.cache.SHORT) :
csHttp.get(host, port, '/blockchain/block/:block');
function getBlockchainLastUd() { function getBlockchainLastUd() {
return getBlockchainWithUd() return getBlockchainWithUd()
...@@ -220,7 +226,9 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -220,7 +226,9 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
peers: csHttp.get(host, port, '/network/peers') peers: csHttp.get(host, port, '/network/peers')
}, },
blockchain: { blockchain: {
parameters: csHttp.getWithCache(host, port, '/blockchain/parameters', csHttp.cache.LONG), parameters: cacheEnable ?
csHttp.getWithCache(host, port, '/blockchain/parameters', csHttp.cache.LONG) :
csHttp.get(host, port, '/blockchain/parameters'),
current: csHttp.get(host, port, '/blockchain/current'), current: csHttp.get(host, port, '/blockchain/current'),
block: getBlockchainBlock, block: getBlockchainBlock,
membership: csHttp.post(host, port, '/blockchain/membership'), membership: csHttp.post(host, port, '/blockchain/membership'),
...@@ -236,9 +244,13 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -236,9 +244,13 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
process: csHttp.post(host, port, '/tx/process'), process: csHttp.post(host, port, '/tx/process'),
history: { history: {
all: csHttp.get(host, port, '/tx/history/:pubkey'), all: csHttp.get(host, port, '/tx/history/:pubkey'),
times: csHttp.getWithCache(host, port, '/tx/history/:pubkey/times/:from/:to'), times: cacheEnable ?
csHttp.getWithCache(host, port, '/tx/history/:pubkey/times/:from/:to') :
csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'),
timesNoCache: csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'), timesNoCache: csHttp.get(host, port, '/tx/history/:pubkey/times/:from/:to'),
blocks: csHttp.getWithCache(host, port, '/tx/history/:pubkey/blocks/:from/:to'), blocks: cacheEnable ?
csHttp.getWithCache(host, port, '/tx/history/:pubkey/blocks/:from/:to') :
csHttp.get(host, port, '/tx/history/:pubkey/blocks/:from/:to'),
pending: csHttp.get(host, port, '/tx/history/:pubkey/pending') pending: csHttp.get(host, port, '/tx/history/:pubkey/pending')
} }
}, },
...@@ -269,7 +281,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -269,7 +281,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
}; };
} }
var service = factory(csSettings.data.node.host, csSettings.data.node.port); var service = factory(csSettings.data.node.host, csSettings.data.node.port, true /*cache*/);
service.instance = factory; service.instance = factory;
// Listen settings changes // Listen settings changes
...@@ -277,7 +289,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce ...@@ -277,7 +289,7 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce
var nodeServer = csHttp.getServer(settings.node.host, settings.node.port); var nodeServer = csHttp.getServer(settings.node.host, settings.node.port);
if (nodeServer != service.node.server) { if (nodeServer != service.node.server) {
var newService = factory(settings.node.host, settings.node.port); var newService = factory(settings.node.host, settings.node.port, true /*cache*/);
service.copy(newService); // reload service service.copy(newService); // reload service
} }
......
...@@ -99,7 +99,7 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se ...@@ -99,7 +99,7 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se
peer.server = server; peer.server = server;
peer.blockNumber = peer.block.replace(/-.+$/, ''); peer.blockNumber = peer.block.replace(/-.+$/, '');
data.newPeers.push(peer); data.newPeers.push(peer);
var node = BMA.instance(peer.getHost(), peer.getPort()); var node = BMA.instance(peer.getHost(), peer.getPort(), false);
return node.blockchain.current() return node.blockchain.current()
.then(function(block){ .then(function(block){
peer.current = block; peer.current = block;
...@@ -130,18 +130,25 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se ...@@ -130,18 +130,25 @@ angular.module('cesium.network.services', ['ngResource', 'ngApi', 'cesium.bma.se
var resolved = false; var resolved = false;
interval = $interval(function() { interval = $interval(function() {
console.debug('[network] check if finish...');
if (data.newPeers.length) { if (data.newPeers.length) {
data.peers = data.peers.concat(data.newPeers.splice(0)); data.peers = data.peers.concat(data.newPeers.splice(0));
console.debug('[network] New peers found: sort and ad them to result...');
sortPeers(); sortPeers();
if (!waitAllPeers) { if (!waitAllPeers) {
resolved = true; console.debug('[network] Returning to main process (peers will continue to be updating in background)');
resolve(data.peers); if (!resolved) {
resolved = true;
resolve(data.peers);
}
} }
} else if (data.updatingPeers && !data.searchingPeersOnNetwork) { } else if (data.updatingPeers && !data.searchingPeersOnNetwork) {
console.debug('[network] Finish : all peers found. Stopping new peers check.');
// The peer lookup end, we can make a clean final report // The peer lookup end, we can make a clean final report
sortPeers(); sortPeers();
data.updatingPeers = false; data.updatingPeers = false;
if (!resolved) { if (!resolved) {
console.debug('[network] refresh peer finished');
resolve(data.peers); resolve(data.peers);
} }
$interval.cancel(interval); $interval.cancel(interval);
......
...@@ -12,20 +12,22 @@ ...@@ -12,20 +12,22 @@
</ion-nav-buttons> </ion-nav-buttons>
<ion-content scroll="false"> <ion-content scroll="false">
<ion-tabs class="tabs-icon-top tabs-positive has-header"> <ion-tabs class="tabs-icon-top tabs-positive">
<ion-tab title="{{'CURRENCY.VIEW.TAB_CURRENCY'|translate}}" icon="ion-stats-bars"> <ion-tab title="{{'CURRENCY.VIEW.TAB_CURRENCY'|translate}}" icon="ion-stats-bars">
<ion-nav-view name="currency-tab"/> <ion-nav-view name="currency-tab">
<ion-content> <ion-content>
<ng-include src="'templates/currency/tabs/view_parameters.html'"/> <ng-include src="'templates/currency/tabs/view_parameters.html'"/>
</ion-content> </ion-content>
</ion-nav-view>
</ion-tab> </ion-tab>
<ion-tab title="{{'CURRENCY.VIEW.TAB_NETWORK'|translate}}" icon="ion-network" > <ion-tab title="{{'CURRENCY.VIEW.TAB_NETWORK'|translate}}" icon="ion-network" >
<ion-nav-view name="network-tab"/> <ion-nav-view name="network-tab">
<ion-content class="padding no-padding-xs"> <ion-content>
<ng-include src="'templates/currency/tabs/view_network.html'"/> <ng-include src="'templates/currency/tabs/view_network.html'"/>
</ion-content> </ion-content>
</ion-nav-view>
</ion-tab> </ion-tab>
</ion-tab> </ion-tab>
......
...@@ -16,25 +16,27 @@ ...@@ -16,25 +16,27 @@
<ion-tab title="{{'WOT.CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-b" <ion-tab title="{{'WOT.CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-b"
on-select="setShowCertifications(true)" on-select="setShowCertifications(true)"
on-deselect="setShowCertifications(false)"> on-deselect="setShowCertifications(false)">
<ion-nav-view name="currency-tab"/> <ion-nav-view name="currency-tab">
<ion-content> <ion-content>
<div class="center padding" ng-if="loading"> <div class="center padding" ng-if="loading">
<ion-spinner icon="android"></ion-spinner> <ion-spinner icon="android"></ion-spinner>
</div> </div>
<ng-include src="'templates/wot/tabs/view_certifications.html'"/> <ng-include src="'templates/wot/tabs/view_certifications.html'"/>
</ion-content> </ion-content>
</ion-nav-view>
</ion-tab> </ion-tab>
<ion-tab title="{{'WOT.GIVEN_CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-a" <ion-tab title="{{'WOT.GIVEN_CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-a"
on-select="setShowGivenCertifications(true)" on-select="setShowGivenCertifications(true)"
on-deselect="setShowGivenCertifications(false)"> on-deselect="setShowGivenCertifications(false)">
<ion-nav-view name="network-tab"/> <ion-nav-view name="network-tab">
<ion-content class="padding no-padding-xs"> <ion-content>
<div class="center padding" ng-if="loading"> <div class="center padding" ng-if="loading">
<ion-spinner icon="android"></ion-spinner> <ion-spinner icon="android"></ion-spinner>
</div> </div>
<ng-include src="'templates/wot/tabs/view_given_certifications.html'"/> <ng-include src="'templates/wot/tabs/view_given_certifications.html'"/>
</ion-content> </ion-content>
</ion-nav-view>
</ion-tab> </ion-tab>
</ion-tab> </ion-tab>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment