Skip to content

Commit

Permalink
Hacking ES in
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Mar 30, 2013
1 parent e1aba13 commit 2323d6d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/js/app.js
Expand Up @@ -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'});
}]);
29 changes: 18 additions & 11 deletions app/js/controllers.js
Expand Up @@ -12,13 +12,22 @@ function cleanData(data) {
}

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

Expand All @@ -29,10 +38,8 @@ function ReportListCtrl($scope, $http) {

function ReportDetailCtrl($scope, $routeParams, $http) {
$scope.uuid = $routeParams.uuid;
$http.get('data/' + $routeParams.uuid + '.json').success(function(data) {
var parsedData = cleanData(data);
addContextTo(parsedData);
$scope.report = parsedData;
$http.get('/es/' + $routeParams.index + '/puppet-apply/' + $routeParams.uuid).success(function(data) {
$scope.report = addContextTo(cleanData(data["_source"]));
});
}

Expand Down

0 comments on commit 2323d6d

Please sign in to comment.