Commit 75683c42 by Torkel Ödegaard

Closes #123, you can now specify template (ie filter) values in url. ?fillterName=filterValue

parent 3f2c69ae
......@@ -8,7 +8,7 @@ define([
var module = angular.module('kibana.services');
module.service('filterSrv', function(dashboard, $rootScope, $timeout) {
module.service('filterSrv', function(dashboard, $rootScope, $timeout, $routeParams) {
// defaults
var _d = {
list: [],
......@@ -26,16 +26,38 @@ define([
self.list = dashboard.current.services.filter.list;
self.time = dashboard.current.services.filter.time;
self.filterTemplateData = undefined;
self.templateSettings = {
interpolate : /\[\[([\s\S]+?)\]\]/g,
};
if (self.list.length) {
this.updateTemplateData(true);
}
};
this.updateTemplateData = function(initial) {
self.filterTemplateData = {};
_.each(self.list, function(filter) {
if (initial) {
var urlValue = $routeParams[filter.name];
if (urlValue) {
filter.current = { text: urlValue, value: urlValue };
}
}
if (!filter.current || !filter.current.value) {
return;
}
self.filterTemplateData[filter.name] = filter.current.value;
});
}
this.filterOptionSelected = function(filter, option) {
filter.current = option;
self.filterTemplateData = undefined;
this.updateTemplateData();
dashboard.refresh();
};
......@@ -47,16 +69,6 @@ define([
if (target.indexOf('[[') === -1) {
return target;
}
if (!self.filterTemplateData) {
self.filterTemplateData = {};
_.each(self.list, function(filter) {
if (!filter.current || !filter.current.value) {
return;
}
self.filterTemplateData[filter.name] = filter.current.value;
});
}
return _.template(target, self.filterTemplateData, self.templateSettings);
};
......
......@@ -21,7 +21,7 @@
</head>
<body ng-cloak body-class >
<body ng-cloak body-class>
<!--<link rel="stylesheet" ng-href="css/bootstrap.{{dashboard.current.style||'dark'}}.min.css">-->
<link rel="stylesheet" ng-href="css/bootstrap.{{dashboard.current.style||'dark'}}.min.css">
......
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