diff --git a/www/js/controllers/blockchain-controllers.js b/www/js/controllers/blockchain-controllers.js index e74e5632ad1f58a71573d51aaba93dc168eb2145..f557c7b41f1b90945a6671ebd3b4b0e55a10babc 100644 --- a/www/js/controllers/blockchain-controllers.js +++ b/www/js/controllers/blockchain-controllers.js @@ -81,7 +81,7 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho $scope.entered = false; $scope.searchTextId = null; $scope.ionItemClass = 'item-border-large'; - $scope.defaultSizeLimit = 50; + $scope.defaultSizeLimit = UIUtils.screen.isSmall() ? 50 : 100; /** * Enter into the view @@ -316,15 +316,14 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho .then(function() { $scope.search.results = $scope.search.results || []; - // Prepare the new block (and previous last block) if (!$scope.search.results.length) { + // Prepare the new block, then add it to result $scope.doPrepareResult([block]); console.debug('[ES] [blockchain] new block #{0} received (by websocket)'.format(block.number)); $scope.search.total++; $scope.search.results.push(block); } else { - $scope.doPrepareResult([block, $scope.search.results[0]]); // Find existing block, by number var existingBlock = _.findWhere($scope.search.results, {number: block.number}); @@ -332,11 +331,17 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho if (existingBlock) { if (existingBlock.hash != block.hash) { console.debug('[ES] [blockchain] block #{0} updated (by websocket)'.format(block.number)); + // Prepare the new block, and refresh the previous latest block (could be compacted) + $scope.doPrepareResult([block, $scope.search.results[0]]); angular.copy(block, existingBlock); + $scope.$broadcast('$$rebind::rebind'); // notify binder } } else { console.debug('[ES] [blockchain] new block #{0} received (by websocket)'.format(block.number)); + // Prepare the new block, and refresh the previous latest block (could be compacted) + $scope.doPrepareResult([block, $scope.search.results[0]]); + // Insert at index 0 $scope.search.total++; $scope.search.results.splice(0, 0, block); } diff --git a/www/js/controllers/network-controllers.js b/www/js/controllers/network-controllers.js index 874e5fa4fc6cf00feb7a375dce755da71569bcd5..fcfa4e0606ef9376e276f5a6b1765846e988ce8d 100644 --- a/www/js/controllers/network-controllers.js +++ b/www/js/controllers/network-controllers.js @@ -52,7 +52,6 @@ function NetworkLookupController($scope, $timeout, $state, $ionicHistory, $ionic sort : undefined, asc: true }; - $scope.mainBlock = {}; /** * Enter in view @@ -66,14 +65,11 @@ function NetworkLookupController($scope, $timeout, $state, $ionicHistory, $ionic $scope.node = !BMA.node.same(currency.peer.host, currency.peer.port) ? BMA.instance(currency.peer.host, currency.peer.port) : BMA; if (state && state.stateParams) { - if (state.stateParams.type && ( - state.stateParams.type === 'mirror' || - state.stateParams.type === 'member' || - state.stateParams.type === 'offline')) { + if (state.stateParams.type && ['mirror', 'member', 'offline'].indexOf(state.stateParams.type) != -1) { $scope.search.type = state.stateParams.type; } if (state.stateParams.expert) { - $scope.expertMode = state.stateParams.expert; + $scope.expertMode = (state.stateParams.expert == 'true'); } } $scope.load(); @@ -133,10 +129,6 @@ function NetworkLookupController($scope, $timeout, $state, $ionicHistory, $ionic }, 100); } }); - - csNetwork.api.data.on.mainBlockChanged($scope, function(mainBlock){ - $scope.mainBlock = mainBlock; - }); } // Show help tip diff --git a/www/js/entities/block.js b/www/js/entities/block.js index fd3658fee8f2918d55a75dd95bf1abcdcb623ff3..2a9e51dab9a37c1e259d707130a46df34642ec08 100644 --- a/www/js/entities/block.js +++ b/www/js/entities/block.js @@ -6,11 +6,13 @@ function Block(json) { var that = this; - Object.keys(json).forEach(function (key) { + /*Object.keys(json).forEach(function (key) { + that[key] = json[key]; + });*/ + ["currency", "issuer", "medianTime", "number", "dividend", "membersCount", "hash", "identities", "joiners", "actives", "leavers", "revoked", "excluded", "certifications", "transactions"].forEach(function (key) { that[key] = json[key]; }); - that.identitiesCount = that.identities ? that.identities.length : 0; that.joinersCount = that.joiners ? that.joiners.length : 0; that.activesCount = that.actives ? that.actives.length : 0; diff --git a/www/js/entities/peer.js b/www/js/entities/peer.js index 5057191a74cf576b358c52fe65fcb82747a7fe4f..17eb82bb81e392e168f107218a87bd86863d7b3b 100644 --- a/www/js/entities/peer.js +++ b/www/js/entities/peer.js @@ -14,7 +14,10 @@ function Peer(json) { Peer.prototype.regex = { + BMA: /^BASIC_MERKLED_API[ ]?/, + BMAS: /^BMAS[ ]?/, BMA_REGEXP: /^BASIC_MERKLED_API([ ]+([a-z_][a-z0-9-_.]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/, + BMAS_REGEXP: /^BMAS([ ]+([a-z_][a-z0-9-_.]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/, LOCAL_IP_ADDRESS: /^127[.]0[.]0.|192[.]168[.]|10[.]0[.]0[.]|172[.]16[.]/ }; @@ -73,8 +76,8 @@ Peer.prototype.getEndpoints = function(regex) { }; Peer.prototype.hasEndpoint = function(endpoint){ - endpoint = '^' + endpoint; - var regExp = new RegExp(endpoint); + //console.debug('testing if hasEndpoint:' + endpoint); + var regExp = this.regex[endpoint] || new RegExp('^' + endpoint); var endpoints = this.getEndpoints(regExp); if (!endpoints.length) return false; else return true; diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index 918593c55b489b5f93e9c4a1638530bdb5112e1b..e594514b2821e94a2534d69cf0d1183c1b5bd4ed 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -20,7 +20,8 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce // duniter://[uid]:[pubkey]@[host]:[port] URI_WITH_AT: "duniter://(?:([A-Za-z0-9_-]+):)?([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})@([a-zA-Z0-9-.]+.[ a-zA-Z0-9-_:/;*?!^\\+=@&~#|<>%.]+)", URI_WITH_PATH: "duniter://([a-zA-Z0-9-.]+.[a-zA-Z0-9-_:.]+)/([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})(?:/([A-Za-z0-9_-]+))?", - BMA_ENDPOINT: "BASIC_MERKLED_API( ([a-z_][a-z0-9-_.]*))?( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))" + BMA_ENDPOINT: "BASIC_MERKLED_API( ([a-z_][a-z0-9-_.]*))?( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))", + BMAS_ENDPOINT: "BMAS( ([a-z_][a-z0-9-_.]*))?( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))" }, errorCodes = { REVOCATION_ALREADY_REGISTERED: 1002, @@ -52,7 +53,8 @@ angular.module('cesium.bma.services', ['ngResource', 'cesium.http.services', 'ce PUBKEY: exact(regex.PUBKEY), CURRENCY: exact(regex.CURRENCY), URI: exact(regex.URI), - BMA_ENDPOINT: exact(regex.BMA_ENDPOINT) + BMA_ENDPOINT: exact(regex.BMA_ENDPOINT), + BMAS_ENDPOINT: exact(regex.BMAS_ENDPOINT) }, node: { server: csHttp.getServer(host, port), diff --git a/www/templates/blockchain/item_block.html b/www/templates/blockchain/item_block.html index 21f20137d12cd6cc40fa8f0263230746d3dca1d0..d8ad95ed37bb97e0bb4e3a36ae32e3177edb21ce 100644 --- a/www/templates/blockchain/item_block.html +++ b/www/templates/blockchain/item_block.html @@ -1,38 +1,38 @@ -<a name="block-{{::block.number}}"></a> -<ion-item id="block-{{::block.number}}" +<a name="block-{{:rebind:block.number}}"></a> +<ion-item id="block-{{:rebind:block.number}}" class="item item-icon-left item-block {{ionItemClass}}" ng-class="{'item-block-empty': block.empty, 'compacted': block.compacted && compactMode}" ng-click="selectBlock(block)"> - <i class="icon ion-cube stable" ng-if="!block.empty"></i> + <i class="icon ion-cube stable" ng-if=":rebind:!block.empty"></i> - <div class="row no-padding" ng-if="!block.compacted || !compactMode"> + <div class="row no-padding" ng-if=":rebind:!block.compacted || !compactMode"> <div class="col"> <h4 ng-class="{'gray': block.compacted, 'dark': !block.compacted}"> <i class="ion-clock"></i> - {{block.medianTime|formatDate}} + {{:rebind:block.medianTime|formatDate}} </h4> <h4 ng-if="!block.empty"> <!-- joiners/leavers --> - <ng-if ng-if="block.joinersCount||(block.excludedCount-block.revokedCount)"> + <ng-if ng-if=":rebind:block.joinersCount||(block.excludedCount-block.revokedCount)"> <i class="dark ion-person"></i> - <span class="dark" ng-if="block.joinersCount">+{{block.joinersCount}}</span> - <span class="dark" ng-if="block.excludedCount">-{{block.excludedCount-block.revokedCount}}</span> + <span class="dark" ng-if=":rebind:block.joinersCount">+{{:rebind:block.joinersCount}}</span> + <span class="dark" ng-if=":rebind:block.excludedCount">-{{:rebind:block.excludedCount-block.revokedCount}}</span> </ng-if> - <span class="dark" ng-if="block.revokedCount" class="assertive"><i class="ion-minus-circled"></i> {{block.revokedCount}} </span> - <span class="dark" ng-if="block.activesCount" class="gray"><i class="gray ion-refresh"></i> {{block.activesCount}} </span> - <span class="dark" ng-if="block.certificationsCount"><i class="ion-ribbon-a"></i> {{block.certificationsCount}} </span> - <span class="dark" ng-if="block.dividend" class="gray"><i class="gray ion-arrow-up-c"></i> {{'COMMON.UD'|translate}} </span> - <span class="dark" ng-if="block.transactionsCount"><i class="ion-card"> {{block.transactionsCount}}</i></span> + <span class="dark" ng-if=":rebind:block.revokedCount" class="assertive"><i class="ion-minus-circled"></i> {{:rebind:block.revokedCount}} </span> + <span class="dark" ng-if=":rebind:block.activesCount" class="gray"><i class="gray ion-refresh"></i> {{:rebind:block.activesCount}} </span> + <span class="dark" ng-if=":rebind:block.certificationsCount"><i class="ion-ribbon-a"></i> {{:rebind:block.certificationsCount}} </span> + <span class="dark" ng-if=":rebind:block.dividend" class="gray"><i class="gray ion-arrow-up-c"></i> {{'COMMON.UD'|translate}} </span> + <span class="dark" ng-if=":rebind:block.transactionsCount"><i class="ion-card"> {{:rebind:block.transactionsCount}}</i></span> </h4> </div> <div class="col col-33 positive hidden-md"> - <h4><i class="ion-person"></i> {{block.name||block.uid}}</h4> + <h4><i class="ion-person"></i> {{:rebind:block.name||block.uid}}</h4> </div> <div class="col col-20"> - <span class="badge " ng-class="{'badge-balanced': !$index , 'badge-calm': $index && !block.compacted && !block.empty}">{{block.number}}</span> + <span class="badge " ng-class="{'badge-balanced': !$index , 'badge-calm': $index && !block.compacted && !block.empty}">{{:rebind:block.number}}</span> </div> </div> diff --git a/www/templates/blockchain/list_blocks.html b/www/templates/blockchain/list_blocks.html index 8139f828f9c06ab034310963acbfe5c99759eb14..c5a1a95388a695e278d7a3d7238a443c49067e68 100644 --- a/www/templates/blockchain/list_blocks.html +++ b/www/templates/blockchain/list_blocks.html @@ -17,19 +17,19 @@ <ion-spinner icon="android"></ion-spinner> </div> - <ion-list class="animate-ripple padding padding-xs"> + <ion-list class="animate-ripple padding padding-xs" bind-notifier="{rebind: search.results.length}"> <div class="padding gray" ng-if="!search.loading && !search.results.length" translate> BLOCKCHAIN.LOOKUP.NO_BLOCK </div> <!-- blocks --> - <ng-repeat ng-repeat="block in search.results" + <ng-repeat ng-repeat="block in :rebind:search.results" ng-include="'templates/blockchain/item_block.html'"> </ng-repeat> </ion-list> <ion-infinite-scroll ng-if="search.hasMore" - spinner="android" + icon="android" on-infinite="showMore()" distance="1%"> </ion-infinite-scroll> diff --git a/www/templates/network/items_peers.html b/www/templates/network/items_peers.html index 315e941e99e91b78506639579a95f6b32a8759d6..316ec51aee7c99189107614f13eaaf9d4dc2aea3 100644 --- a/www/templates/network/items_peers.html +++ b/www/templates/network/items_peers.html @@ -1,3 +1,5 @@ +<bind-notifier bind-notifier="{ rebind:search.results}"> + <div class="item row row-header hidden-xs hidden-sm" ng-if="expertMode"> <a class="col col-header no-padding dark" ng-click="toggleSort('uid')"> <cs-sort-icon asc="search.asc" sort="search.sort" toggle="'uid'"></cs-sort-icon> @@ -19,7 +21,7 @@ </a> </div> - <div ng-repeat="peer in search.results track by peer.id" + <div ng-repeat="peer in :rebind:search.results track by $index" class="item peer-item item-icon-left {{::ionItemClass}}" ng-class="{ assertive: !peer.online, balanced: (peer.online && peer.hasMainConsensusBlock), energized: (peer.online && !peer.hasMainConsensusBlock)}" id="helptip-network-peer-{{$index}}" @@ -33,7 +35,6 @@ <h3> <span ng-if="peer.uid" ui-sref="app.wot_view_identity({pubkey: peer.pubkey, uid: peer.uid})"> - <!-- <i class="ion-person"></i>--> {{peer.name||peer.uid}} </span> <span ng-if="!peer.uid"> @@ -42,13 +43,16 @@ <span class="gray">{{peer.dns && ' | ' + peer.dns}}</span></h3> <h4>{{peer.server}}</h4> </div> - <div class="col col-15 no-padding text-center" ng-if="expertMode && peer.hasEndpoint('ES_USER_API')"> - <h3 class="hidden-xs hidden-sm"> + <div class="col col-15 no-padding text-center" ng-if="::expertMode"> + <div class="hidden-xs hidden-sm" ng-if=":rebind:peer.hasEndpoint('ES_USER_API')"> <i class="ion-es-user-api"></i> <b class="ion-plus gray" style="position: relative; left: -14px; top:-17px; font-size : 16px;"></b> - </h3> + </div> + <div class="hidden-xs hidden-sm" ng-if=":rebind:peer.hasEndpoint('BMAS')"> + <i class="ion-locked"></i> <small>SSL</small> + </div> </div> - <div class="col col-20 no-padding text-center" ng-if="expertMode && search.type != 'offline'"> + <div class="col col-20 no-padding text-center" ng-if="::expertMode && search.type != 'offline'"> <h3 class="hidden-sm hidden-xs"> <span ng-if="peer.uid"><i class="ion-lock-combination"></i>{{peer.difficulty||'?'}}</span> <span ng-if="!peer.uid" translate>PEER.MIRROR</span> @@ -57,9 +61,9 @@ </div> <div class="col col-20 no-padding text-center"> <span id="helptip-network-peer-{{$index}}-block" - class="badge" ng-class="{ 'badge-balanced': peer.hasMainConsensusBlock, 'badge-energized': peer.hasConsensusBlock }">{{peer.currentNumber}}</span> + class="badge" ng-class="{'badge-balanced': peer.hasMainConsensusBlock, 'badge-energized': peer.hasConsensusBlock }">{{peer.currentNumber}}</span> </div> </div> </div> -</div> +</bind-notifier>