Commit 4cdac5e7 by Rashid Khan

More error handling, changed es loading to use get instead of search

parent 809b0a34
...@@ -53,6 +53,7 @@ angular.module('kibana.services', []) ...@@ -53,6 +53,7 @@ angular.module('kibana.services', [])
self.map(indices).then(function(result) { self.map(indices).then(function(result) {
self.mapping = _.extend(self.mapping,result); self.mapping = _.extend(self.mapping,result);
self.list = mapFields(self.mapping); self.list = mapFields(self.mapping);
console.log(self.mapping);
}); });
// Otherwise just use the cached mapping // Otherwise just use the cached mapping
} else { } else {
...@@ -749,20 +750,22 @@ angular.module('kibana.services', []) ...@@ -749,20 +750,22 @@ angular.module('kibana.services', [])
}); });
}; };
this.elasticsearch_load = function(type,id) { this.elasticsearch_load = function(type,id) {
var request = ejs.Request().indices(config.kibana_index).types(type); return $http({
return request.query( url: config.elasticsearch + "/" + config.kibana_index + "/"+type+"/"+id,
ejs.IdsQuery(id) method: "GET"
).doSearch(function(results) { }).error(function(data, status, headers, conf) {
if(_.isUndefined(results)) { if(status === 0) {
return false; alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+
". Please ensure that Elasticsearch is reachable from your system." ,'error');
} else { } else {
self.dash_load(angular.fromJson(results.hits.hits[0]['_source']['dashboard'])); alertSrv.set('Error',"Could not find "+id+". If you"+
return true; " are using a proxy, ensure it is configured correctly",'error');
} }
}, return false;
function(data,status) { }).success(function(data, status, headers) {
alertSrv.set('Error','Could not load '+config.elasticsearch+"/"+config.kibana_index+"/"+type+"/"+id,'error'); self.dash_load(angular.fromJson(data['_source']['dashboard']));
}); });
}; };
...@@ -786,7 +789,6 @@ angular.module('kibana.services', []) ...@@ -786,7 +789,6 @@ angular.module('kibana.services', [])
request = type === 'temp' && ttl ? request.ttl(ttl) : request; request = type === 'temp' && ttl ? request.ttl(ttl) : request;
// TOFIX: Implement error handling here
return request.doIndex( return request.doIndex(
// Success // Success
function(result) { function(result) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment