Commit 859c3996 by Rashid Khan

Namespace kibana url parameters

parent 0280626a
......@@ -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
_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
dashboard = {
rows : [],
......@@ -40,7 +43,7 @@ if(!_.isUndefined(ARGS.index)) {
dashboard.index = {
default: ARGS.index,
interval: 'none'
}
};
} else {
// Don't fail to default
dashboard.failover = false;
......@@ -48,7 +51,7 @@ if(!_.isUndefined(ARGS.index)) {
default: ARGS.index||'ADD_A_TIME_FILTER',
pattern: ARGS.pattern||'[logstash-]YYYY.MM.DD',
interval: ARGS.interval||'day'
}
};
}
// In this dashboard we let users pass queries as comma seperated list to the query parameter.
......@@ -59,7 +62,7 @@ if(!_.isUndefined(ARGS.query)) {
queries = _.object(_.map(ARGS.query.split(ARGS.split||','), function(v,k) {
return [k,{
query: v,
id: parseInt(k),
id: parseInt(k,10),
alias: v
}];
}));
......@@ -70,14 +73,14 @@ if(!_.isUndefined(ARGS.query)) {
query: '*',
id: 0
}
}
};
}
// Now populate the query service with our objects
dashboard.services.query = {
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
// 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 = {
}
},
ids: [0]
}
};
// Ok, lets make some rows. The Filters row is collapsed by default
dashboard.rows = [
......@@ -138,7 +141,7 @@ dashboard.rows[1].panels = [
{
type: 'Query'
}
]
];
// Add a filtering panel to the 3rd row
......@@ -146,7 +149,7 @@ dashboard.rows[2].panels = [
{
type: 'filtering'
}
]
];
// And a histogram that allows the user to specify the interval and time field
dashboard.rows[3].panels = [
......@@ -155,7 +158,7 @@ dashboard.rows[3].panels = [
time_field: ARGS.timefield||"@timestamp",
auto_int: true
}
]
];
// And a table row where you can specify field and sort order
dashboard.rows[4].panels = [
......@@ -165,7 +168,7 @@ dashboard.rows[4].panels = [
sort: !_.isUndefined(ARGS.sort) ? ARGS.sort.split(',') : [ARGS.timefield||'@timestamp','desc'],
overflow: 'expand'
}
]
];
// Now return the object and we're good!
return dashboard;
......@@ -48,10 +48,10 @@ labjs.wait(function(){
.when('/dashboard', {
templateUrl: 'partials/dashboard.html',
})
.when('/dashboard/:type/:id', {
.when('/dashboard/:kbnType/:kbnId', {
templateUrl: 'partials/dashboard.html',
})
.when('/dashboard/:type/:id/:params', {
.when('/dashboard/:kbnType/:kbnId/:params', {
templateUrl: 'partials/dashboard.html'
})
.otherwise({
......
......@@ -606,9 +606,9 @@ angular.module('kibana.services', [])
var route = function() {
// Is there a dashboard type and id in the URL?
if(!(_.isUndefined($routeParams.type)) && !(_.isUndefined($routeParams.id))) {
var _type = $routeParams.type;
var _id = $routeParams.id;
if(!(_.isUndefined($routeParams.kbnType)) && !(_.isUndefined($routeParams.kbnId))) {
var _type = $routeParams.kbnType;
var _id = $routeParams.kbnId;
switch(_type) {
case ('elasticsearch'):
......@@ -827,7 +827,7 @@ angular.module('kibana.services', [])
method: "GET",
transformResponse: function(response) {
/*jshint -W054 */
var _f = new Function(response);
var _f = new Function("ARGS",response);
return _f($routeParams);
}
}).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