diff --git a/common/css/main.css b/common/css/main.css index f3a182ef850..08e0e982693 100644 --- a/common/css/main.css +++ b/common/css/main.css @@ -51,4 +51,11 @@ .tiny { font-size: 50%; -} \ No newline at end of file +} + +.remove:hover { + color: #A60000; + text-decoration: line-through; +} + +.typeahead { z-index: 1051; } \ No newline at end of file diff --git a/dashboards.js b/dashboards.js index 323c37764f7..c5f34581685 100644 --- a/dashboards.js +++ b/dashboards.js @@ -45,7 +45,7 @@ var dashboards = index : "\"shakespeare\"", refresh : { enable : true, - interval: 30, + interval: 3, min : 10 }, timefield: '@timestamp', @@ -70,7 +70,7 @@ var dashboards = index : "\"shakespeare\"", refresh : { enable : true, - interval: 30, + interval: 3, min : 10 }, timefield: '@timestamp', @@ -208,6 +208,7 @@ var dashboards = }, { title : "Newest Lines", + editable: true, type : "table", span : 6, query : "*", @@ -221,6 +222,7 @@ var dashboards = }, ] }, + { title: "Monkey Monitoring", collapse: false, @@ -260,5 +262,6 @@ var dashboards = }, ] } + ] }; diff --git a/index.html b/index.html index 59fc153a212..d68416b6976 100644 --- a/index.html +++ b/index.html @@ -12,9 +12,9 @@ Kibana Dashboard - + diff --git a/js/app.js b/js/app.js index 90bf28a8ac6..b49d0eda148 100644 --- a/js/app.js +++ b/js/app.js @@ -4,9 +4,9 @@ // Base modules var modules = [ + 'kibana.services', 'kibana.controllers', 'kibana.filters', - 'kibana.services', 'kibana.directives', 'elasticjs.service', '$strap.directives', diff --git a/js/controllers.js b/js/controllers.js index fc8b4512ad9..6c8683b14ac 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -3,7 +3,7 @@ 'use strict'; angular.module('kibana.controllers', []) -.controller('DashCtrl', function($scope, ejsResource) { +.controller('DashCtrl', function($scope, $rootScope, ejsResource) { $scope.config = config; $scope.dashboards = dashboards @@ -14,7 +14,7 @@ angular.module('kibana.controllers', []) $scope.$broadcast('toggle_row',row) row.collapse = row.collapse ? false : true; } - + }); diff --git a/js/directives.js b/js/directives.js index 8e7c62e4fb6..396e755a053 100644 --- a/js/directives.js +++ b/js/directives.js @@ -12,13 +12,35 @@ angular.module('kibana.directives', []) return (attrs.panel && scope.index) ? true : false; }, function (ready) { if (ready) { - element.html($compile("
")(scope)) + element.html($compile("
")(scope)) } }); } } } }) +.directive('arrayJoin', function() { + return { + restrict: 'A', + require: 'ngModel', + link: function(scope, element, attr, ngModel) { + + function split_array(text) { + return (text || '').split(','); + } + + function join_array(text) { + if(_.isArray(text)) + return (text || '').join(','); + else + return text + } + ngModel.$parsers.push(split_array); + ngModel.$formatters.push(join_array); + } + }; +}) .directive('upload', function(){ return { restrict: 'A', diff --git a/js/services.js b/js/services.js index deca4150055..182c52a43c4 100644 --- a/js/services.js +++ b/js/services.js @@ -2,4 +2,38 @@ /*global angular:true */ 'use strict'; -angular.module('kibana.services', []); +angular.module('kibana.services', []) +.service('eventBus', function($rootScope) { + + this.broadcast = function(from,to,type,data) { + if(_.isUndefined(data)) + var data = from + + $rootScope.$broadcast(type,{ + from: from, + to: to, + data: data + }); + } + + // This sets up an $on listener that checks to see if the event (packet) is + // addressed to the scope in question and runs the registered function if it + // is. + this.register = function(scope,type,fn) { + scope.$on(type,function(event,packet){ + var _id = scope.$id; + var _to = packet.to; + var _from = packet.from; + + if(!(_.isArray(_to))) + _to = [_to]; + if(!(_.isArray(scope.panel.group))) + scope.panel.group = [scope.panel.group]; + + if(_.intersection(_to,scope.panel.group).length > 0 || _.indexOf(_to,_id) > -1) { + fn(event,packet.data); + } + }); + } + +}); diff --git a/panels/fields/module.js b/panels/fields/module.js index 874ebc00197..84d48582fff 100644 --- a/panels/fields/module.js +++ b/panels/fields/module.js @@ -1,5 +1,5 @@ angular.module('kibana.fields', []) -.controller('fields', function($scope, $rootScope) { +.controller('fields', function($scope, eventBus) { var _id = _.uniqueId(); @@ -12,7 +12,7 @@ angular.module('kibana.fields', []) $scope.init = function() { $scope.fields = []; - $scope.$on($scope.panel.group+"-fields", function(event, fields) { + eventBus.register($scope,'fields', function(event, fields) { $scope.panel.sort = _.clone(fields.sort); $scope.fields = _.union(fields.all,$scope.fields); $scope.active = _.clone(fields.active); @@ -28,7 +28,8 @@ angular.module('kibana.fields', []) $scope.active = _.without($scope.active,field) else $scope.active.push(field) - $rootScope.$broadcast($scope.panel.group+"-selected_fields",$scope.active) + + eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active) } $scope.is_active = function(field) { diff --git a/panels/histogram/module.js b/panels/histogram/module.js index 61d6e2f4e0f..6613fdbe17d 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -1,5 +1,5 @@ angular.module('kibana.histogram', []) -.controller('histogram', function($scope, $rootScope) { +.controller('histogram', function($scope, eventBus) { var _id = _.uniqueId(); @@ -15,14 +15,13 @@ angular.module('kibana.histogram', []) _.defaults($scope.panel,_d) $scope.init = function() { - $scope.$on(_id+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-query", function(event, query) { + eventBus.register($scope,'time', function(event,time){set_time(time)}); + eventBus.register($scope,'query', function(event, query) { $scope.panel.query[0].query = query; $scope.get_data(); }); // Now that we're all setup, request the time from our group - $rootScope.$broadcast($scope.panel.group+"-get_time",_id) + eventBus.broadcast($scope.$id,$scope.panel.group,'get_time') } $scope.get_data = function() { diff --git a/panels/hits/module.js b/panels/hits/module.js index f1b66ac6099..8b4b072b73e 100644 --- a/panels/hits/module.js +++ b/panels/hits/module.js @@ -1,5 +1,5 @@ angular.module('kibana.hits', []) -.controller('hits', function($scope, $rootScope, $location) { +.controller('hits', function($scope, eventBus) { var _id = _.uniqueId(); @@ -12,15 +12,13 @@ angular.module('kibana.hits', []) _.defaults($scope.panel,_d) $scope.init = function () { - $scope.$on(_id+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-query", function(event, query) { + eventBus.register($scope,'time', function(event,time){set_time(time)}); + eventBus.register($scope,'query', function(event, query) { $scope.panel.query = query; $scope.get_data(); }); - // Now that we're all setup, request the time from our group - $rootScope.$broadcast($scope.panel.group+"-get_time",_id) + eventBus.broadcast($scope.$id,$scope.panel.group,'get_time') } $scope.get_data = function() { diff --git a/panels/map/module.js b/panels/map/module.js index 4d24e4fe801..62fc8ab1115 100644 --- a/panels/map/module.js +++ b/panels/map/module.js @@ -1,5 +1,5 @@ angular.module('kibana.map', []) -.controller('map', function($scope, $rootScope) { +.controller('map', function($scope, eventBus) { var _id = _.uniqueId(); @@ -15,14 +15,13 @@ angular.module('kibana.map', []) _.defaults($scope.panel,_d) $scope.init = function() { - $scope.$on(_id+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-query", function(event, query) { + eventBus.register($scope,'time', function(event,time){set_time(time)}); + eventBus.register($scope,'query', function(event, query) { $scope.panel.query = query; $scope.get_data(); }); // Now that we're all setup, request the time from our group - $rootScope.$broadcast($scope.panel.group+"-get_time",_id) + eventBus.broadcast($scope.$id,$scope.panel.group,'get_time') } $scope.get_data = function() { diff --git a/panels/pie/module.js b/panels/pie/module.js index 5650181bd7f..c5078f81dcc 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -2,7 +2,7 @@ labjs = labjs.script("common/lib/panels/jquery.flot.js") .script("common/lib/panels/jquery.flot.pie.js") angular.module('kibana.pie', []) -.controller('pie', function($scope, $rootScope) { +.controller('pie', function($scope, eventBus) { var _id = _.uniqueId(); @@ -20,16 +20,15 @@ angular.module('kibana.pie', []) _.defaults($scope.panel,_d) $scope.init = function() { - $scope.$on(_id+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-time", function(event,time){set_time(time)}); + eventBus.register($scope,'time', function(event,time){set_time(time)}); if(!(_.isArray($scope.panel.query))) { - $scope.$on($scope.panel.group+"-query", function(event, query) { + eventBus.register($scope,'query', function(event, query) { $scope.panel.query.query = query; $scope.get_data(); }); } // Now that we're all setup, request the time from our group - $rootScope.$broadcast($scope.panel.group+"-get_time",_id) + eventBus.broadcast($scope.$id,$scope.panel.group,'get_time') } $scope.get_data = function() { diff --git a/panels/sort/module.js b/panels/sort/module.js index a145424ef95..9b1f2ddfa3e 100644 --- a/panels/sort/module.js +++ b/panels/sort/module.js @@ -1,5 +1,5 @@ angular.module('kibana.sort', []) -.controller('sort', function($scope, $rootScope) { +.controller('sort', function($scope, eventBus) { var _id = _.uniqueId(); @@ -15,19 +15,21 @@ angular.module('kibana.sort', []) $scope.init = function() { $scope.fields = []; - $scope.$on($scope.panel.group+"-fields", function(event, fields) { + eventBus.register($scope,'fields',function(event, fields) { $scope.panel.sort = _.clone(fields.sort); $scope.fields = _.union(fields.all,$scope.fields); }); } $scope.set_sort = function() { - $rootScope.$broadcast($scope.panel.group+"-sort",$scope.panel.sort) + console.log($scope) + eventBus.broadcast($scope.$id,$scope.panel.group,"sort",$scope.panel.sort) } $scope.toggle_sort = function() { $scope.panel.sort[1] = $scope.panel.sort[1] == 'asc' ? 'desc' : 'asc'; - $rootScope.$broadcast($scope.panel.group+"-sort",$scope.panel.sort) + $scope.set_sort(); } + $scope.init(); }) \ No newline at end of file diff --git a/panels/stringquery/module.js b/panels/stringquery/module.js index 33d5258a74b..dd6f9914f57 100644 --- a/panels/stringquery/module.js +++ b/panels/stringquery/module.js @@ -1,5 +1,5 @@ angular.module('kibana.stringquery', []) -.controller('stringquery', function($scope, $rootScope) { +.controller('stringquery', function($scope, eventBus) { var _id = _.uniqueId(); @@ -18,9 +18,7 @@ angular.module('kibana.stringquery', []) $scope.init = function() { $scope.send_query = function(query) { - _.each(_groups,function(group) { - $rootScope.$broadcast(group+"-query", query) - }); + eventBus.broadcast($scope.$id,$scope.panel.group,'query',query) } } $scope.init(); diff --git a/panels/table/editor.html b/panels/table/editor.html new file mode 100644 index 00000000000..76af4bfd872 --- /dev/null +++ b/panels/table/editor.html @@ -0,0 +1,30 @@ + + + \ No newline at end of file diff --git a/panels/table/module.html b/panels/table/module.html index 95f239e935b..4b513697583 100644 --- a/panels/table/module.html +++ b/panels/table/module.html @@ -1,5 +1,5 @@
-

{{panel.title}}

+

{{panel.title}}

diff --git a/panels/table/module.js b/panels/table/module.js index e5a9e19c9f2..685fb4cd5d8 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -1,5 +1,5 @@ angular.module('kibana.table', []) -.controller('table', function($scope, $rootScope, $location) { +.controller('table', function($scope, eventBus) { var _id = _.uniqueId(); @@ -15,25 +15,29 @@ angular.module('kibana.table', []) _.defaults($scope.panel,_d) $scope.init = function () { - $scope.$on(_id+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-time", function(event,time){set_time(time)}); - $scope.$on($scope.panel.group+"-query", function(event, query) { - console.log($scope.panel) - $scope.panel.query = query; - $scope.get_data(); - }); - $scope.$on($scope.panel.group+"-sort", function(event,sort){ - $scope.panel.sort = _.clone(sort); - }); - $scope.$on($scope.panel.group+"-selected_fields", function(event, fields) { - $scope.panel.fields = _.clone(fields) - }); + $scope.set_listeners($scope.panel.group) $scope.$watch(function() { return angular.toJson($scope.panel.sort) }, function(){$scope.get_data()}); // Now that we're all setup, request the time from our group - $rootScope.$broadcast($scope.panel.group+"-get_time",_id) + eventBus.broadcast($scope.$id,$scope.panel.group,"get_time") + } + + $scope.set_listeners = function(group) { + eventBus.register($scope,'time',function(event,time) { + set_time(time) + }); + eventBus.register($scope,'query',function(event,query) { + $scope.panel.query = query; + $scope.get_data(); + }); + eventBus.register($scope,'sort', function(event,sort){ + $scope.panel.sort = _.clone(sort); + }); + eventBus.register($scope,'selected_fields', function(event, fields) { + $scope.panel.fields = _.clone(fields) + }); } $scope.set_sort = function(field) { @@ -43,6 +47,14 @@ angular.module('kibana.table', []) $scope.panel.sort[0] = field; } + $scope.toggle_field = function(field) { + if (_.indexOf($scope.panel.fields,field) > -1) + $scope.panel.fields = _.without($scope.panel.fields,field) + else + $scope.panel.fields.push(field) + broadcast_fields(); + } + $scope.get_data = function() { // Make sure we have everything for the request to complete if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.panel.time)) @@ -71,17 +83,9 @@ angular.module('kibana.table', []) $scope.panel.error = false; $scope.hits = results.hits.total; $scope.data = results.hits.hits; + $scope.all_fields = get_all_fields(results); - // Broadcast a list of all fields. Note that receivers of field array - // events should be able to receive from multiple sources, merge, dedupe - // and sort on the fly. - if (!(_.isUndefined($scope.panel.group))) - $rootScope.$broadcast( - $scope.panel.group+"-fields", { - all : get_all_fields(results), - sort : $scope.panel.sort, - active: $scope.panel.fields - }); + broadcast_fields(); }); } @@ -89,6 +93,17 @@ angular.module('kibana.table', []) console.log(field,dir) } + // Broadcast a list of all fields. Note that receivers of field array + // events should be able to receive from multiple sources, merge, dedupe + // and sort on the fly if needed. + function broadcast_fields() { + eventBus.broadcast($scope.$id,$scope.panel.group,"fields", { + all : $scope.all_fields, + sort : $scope.panel.sort, + active: $scope.panel.fields + }); + } + function set_time(time) { $scope.panel.time = time; $scope.panel.index = _.isUndefined(time.index) ? $scope.panel.index : time.index diff --git a/panels/timepicker/module.js b/panels/timepicker/module.js index 9a2f6502ac9..2276e9b570c 100644 --- a/panels/timepicker/module.js +++ b/panels/timepicker/module.js @@ -24,7 +24,7 @@ a pattern */ angular.module('kibana.timepicker', []) -.controller('timepicker', function($scope, $rootScope, $timeout, $http) { +.controller('timepicker', function($scope, eventBus, $timeout, $http) { var _id = _.uniqueId(); @@ -78,10 +78,8 @@ angular.module('kibana.timepicker', []) // In the case that a panel is not ready to receive a time event, it may // request one be sent by broadcasting a 'get_time' with its _id to its group // This panel can handle multiple groups - _.each(_groups,function(group){ - $scope.$on(group+"-get_time", function(event,id) { - $rootScope.$broadcast(id+"-time", $scope.time) - }); + eventBus.register($scope,"get_time", function(event,id) { + eventBus.broadcast($scope.$id,id,'time',$scope.time) }); $scope.$watch('panel.refresh.enable', function() {$scope.refresh()}); @@ -175,9 +173,7 @@ angular.module('kibana.timepicker', []) indices($scope.time.from,$scope.time.to).then(function (p) { $scope.time.index = p.join(); // Broadcast time - _.each(_groups,function(group){ - $rootScope.$broadcast(group+"-time", $scope.time) - }); + eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time) }); // Update panel's string representation of the time object