Skip to content
Snippets Groups Projects
Commit 860b834e authored by ArnaudCerisier's avatar ArnaudCerisier
Browse files

Before merge

parent 71798f70
No related branches found
No related tags found
1 merge request!461[fix] Evolution of the search in the network tab
...@@ -185,7 +185,11 @@ ...@@ -185,7 +185,11 @@
"HEADER_MEDIAN_TIME": "Date / Heure", "HEADER_MEDIAN_TIME": "Date / Heure",
"HEADER_BLOCK": "Bloc #", "HEADER_BLOCK": "Bloc #",
"HEADER_ISSUER": "Noeud émetteur", "HEADER_ISSUER": "Noeud émetteur",
"BTN_LAST": "Derniers blocs" "BTN_LAST": "Derniers blocs",
"TX_SEARCH_FILTER": {
"PERIOD": "Transactions effectuées entre le {{params[1]|formatDate}} et le {{params[2]|formatDate}}",
"PUBKEY": "Clé publique : {{params[1]|formatPubkey}}"
}
}, },
"ERROR": { "ERROR": {
"SEARCH_BLOCKS_FAILED": "Erreur de la recherche des blocs." "SEARCH_BLOCKS_FAILED": "Erreur de la recherche des blocs."
...@@ -294,10 +298,6 @@ ...@@ -294,10 +298,6 @@
"RECORD_REMOVED" : "Annonce supprimée" "RECORD_REMOVED" : "Annonce supprimée"
} }
}, },
"TX_SEARCH": {
"PERIOD": "Transactions effectuées entre le {{date.startDate|formatDate}} et le {{date.endDate|formatDate}}",
"PUBKEY": "Clé publique : {{pubkey|formatPubkey}}"
},
"REGISTRY": { "REGISTRY": {
"CATEGORY": "Activité principale", "CATEGORY": "Activité principale",
"GENERAL_DIVIDER": "Informations générales", "GENERAL_DIVIDER": "Informations générales",
......
...@@ -53,6 +53,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU ...@@ -53,6 +53,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
} }
$scope.search.type = 'text'; $scope.search.type = 'text';
$scope.processSearchText($scope.search.text);
$scope.doSearch(); $scope.doSearch();
$ionicHistory.nextViewOptions({ $ionicHistory.nextViewOptions({
...@@ -85,69 +86,39 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU ...@@ -85,69 +86,39 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
}; };
// Cancel search filter // Cancel search filter
$scope.itemRemove = function(itemType) { $scope.itemRemove = function(item) {
if(itemType === $scope.dynamicSearchFilter[0][0]) $scope.newQuery = $scope.query.replace(item.query, '');
$scope.dynamicSearchFilter[0][3] = false;
else if(itemType === $scope.dynamicSearchFilter[1][0])
$scope.dynamicSearchFilter[0][3] = false;
$scope.newQuery = $scope.query.replace(itemType, '');
$scope.newQuery = $scope.newQuery.replace(/^ AND /, ''); $scope.newQuery = $scope.newQuery.replace(/^ AND /, '');
$scope.newQuery = $scope.newQuery.replace(/ AND $/, ''); $scope.newQuery = $scope.newQuery.replace(/ AND $/, '');
$scope.searchFilter.item = null;
$scope.search.text = $scope.newQuery; $scope.search.text = $scope.newQuery;
$scope.doSearchText(); $scope.doSearchText();
}; };
$scope.filterConstructor = function() { $scope.processSearchText = function(text) {
$scope.dynamicSearchFilter = new Array(2);
for (var i = 0; i < $scope.dynamicSearchFilter.length; i++) { //exports.block.parseSearchText = function(text) {
$scope.dynamicSearchFilter[i] = new Array(5) var filterRegexps = {
} PERIOD: /_exists_:transactions AND medianTime:>=([0-9]+) AND medianTime:<([0-9]+)/,
PUBKEY: /issuer:([a-zA-Z0-9]+)/
};
/* $scope.search.filters = _.keys(filterRegexps).reduce(function(res, filterType){
+-----------+--------+ var matches = filterRegexps[filterType].exec(text);
| period | pubkey |
+--------+-----------+--------+
| regex | | |
+--------+-----------+--------+
| query | | |
+--------+-----------+--------+
| key | | |
+--------+-----------+--------+
| params | startDate | pubkey |
+--------+-----------+--------+
| | endDate | |
+--------+-----------+--------+
*/
//Period
$scope.dynamicSearchFilter[0][0] = /_exists_:transactions AND medianTime:>=([0-9]+) AND medianTime:<([0-9]+)/;
var matches = $scope.search.text.match($scope.dynamicSearchFilter[0][0]);
if (matches){
$scope.dynamicSearchFilter[0][1] = matches[0];
$scope.dynamicSearchFilter[0][2] = 'TX_SEARCH.PERIOD';
$scope.dynamicSearchFilter[0][3] = true;
$scope.dynamicSearchFilter[0][4] = matches[1];
$scope.dynamicSearchFilter[0][5] = matches[2];
}
//Pubkey
$scope.dynamicSearchFilter[1][0] = /issuer:([a-zA-Z0-9]+)/;
var matches = $scope.search.text.match($scope.dynamicSearchFilter[1][0]);
if (matches) { if (matches) {
$scope.dynamicSearchFilter[1][1] = matches[0]; console.log(filterType, matches);
$scope.dynamicSearchFilter[1][2] = 'TX_SEARCH.PUBKEY'; var filter = {
$scope.dynamicSearchFilter[1][3] = true; type: filterType,
$scope.dynamicSearchFilter[1][4] = matches[1]; params: matches
} };
$scope.params ={ return res.concat(filter);
date : {
startDate : $scope.dynamicSearchFilter[0][4],
endDate : $scope.dynamicSearchFilter[0][5]
},
pubkey: $scope.dynamicSearchFilter[1][4]
} }
return res;
}, []);
//};
}; };
// This method override the base class method // This method override the base class method
...@@ -175,11 +146,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU ...@@ -175,11 +146,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
} }
request.excludeCurrent = (from === 0); request.excludeCurrent = (from === 0);
$scope.filterConstructor();
promise = esBlockchain.block.search($scope.currency, request); promise = esBlockchain.block.search($scope.currency, request);
$scope.query = $scope.search.text;
$scope.search.text = null;
} }
// Full text search // Full text search
...@@ -196,11 +163,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU ...@@ -196,11 +163,7 @@ function ESBlockLookupController($scope, $state, $controller, $ionicPopover, UIU
} }
request.excludeCurrent = true; request.excludeCurrent = true;
$scope.filterConstructor();
promise = esBlockchain.block.searchText($scope.currency, $scope.search.text, request); promise = esBlockchain.block.searchText($scope.currency, $scope.search.text, request);
$scope.query = $scope.search.text;
$scope.search.text = null;
} }
var time = new Date().getTime(); var time = new Date().getTime();
......
...@@ -119,6 +119,7 @@ angular.module('cesium.es.blockchain.services', ['cesium.services', 'cesium.es.h ...@@ -119,6 +119,7 @@ angular.module('cesium.es.blockchain.services', ['cesium.services', 'cesium.es.h
return exports; return exports;
} }
return EsBlockchain(); return EsBlockchain();
}) })
; ;
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<div class="item no-padding"> <div class="item no-padding">
<div class="gray double-padding-x padding-top item-text-wrap" <div class="gray double-padding-x padding-top item-text-wrap"
ng-repeat="items in dynamicSearchFilter" ng-if="items[3]"> ng-repeat="filter in search.filters" ng-if="filter">
<span>{{items[2]|translate:params}}</span> <span>{{'BLOCKCHAIN.LOOKUP.TX_SEARCH_FILTER.'+filter.type|translate:filter}}</span>
<a class="icon ion-close" ng-click="itemRemove(items[0])"></a> <a class="icon ion-close" ng-click="itemRemove(filter)"></a>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment