Commit 859c3996 by Rashid Khan

Namespace kibana url parameters

parent 0280626a
...@@ -18,14 +18,17 @@ ...@@ -18,14 +18,17 @@
* *
*/ */
var dashboard, ARGS, queries, _d_timespan; 'use strict';
// Setup some variables
var dashboard, queries, _d_timespan;
// All url parameters are available via the ARGS object
var ARGS;
// Set a default timespan if one isn't specified // Set a default timespan if one isn't specified
_d_timespan = '1h'; _d_timespan = '1h';
// arguments[0] contains a hash of the URL parameters, make it shorter
ARGS = arguments[0];
// Intialize a skeleton with nothing but a rows array and service object // Intialize a skeleton with nothing but a rows array and service object
dashboard = { dashboard = {
rows : [], rows : [],
...@@ -40,7 +43,7 @@ if(!_.isUndefined(ARGS.index)) { ...@@ -40,7 +43,7 @@ if(!_.isUndefined(ARGS.index)) {
dashboard.index = { dashboard.index = {
default: ARGS.index, default: ARGS.index,
interval: 'none' interval: 'none'
} };
} else { } else {
// Don't fail to default // Don't fail to default
dashboard.failover = false; dashboard.failover = false;
...@@ -48,7 +51,7 @@ if(!_.isUndefined(ARGS.index)) { ...@@ -48,7 +51,7 @@ if(!_.isUndefined(ARGS.index)) {
default: ARGS.index||'ADD_A_TIME_FILTER', default: ARGS.index||'ADD_A_TIME_FILTER',
pattern: ARGS.pattern||'[logstash-]YYYY.MM.DD', pattern: ARGS.pattern||'[logstash-]YYYY.MM.DD',
interval: ARGS.interval||'day' interval: ARGS.interval||'day'
} };
} }
// In this dashboard we let users pass queries as comma seperated list to the query parameter. // In this dashboard we let users pass queries as comma seperated list to the query parameter.
...@@ -59,7 +62,7 @@ if(!_.isUndefined(ARGS.query)) { ...@@ -59,7 +62,7 @@ if(!_.isUndefined(ARGS.query)) {
queries = _.object(_.map(ARGS.query.split(ARGS.split||','), function(v,k) { queries = _.object(_.map(ARGS.query.split(ARGS.split||','), function(v,k) {
return [k,{ return [k,{
query: v, query: v,
id: parseInt(k), id: parseInt(k,10),
alias: v alias: v
}]; }];
})); }));
...@@ -70,14 +73,14 @@ if(!_.isUndefined(ARGS.query)) { ...@@ -70,14 +73,14 @@ if(!_.isUndefined(ARGS.query)) {
query: '*', query: '*',
id: 0 id: 0
} }
} };
} }
// Now populate the query service with our objects // Now populate the query service with our objects
dashboard.services.query = { dashboard.services.query = {
list : queries, list : queries,
ids : _.map(_.keys(queries),function(v){return parseInt(v);}) ids : _.map(_.keys(queries),function(v){return parseInt(v,10);})
} };
// Lets also add a default time filter, the value of which can be specified by the user // Lets also add a default time filter, the value of which can be specified by the user
// This isn't strictly needed, but it gets rid of the info alert about the missing time filter // This isn't strictly needed, but it gets rid of the info alert about the missing time filter
...@@ -93,7 +96,7 @@ dashboard.services.filter = { ...@@ -93,7 +96,7 @@ dashboard.services.filter = {
} }
}, },
ids: [0] ids: [0]
} };
// Ok, lets make some rows. The Filters row is collapsed by default // Ok, lets make some rows. The Filters row is collapsed by default
dashboard.rows = [ dashboard.rows = [
...@@ -138,7 +141,7 @@ dashboard.rows[1].panels = [ ...@@ -138,7 +141,7 @@ dashboard.rows[1].panels = [
{ {
type: 'Query' type: 'Query'
} }
] ];
// Add a filtering panel to the 3rd row // Add a filtering panel to the 3rd row
...@@ -146,7 +149,7 @@ dashboard.rows[2].panels = [ ...@@ -146,7 +149,7 @@ dashboard.rows[2].panels = [
{ {
type: 'filtering' type: 'filtering'
} }
] ];
// And a histogram that allows the user to specify the interval and time field // And a histogram that allows the user to specify the interval and time field
dashboard.rows[3].panels = [ dashboard.rows[3].panels = [
...@@ -155,7 +158,7 @@ dashboard.rows[3].panels = [ ...@@ -155,7 +158,7 @@ dashboard.rows[3].panels = [
time_field: ARGS.timefield||"@timestamp", time_field: ARGS.timefield||"@timestamp",
auto_int: true auto_int: true
} }
] ];
// And a table row where you can specify field and sort order // And a table row where you can specify field and sort order
dashboard.rows[4].panels = [ dashboard.rows[4].panels = [
...@@ -165,7 +168,7 @@ dashboard.rows[4].panels = [ ...@@ -165,7 +168,7 @@ dashboard.rows[4].panels = [
sort: !_.isUndefined(ARGS.sort) ? ARGS.sort.split(',') : [ARGS.timefield||'@timestamp','desc'], sort: !_.isUndefined(ARGS.sort) ? ARGS.sort.split(',') : [ARGS.timefield||'@timestamp','desc'],
overflow: 'expand' overflow: 'expand'
} }
] ];
// Now return the object and we're good! // Now return the object and we're good!
return dashboard; return dashboard;
...@@ -48,10 +48,10 @@ labjs.wait(function(){ ...@@ -48,10 +48,10 @@ labjs.wait(function(){
.when('/dashboard', { .when('/dashboard', {
templateUrl: 'partials/dashboard.html', templateUrl: 'partials/dashboard.html',
}) })
.when('/dashboard/:type/:id', { .when('/dashboard/:kbnType/:kbnId', {
templateUrl: 'partials/dashboard.html', templateUrl: 'partials/dashboard.html',
}) })
.when('/dashboard/:type/:id/:params', { .when('/dashboard/:kbnType/:kbnId/:params', {
templateUrl: 'partials/dashboard.html' templateUrl: 'partials/dashboard.html'
}) })
.otherwise({ .otherwise({
......
...@@ -606,9 +606,9 @@ angular.module('kibana.services', []) ...@@ -606,9 +606,9 @@ angular.module('kibana.services', [])
var route = function() { var route = function() {
// Is there a dashboard type and id in the URL? // Is there a dashboard type and id in the URL?
if(!(_.isUndefined($routeParams.type)) && !(_.isUndefined($routeParams.id))) { if(!(_.isUndefined($routeParams.kbnType)) && !(_.isUndefined($routeParams.kbnId))) {
var _type = $routeParams.type; var _type = $routeParams.kbnType;
var _id = $routeParams.id; var _id = $routeParams.kbnId;
switch(_type) { switch(_type) {
case ('elasticsearch'): case ('elasticsearch'):
...@@ -827,7 +827,7 @@ angular.module('kibana.services', []) ...@@ -827,7 +827,7 @@ angular.module('kibana.services', [])
method: "GET", method: "GET",
transformResponse: function(response) { transformResponse: function(response) {
/*jshint -W054 */ /*jshint -W054 */
var _f = new Function(response); var _f = new Function("ARGS",response);
return _f($routeParams); return _f($routeParams);
} }
}).then(function(result) { }).then(function(result) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment