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