Permalink
Browse files

Make ES queries work

  • Loading branch information...
bobtfish committed Mar 29, 2013
1 parent 0f3af72 commit d4d707a59ea69b2d968a8e382264c89607ab40c2
Showing with 14 additions and 11 deletions.
  1. +1 −1 app/js/app.js
  2. +13 −10 app/js/controllers.js
View
@@ -6,6 +6,6 @@ angular.module('norman', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
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'});
}]);
View
@@ -8,9 +8,7 @@ function cleanData(data) {
}
function ReportListCtrl($scope, $http) {
- $http.get('data/reports_latest.json').success(function(data) {
- $http.post('/es/_all/puppet-apply/_search', '
-{
+ $http.post('/es/_all/puppet-apply/_search', angular.toJson({
"from" : 0, "size" : 100,
"query": {
"term": {
@@ -20,15 +18,14 @@ function ReportListCtrl($scope, $http) {
"sort" : [
{ "@timestamp" : {"order" : "desc"} }
]
-}').success(function(data) {
- d = []
- data['hits']['hits'].foreach(function(hit) {
- alert(hit);
- d.push(hit);
+})).success(function(data) {
+ var d = []
+ data['hits']['hits'].forEach(function(hit) {
+ hit["_source"]["uuid"] = hit["_index"].concat("/").concat(hit["_id"]);
+ d.push(hit["_source"]);
})
- $scope.reports = cleanData(data);
+ $scope.reports = cleanData(d);
});
-
$scope.orderProp = 'age';
}
@@ -37,8 +34,14 @@ function ReportListCtrl($scope, $http) {
function ReportDetailCtrl($scope, $routeParams, $http) {
$scope.uuid = $routeParams.uuid;
+<<<<<<< HEAD
$http.get('data/' + $routeParams.uuid + '.json').success(function(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
});
}

0 comments on commit d4d707a

Please sign in to comment.