Skip to content

Commit

Permalink
implemented search
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Mar 18, 2016
1 parent b0cf464 commit 6fcee40
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
5 changes: 5 additions & 0 deletions css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,9 @@ svg.nvd3-svg {
.msg-error {
color:#F00;
font-size:14px;
}

.searchform {
color:#F00;

}
34 changes: 33 additions & 1 deletion js/modules/pages/controllers/resultCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
$scope.restoreState();
$scope.count = sdata.length;
$scope.gridOpts.data = sdata;
$scope.Data = sdata;
$timeout(function () {
angular.element($window).resize();
}, 0)
Expand Down Expand Up @@ -468,6 +469,10 @@
//set gridApi on scope
$scope.gridApi = gridApi;
};

$scope.searchData = function() {
$scope.gridOpts.data = $filter('messageSearch')($scope.Data, $scope.gridOpts, $scope.searchText);
};
}
])
.filter('unixts', function() {
Expand All @@ -479,5 +484,32 @@
return input;
}
};
});
})
.filter('messageSearch', function() {
return function(data, grid, query) {
var matches = [];

//no filter defined so bail
if (query === undefined|| query==='') {
return data;
}

for (var i = 0; i < data.length; i++) {
for (var j = 0; j < grid.columnDefs.length; j++) {

var dataItem = data[i];
var fieldName = grid.columnDefs[j]['field'];

if(dataItem[fieldName] === undefined) continue;

if (dataItem[fieldName].toString().search(query)>-1) {
var n = dataItem[fieldName].toString().search(query);
matches.push(dataItem);
break;
}
}
}
return matches;
}
});
}(angular, homer));
2 changes: 2 additions & 0 deletions js/modules/pages/html/result.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ <h1>
<a href="javascript:history.back();" ng-show="!dataLoading">
<em class="fa fa-step-backward" style="font-size: 20pt;"></em>
</a>
&nbsp;
<input ng-class="searchClass" style="float:right;" class="searchForm" type="text" ng-model="searchText" ng-change="searchData()" placeholder="Regex Filter ..." />

</h1>

Expand Down

0 comments on commit 6fcee40

Please sign in to comment.