From d3495ff73971f38e18d3a6f9c7cd533d22c25847 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Thu, 7 Nov 2013 22:00:48 +0100 Subject: [PATCH] allow loading of panels and dashboards from subfolders every . in their name is mapped to a / --- src/app/controllers/dash.js | 2 +- src/app/directives/addPanel.js | 2 +- src/app/directives/kibanaPanel.js | 5 +++-- src/app/directives/kibanaSimplePanel.js | 6 +++--- src/app/services/dashboard.js | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index 589495d426b87..1bb2bd72043ca 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -70,7 +70,7 @@ function (angular, config, _) { $scope.edit_path = function(type) { if(type) { - return 'app/panels/'+type+'/editor.html'; + return 'app/panels/'+type.replace(".","/")+'/editor.html'; } else { return false; } diff --git a/src/app/directives/addPanel.js b/src/app/directives/addPanel.js index 0b091ac30fe85..2887a54a35e4d 100644 --- a/src/app/directives/addPanel.js +++ b/src/app/directives/addPanel.js @@ -17,7 +17,7 @@ function (angular, app, _) { $scope.reset_panel(_type); if(!_.isUndefined($scope.panel.type)) { $scope.panel.loadingEditor = true; - $scope.require(['panels/'+$scope.panel.type+'/module'], function () { + $scope.require(['panels/'+$scope.panel.type.replace(".","/") +'/module'], function () { var template = '
'; elem.html($compile(angular.element(template))($scope)); $scope.panel.loadingEditor = false; diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index b6debc5c7158d..bbe5483d60465 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -75,9 +75,10 @@ function (angular) { $scope.$watch(attr.type, function (name) { elem.addClass("ng-cloak"); // load the panels module file, then render it in the dom. + var nameAsPath = name.replace(".", "/"); $scope.require([ 'jquery', - 'text!panels/'+name+'/module.html' + 'text!panels/'+nameAsPath+'/module.html' ], function ($, moduleTemplate) { var $module = $(moduleTemplate); // top level controllers @@ -88,7 +89,7 @@ function (angular) { if ($controllers.length) { $controllers.first().prepend(editorTemplate); $scope.require([ - 'panels/'+name+'/module' + 'panels/'+nameAsPath+'/module' ], function() { loadModule($module); }); diff --git a/src/app/directives/kibanaSimplePanel.js b/src/app/directives/kibanaSimplePanel.js index 74b781dcb9ca1..6274e8749f970 100644 --- a/src/app/directives/kibanaSimplePanel.js +++ b/src/app/directives/kibanaSimplePanel.js @@ -32,10 +32,10 @@ function (angular, _) { function loadController(name) { elem.addClass("ng-cloak"); // load the panels module file, then render it in the dom. - + var nameAsPath = name.replace(".", "/"); $scope.require([ 'jquery', - 'text!panels/'+name+'/module.html' + 'text!panels/'+nameAsPath+'/module.html' ], function ($, moduleTemplate) { var $module = $(moduleTemplate); // top level controllers @@ -46,7 +46,7 @@ function (angular, _) { if ($controllers.length) { $controllers.first().prepend(panelLoading); $scope.require([ - 'panels/'+name+'/module' + 'panels/'+nameAsPath+'/module' ], function() { loadModule($module); }); diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index c9203864d13fd..a4c1b1e3d5dab 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -274,7 +274,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) { this.file_load = function(file) { return $http({ - url: "app/dashboards/"+file+'?' + new Date().getTime(), + url: "app/dashboards/"+file.replace(".","/")+'?' + new Date().getTime(), method: "GET", transformResponse: function(response) { return renderTemplate(response,$routeParams); @@ -314,7 +314,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) { this.script_load = function(file) { return $http({ - url: "app/dashboards/"+file, + url: "app/dashboards/"+file.replace(".","/"), method: "GET", transformResponse: function(response) { /*jshint -W054 */