Skip to content

Commit

Permalink
Make ES queries work
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Mar 29, 2013
1 parent 0f3af72 commit d4d707a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/js/app.js
Expand Up @@ -6,6 +6,6 @@ angular.module('norman', []).
config(['$routeProvider', function($routeProvider) { config(['$routeProvider', function($routeProvider) {
$routeProvider. $routeProvider.
when('/latest', {templateUrl: 'partials/report-latest.html', controller: ReportListCtrl}). when('/latest', {templateUrl: 'partials/report-latest.html', controller: ReportListCtrl}).
when('/report/:uuid', {templateUrl: 'partials/report-detail.html', controller: ReportDetailCtrl}). when('/report/:index/:uuid', {templateUrl: 'partials/report-detail.html', controller: ReportDetailCtrl}).
otherwise({redirectTo: '/latest'}); otherwise({redirectTo: '/latest'});
}]); }]);
23 changes: 13 additions & 10 deletions app/js/controllers.js
Expand Up @@ -8,9 +8,7 @@ function cleanData(data) {
} }


function ReportListCtrl($scope, $http) { function ReportListCtrl($scope, $http) {
$http.get('data/reports_latest.json').success(function(data) { $http.post('/es/_all/puppet-apply/_search', angular.toJson({
$http.post('/es/_all/puppet-apply/_search', '
{
"from" : 0, "size" : 100, "from" : 0, "size" : 100,
"query": { "query": {
"term": { "term": {
Expand All @@ -20,15 +18,14 @@ function ReportListCtrl($scope, $http) {
"sort" : [ "sort" : [
{ "@timestamp" : {"order" : "desc"} } { "@timestamp" : {"order" : "desc"} }
] ]
}').success(function(data) { })).success(function(data) {
d = [] var d = []
data['hits']['hits'].foreach(function(hit) { data['hits']['hits'].forEach(function(hit) {
alert(hit); hit["_source"]["uuid"] = hit["_index"].concat("/").concat(hit["_id"]);
d.push(hit); d.push(hit["_source"]);
}) })
$scope.reports = cleanData(data); $scope.reports = cleanData(d);
}); });

$scope.orderProp = 'age'; $scope.orderProp = 'age';
} }


Expand All @@ -37,8 +34,14 @@ function ReportListCtrl($scope, $http) {


function ReportDetailCtrl($scope, $routeParams, $http) { function ReportDetailCtrl($scope, $routeParams, $http) {
$scope.uuid = $routeParams.uuid; $scope.uuid = $routeParams.uuid;
<<<<<<< HEAD
$http.get('data/' + $routeParams.uuid + '.json').success(function(data) { $http.get('data/' + $routeParams.uuid + '.json').success(function(data) {
$scope.report = cleanData(data); $scope.report = cleanData(data);
=======
$http.get('/es/' + $routeParams.index + '/puppet-apply/' + $routeParams.uuid).success(function(data) {
var jsonStringWithoutEvilAtSigns = angular.toJson(data["_source"]).replace(/@/g, "");
$scope.report = angular.fromJson(jsonStringWithoutEvilAtSigns);
>>>>>>> Make ES queries work
}); });
} }


Expand Down

0 comments on commit d4d707a

Please sign in to comment.