|
@@ -15,7 +15,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
|
|
|
|
|
|
|
|
module.service('dashboard', function(
|
|
module.service('dashboard', function(
|
|
|
$routeParams, $http, $rootScope, $injector, $location, $timeout,
|
|
$routeParams, $http, $rootScope, $injector, $location, $timeout,
|
|
|
- ejsResource, timer, alertSrv
|
|
|
|
|
|
|
+ ejsResource, timer, alertSrv, $q
|
|
|
) {
|
|
) {
|
|
|
// A hash of defaults to use when loading a dashboard
|
|
// A hash of defaults to use when loading a dashboard
|
|
|
|
|
|
|
@@ -332,13 +332,27 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
|
|
|
this.script_load = function(file) {
|
|
this.script_load = function(file) {
|
|
|
return $http({
|
|
return $http({
|
|
|
url: "app/dashboards/"+file.replace(/\.(?!js)/,"/"),
|
|
url: "app/dashboards/"+file.replace(/\.(?!js)/,"/"),
|
|
|
- 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);
|
|
|
|
|
|
|
+ method: "GET"
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(function(result) {
|
|
|
|
|
+ /*jshint -W054 */
|
|
|
|
|
+ var script_func = new Function('ARGS','kbn','_','moment','window','document','$','jQuery', result.data);
|
|
|
|
|
+ var script_result = script_func($routeParams,kbn,_,moment, window, document, $, $);
|
|
|
|
|
+
|
|
|
|
|
+ // Handle async dashboard scripts
|
|
|
|
|
+ if (_.isFunction(script_result)) {
|
|
|
|
|
+ var deferred = $q.defer();
|
|
|
|
|
+ script_result(function(dashboard) {
|
|
|
|
|
+ $rootScope.$apply(function() {
|
|
|
|
|
+ deferred.resolve({ data: dashboard });
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ return deferred.promise;
|
|
|
}
|
|
}
|
|
|
- }).then(function(result) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return { data: script_result };
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(function(result) {
|
|
|
if(!result) {
|
|
if(!result) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|