From 9972c0d80078d3944d3d0968d1fe45a1f4c4a4e2 Mon Sep 17 00:00:00 2001 From: "Van Eenwyk, Jonathan" Date: Fri, 9 May 2014 09:53:09 -0600 Subject: [PATCH] Add support for deferred dashboards. This change allows scripted dashboards to return a jQuery Deferred object, so that they can do extra queries as needed to generate the dashboard. For example, the dashboard could fetch extra data from a REST service (like elasticsearch) and use the results to construct a dynamic dashboard. --- src/app/services/dashboard.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index e5191ccaf67ec..055bc67c9bc11 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -379,14 +379,18 @@ function (angular, $, kbn, _, config, moment, Modernizr) { method: "GET", transformResponse: function(response) { /*jshint -W054 */ - var _f = new Function('ARGS','kbn','_','moment','window','document','angular','require','define','$','jQuery',response); - return _f($routeParams,kbn,_,moment); + var _f = new Function('ARGS','kbn','_','moment','window','document','angular','require','define','$',response); + return _f($routeParams,kbn,_,moment,window,document,angular,require,define,$); } }).then(function(result) { if(!result) { return false; } - self.dash_load(dash_defaults(result.data)); + + $.when(result.data).then(function(data) { + self.dash_load(dash_defaults(data)); + }); + return true; },function() { alertSrv.set('Error',