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

[fix] ES: block search should always show last block, by default

parent 957fc2de
No related branches found
No related tags found
No related merge requests found
......@@ -15138,7 +15138,7 @@ div[dropzone] {
@media screen and (max-width: 991px) {
.modal iframe.iframe-license {
width: 100%;
height: 100%; } }
height: 78%; } }
 
@media screen and (min-width: 992px) {
.modal iframe.iframe-license {
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -191,6 +191,17 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht
};
})
// Display time in ms or seconds (see i18n label 'COMMON.EXECUTION_TIME')
.filter('formatDurationMs', function() {
return function(input) {
return input ? (
(input < 1000) ?
(input + 'ms') :
(input/1000 + 's')
) : '';
};
})
.filter('formatPeriod', function() {
return function(input) {
if (!input) {return null;}
......
......@@ -11,20 +11,19 @@ angular.module("cesium.config", [])
.constant("csConfig", {
"cacheTimeMs": 60000,
"fallbackLanguage": "en",
"rememberMe": false,
"rememberMe": true,
"showUDHistory": false,
"timeout": 10000,
"timeWarningExpireMembership": 5184000,
"timeWarningExpire": 7776000,
"logoutIlde": 600,
"useLocalStorage": false,
"useLocalStorage": true,
"useRelative": false,
"initPhase": false,
"expertMode": false,
"expertMode": true,
"decimalCount": 2,
"httpsMode": false,
"helptip": {
"enable": true,
"enable": false,
"installDocUrl": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md"
},
"license": {
......@@ -39,19 +38,19 @@ angular.module("cesium.config", [])
"es": {
"enable": true,
"askEnable": false,
"host": "g1.data.duniter.fr",
"port": "443",
"notifications": {
"txSent": true,
"txReceived": true,
"certSent": true,
"certReceived": true
}
"host": "g1.data.duniter.fr",
"port": "443",
},
"graph": {
"enable": true
},
"neo4j": {
"enable": true
}
},
"version": "0.12.5",
"build": "2017-05-18T16:10:51.026Z",
"build": "2017-05-19T08:58:22.076Z",
"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
})
;
\ No newline at end of file
;
......@@ -254,6 +254,9 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho
var notFirstEmpty = (index !== 0) || (offset !== 0);
var previousNotEmptyOrSameDay = !previousEmptyBlockDay || (previousEmptyBlockDay == blockDay);
block.compacted = notFirstEmpty && previousNotEmptyOrSameDay;
if (block.number > 20751) {
console.log(block.number, block.compacted);
}
previousEmptyBlockDay = blockDay;
}
else {
......@@ -273,7 +276,7 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho
$scope.search.results = $scope.search.results.concat(res);
}
$scope.search.hasMore = total && $scope.search.results.length < total;
$scope.search.total = total;
$scope.search.total = total || $scope.search.total;
$scope.smallscreen = UIUtils.screen.isSmall();
......@@ -385,7 +388,7 @@ function BlockLookupController($scope, $timeout, $focus, $filter, $state, $ancho
$scope.toggleCompactMode = function() {
$scope.compactMode = !$scope.compactMode;
$scope.doDisplayResult($scope.search.results, 0, $scope.search.results.length);
$scope.doDisplayResult($scope.search.results, 0, $scope.search.total/*keep previous total*/);
// Workaround to re-initialized the <ion-infinite-loop>
if (!$scope.search.hasMore && $scope.search.results.length && $scope.search.type == 'last') {
......
......@@ -106,6 +106,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
"number": "desc"
};
}
request.excludeCurrent = (from == 0);
promise = esBlockchain.block.search($scope.currency, request);
}
......@@ -121,22 +122,26 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
else { // default sort
request.sort = "number:desc";
}
request.excludeCurrent = true;
promise = esBlockchain.block.searchText($scope.currency, $scope.search.text, request);
}
var time = new Date().getTime();
return promise
.then(function(result) {
// Apply transformation need by UI (e.g add avatar and name...)
return $scope.doPrepareResult(result.hits)
.then(function() {
// remove 'name' if
return result;
});
})
.then(function(result) {
$scope.showPubkey = ($scope.search.sort == 'issuer');
$scope.search.took = (new Date().getTime() - time);
$scope.doDisplayResult(result.hits, from, result.total);
// Compute time only once (on first page)
$scope.search.took = (from === 0) ? (new Date().getTime() - time) : $scope.search.took;
// Keep previous total, when already computed (because of current, that is excluded only in the first page)
var total = (from === 0) ? result.total : $scope.search.total;
$scope.doDisplayResult(result.hits, from, total);
$scope.search.loading = false;
})
.catch(function(err) {
......
......@@ -71,14 +71,6 @@ angular.module('cesium.es.blockchain.services', ['cesium.services', 'cesium.es.h
hasExcludedCurrent ? res.hits.total-1 : res.hits.total) : 0
};
// Fill avatar
if (result.hits.length && options.fillAvatar) {
return esUser.profile.fillAvatars(result.hits, 'issuer')
.then(function() {
return result;
});
}
return result;
};
......
<a name="block-{{:rebind:block.number}}"></a>
<ion-item id="block-{{:rebind:block.number}}"
class="item item-icon-left item-block "
ng-class="{'ink': !block.empty||!block.compacted, 'item-block-empty': block.empty, 'compacted': block.compacted && compactMode, ionItemClass: true}"
class="item item-icon-left item-block {{::ionItemClass}}"
ng-class="{'ink': !block.empty||!block.compacted, 'item-block-empty': block.empty, 'compacted': block.compacted && compactMode}"
ng-click="selectBlock(block)">
<i class="icon ion-cube stable" ng-if=":rebind:(!block.empty && !block.avatar)"></i>
......
<a name="block-{{::block.number}}"></a>
<div id="block-{{::block.number}}"
ng-if="!block.hide"
class="item item-block item-icon-left item-block-empty"
ng-class=":rebind:{'compacted': compactMode, ionItemClass: true}"
ng-class="{'compacted': block.compacted && compactMode}"
ng-click="selectBlock(block)"
>
<div class="row no-padding" ng-if=":rebind:!compactMode">
<div class="row no-padding" ng-if=":rebind:!block.compacted || !compactMode">
<div class="col">
<h3 class="gray">
<i class="ion-clock"></i>
......
<ion-item id="block-{{::block.number}}"
class="item item-block item-icon-left ink"
ng-class="::ionItemClass"
class="item item-block item-icon-left ink {{::ionItemClass}}"
ng-class="{{::ionItemClass}}"
ng-click="selectBlock(block)">
<i class="icon ion-cube stable" ng-if=":rebind:!block.avatar"></i>
......
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