diff --git a/config.js b/config.js index d2b69468238..f92de346496 100644 --- a/config.js +++ b/config.js @@ -30,7 +30,7 @@ var config = new Settings( timefield: '@timestamp', //indexpattern: '"logstash-"yyyy.mm.dd', indexpattern: '"shakespeare"', - modules: ['histogram','map','pie','table'], + modules: ['histogram','map','pie','table','stringquery'], defaultfields: ['line_text'], perpage: 50, diff --git a/dashboards.js b/dashboards.js index a6b4587d803..e08e647ccbf 100644 --- a/dashboards.js +++ b/dashboards.js @@ -2,6 +2,16 @@ var dashboards = { title: "Infinite Monkey Dashboard", rows: [ + { + height: "30px", + panels: [ + { + type : "stringquery", + span : 12, + group : "mainsearch" + } + ] + }, { height: "300px", panels: [ @@ -11,12 +21,8 @@ var dashboards = span : 6, show : ['lines','stack'], fill : 1, - query : [ - { label : "US", query : "country:US", color: '#86B32D' }, - { label : "CN", query : "country:CN", color: '#BF3030' }, - { label : "IN", query : "country:IN", color: '#1D7373' } - ], - color : "#7BA4AF" + query : [{ label : "lines", query : "*", color: '#86B32D' } ], + group : "mainsearch" }, { title : "World Monkeys", @@ -25,7 +31,9 @@ var dashboards = field : "country", span : 6, size : 500, - query : "*" + query : "*", + group : "mainsearch" + } ] }, @@ -33,7 +41,7 @@ var dashboards = height: "300px", panels: [ { - title : "Hamlet vs Macbeth", + title : "Plays", type : "pie", span : 4, size : 8, @@ -41,17 +49,16 @@ var dashboards = colors : ['#BF3030','#1D7373','#86B32D','#A60000','#006363','#679B00'], field : 'country', //query : { query: "*", field: "country"} - query : [ - { label : "Hamlet", query : "play_name:Hamlet", color: '#86B32D' }, - { label : "Macbeth", query : "play_name:macbeth", color: '#BF3030' }, - ] + query : { field : "play_name", query : "*" }, + group : "mainsearch" }, { title : "Newest Lines", type : "table", span : 8, query : "*", - fields : ['@timestamp','speaker','text_entry'] + fields : ['@timestamp','speaker','text_entry'], + group : "mainsearch" } ] } diff --git a/panels/histogram/module.js b/panels/histogram/module.js index d449b8fad8e..27823128398 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -14,6 +14,13 @@ angular.module('kibana.histogram', []) ? _d[k] : $scope.panel[k]; }); + if (!(_.isUndefined($scope.panel.group))) { + $scope.$on($scope.panel.group+"-query", function(event, query) { + $scope.panel.query[0].query = query; + $scope.get_data(); + }); + } + $scope.get_data = function() { var request = $scope.ejs.Request().indices($scope.index); diff --git a/panels/map/module.js b/panels/map/module.js index 08a08dfc5ce..e817c83461a 100644 --- a/panels/map/module.js +++ b/panels/map/module.js @@ -14,6 +14,14 @@ angular.module('kibana.map', []) ? _d[k] : $scope.panel[k]; }); + + if (!(_.isUndefined($scope.panel.group))) { + $scope.$on($scope.panel.group+"-query", function(event, query) { + $scope.panel.query = query; + $scope.get_data(); + }); + } + $scope.get_data = function() { var request = $scope.ejs.Request().indices($scope.index); diff --git a/panels/pie/module.js b/panels/pie/module.js index 0f6dbc3afb6..c53db746b40 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -18,6 +18,13 @@ angular.module('kibana.pie', []) ? _d[k] : $scope.panel[k]; }); + if (!(_.isUndefined($scope.panel.group)) && !(_.isArray($scope.panel.query))) { + $scope.$on($scope.panel.group+"-query", function(event, query) { + $scope.panel.query.query = query; + $scope.get_data(); + }); + } + $scope.get_data = function() { var request = $scope.ejs.Request().indices($scope.index); diff --git a/panels/stringquery/module.html b/panels/stringquery/module.html new file mode 100644 index 00000000000..a728eb352ab --- /dev/null +++ b/panels/stringquery/module.html @@ -0,0 +1,7 @@ +
+

{{panel.title}}

+ +
\ No newline at end of file diff --git a/panels/stringquery/module.js b/panels/stringquery/module.js new file mode 100644 index 00000000000..804d34c01df --- /dev/null +++ b/panels/stringquery/module.js @@ -0,0 +1,20 @@ +angular.module('kibana.stringquery', []) +.controller('stringquery', function($scope, $rootScope) { + + // Set and populate defaults + var _d = { + query : "*", + size : 100, + sort : [config.timefield,'desc'], + } + _.each(_d, function(v, k) { + $scope.panel[k] = _.isUndefined($scope.panel[k]) + ? _d[k] : $scope.panel[k]; + }); + + if (!(_.isUndefined($scope.panel.group))) { + $scope.send_query = function(query) { + $rootScope.$broadcast($scope.panel.group+"-query", query) + } + } +}) \ No newline at end of file diff --git a/panels/table/module.js b/panels/table/module.js index 7f39d272813..66ddcefd5d1 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -12,6 +12,13 @@ angular.module('kibana.table', []) ? _d[k] : $scope.panel[k]; }); + if (!(_.isUndefined($scope.panel.group))) { + $scope.$on($scope.panel.group+"-query", function(event, query) { + $scope.panel.query = query; + $scope.get_data(); + }); + } + $scope.get_data = function() { var request = $scope.ejs.Request().indices($scope.index); @@ -30,7 +37,6 @@ angular.module('kibana.table', []) // Populate scope when we have results results.then(function(results) { - console.log(results) $scope.hits = results.hits.total; $scope.data = results.hits.hits; /* @@ -55,4 +61,4 @@ angular.module('kibana.table', []) $scope.get_data(); }); -}) \ No newline at end of file +})