Skip to content

Commit

Permalink
allow loading of panels and dashboards from subfolders
Browse files Browse the repository at this point in the history
every . in their name is mapped to a /
  • Loading branch information
bleskes committed Nov 7, 2013
1 parent 2b9a8a0 commit d3495ff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/controllers/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/directives/addPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div ng-controller="'+$scope.panel.type+'" ng-include="\'app/partials/paneladd.html\'"></div>';
elem.html($compile(angular.element(template))($scope));
$scope.panel.loadingEditor = false;
Expand Down
5 changes: 3 additions & 2 deletions src/app/directives/kibanaPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -88,7 +89,7 @@ function (angular) {
if ($controllers.length) {
$controllers.first().prepend(editorTemplate);
$scope.require([
'panels/'+name+'/module'
'panels/'+nameAsPath+'/module'
], function() {
loadModule($module);
});
Expand Down
6 changes: 3 additions & 3 deletions src/app/directives/kibanaSimplePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,7 +46,7 @@ function (angular, _) {
if ($controllers.length) {
$controllers.first().prepend(panelLoading);
$scope.require([
'panels/'+name+'/module'
'panels/'+nameAsPath+'/module'
], function() {
loadModule($module);
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(".","/"),

This comment has been minimized.

Copy link
@marceldegraaf

marceldegraaf Nov 8, 2013

This change seems to have broken our Kibana setup, in that it now looks for a app/dashboards/default/json file instead of for app/dashboards/default.json. Is this behaviour intended? So, should we move our default dashboard to an extension-less app/dashboards/default/json file?

This comment has been minimized.

Copy link
@pmoranga

pmoranga Nov 8, 2013

It broke mine also.
a negative lookahead fixed the issue for me (line 277):
file.replace(".(?!json)","/")

This comment has been minimized.

Copy link
@marceldegraaf

marceldegraaf Nov 11, 2013

@pmoranga FYI, this has been fixed in 444bb40 😄

This comment has been minimized.

Copy link
@pmoranga

pmoranga Nov 11, 2013

Great

method: "GET",
transformResponse: function(response) {
/*jshint -W054 */
Expand Down

0 comments on commit d3495ff

Please sign in to comment.