diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index 84972a7c6597e..3a0148dea9ebe 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -292,24 +292,24 @@ function (angular, $, kbn, _, config, moment, Modernizr) { }; this.elasticsearch_load = function(type,id) { - return $http({ - url: config.elasticsearch + "/" + config.kibana_index + "/"+type+"/"+id+'?' + new Date().getTime(), - method: "GET", - transformResponse: function(response) { - return renderTemplate(angular.fromJson(response)._source.dashboard, $routeParams); - } - }).error(function(data, status) { + var successcb = function(data) { + var response = renderTemplate(angular.fromJson(data)._source.dashboard, $routeParams); + self.dash_load(response); + }; + var errorcb = function(data, status) { if(status === 0) { - alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+ + alertSrv.set('Error',"Could not contact Elasticsearch at "+ejs.config.server+ ". Please ensure that Elasticsearch is reachable from your system." ,'error'); } else { alertSrv.set('Error',"Could not find "+id+". If you"+ " are using a proxy, ensure it is configured correctly",'error'); } return false; - }).success(function(data) { - self.dash_load(data); - }); + }; + + ejs.client.get( + "/" + config.kibana_index + "/"+type+"/"+id+'?' + new Date().getTime(), + null, successcb, errorcb); }; this.script_load = function(file) { diff --git a/src/app/services/esVersion.js b/src/app/services/esVersion.js index 20f1c7251942e..790c11ec51dc9 100644 --- a/src/app/services/esVersion.js +++ b/src/app/services/esVersion.js @@ -8,7 +8,7 @@ function (angular, _, config) { var module = angular.module('kibana.services'); - module.service('esVersion', function($http, alertSrv) { + module.service('esVersion', function($http, alertSrv, ejsResource) { this.versions = []; @@ -19,19 +19,19 @@ function (angular, _, config) { getVersions(); }; + var ejs = ejsResource(config.elasticsearch); + var getVersions = function() { - var nodeInfo = $http({ - url: config.elasticsearch + '/_nodes', - method: "GET" - }).error(function(data, status) { - if(status === 0) { - alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+ - ". Please ensure that Elasticsearch is reachable from your system." ,'error'); - } else { - alertSrv.set('Error',"Could not reach "+config.elasticsearch+"/_nodes. If you"+ - " are using a proxy, ensure it is configured correctly",'error'); - } - }); + var nodeInfo = ejs.client.get('/_nodes', + undefined, undefined, function(data, status) { + if(status === 0) { + alertSrv.set('Error',"Could not contact Elasticsearch at "+ejs.config.server+ + ". Please ensure that Elasticsearch is reachable from your system." ,'error'); + } else { + alertSrv.set('Error',"Could not reach "+ejs.config.server+"/_nodes. If you"+ + " are using a proxy, ensure it is configured correctly",'error'); + } + }); return nodeInfo.then(function(p) { _.each(p.data.nodes, function(v) { @@ -147,4 +147,4 @@ function (angular, _, config) { }); -}); \ No newline at end of file +}); diff --git a/src/app/services/fields.js b/src/app/services/fields.js index c59278f0b7309..a24a00e3d85d3 100644 --- a/src/app/services/fields.js +++ b/src/app/services/fields.js @@ -8,7 +8,7 @@ function (angular, _, config) { var module = angular.module('kibana.services'); - module.service('fields', function(dashboard, $rootScope, $http, alertSrv) { + module.service('fields', function(dashboard, $rootScope, $http, alertSrv, ejsResource) { // Save a reference to this var self = this; @@ -32,6 +32,8 @@ function (angular, _, config) { } }); + var ejs = ejsResource(config.elasticsearch); + var mapFields = function (m) { var fields = []; _.each(m, function(types) { @@ -43,19 +45,17 @@ function (angular, _, config) { }; this.map = function(indices) { - var request = $http({ - url: config.elasticsearch + "/" + indices.join(',') + "/_mapping", - method: "GET" - }).error(function(data, status) { - if(status === 0) { - alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+ - ". Please ensure that Elasticsearch is reachable from your system." ,'error'); - } else { - alertSrv.set('Error',"No index found at "+config.elasticsearch+"/" + - indices.join(',')+"/_mapping. Please create at least one index." + - "If you're using a proxy ensure it is configured correctly.",'error'); - } - }); + var request = ejs.client.get('/' + indices.join(',') + "/_mapping", + undefined, undefined, function(data, status) { + if(status === 0) { + alertSrv.set('Error',"Could not contact Elasticsearch at "+ejs.config.server+ + ". Please ensure that Elasticsearch is reachable from your system." ,'error'); + } else { + alertSrv.set('Error',"No index found at "+ejs.config.server+"/" + + indices.join(',')+"/_mapping. Please create at least one index." + + "If you're using a proxy ensure it is configured correctly.",'error'); + } + }); return request.then(function(p) { var mapping = {}; @@ -93,4 +93,4 @@ function (angular, _, config) { }); -}); \ No newline at end of file +}); diff --git a/src/app/services/kbnIndex.js b/src/app/services/kbnIndex.js index 9133b2ffb7f38..3b7a00f7115e2 100644 --- a/src/app/services/kbnIndex.js +++ b/src/app/services/kbnIndex.js @@ -9,7 +9,7 @@ function (angular, _, config, moment) { var module = angular.module('kibana.services'); - module.service('kbnIndex', function($http, alertSrv) { + module.service('kbnIndex', function($http, alertSrv, ejsResource) { // returns a promise containing an array of all indices matching the index // pattern that exist in a given range this.indices = function(from,to,pattern,interval) { @@ -25,21 +25,21 @@ function (angular, _, config, moment) { }); }; + var ejs = ejsResource(config.elasticsearch); + // returns a promise containing an array of all indices in an elasticsearch // cluster function all_indices() { - var something = $http({ - url: config.elasticsearch + "/_aliases", - method: "GET" - }).error(function(data, status) { - if(status === 0) { - alertSrv.set('Error',"Could not contact Elasticsearch at "+config.elasticsearch+ - ". Please ensure that Elasticsearch is reachable from your system." ,'error'); - } else { - alertSrv.set('Error',"Could not reach "+config.elasticsearch+"/_aliases. If you"+ - " are using a proxy, ensure it is configured correctly",'error'); - } - }); + var something = ejs.client.get('/_aliases', + undefined, undefined, function(data, status) { + if(status === 0) { + alertSrv.set('Error',"Could not contact Elasticsearch at "+ejs.config.server+ + ". Please ensure that Elasticsearch is reachable from your system." ,'error'); + } else { + alertSrv.set('Error',"Could not reach "+ejs.config.server+"/_aliases. If you"+ + " are using a proxy, ensure it is configured correctly",'error'); + } + }); return something.then(function(p) { var indices = []; @@ -98,4 +98,4 @@ function (angular, _, config, moment) { } }); -}); \ No newline at end of file +});