From 869bebed6e33fe40382428c311d8b2f9ae233957 Mon Sep 17 00:00:00 2001 From: Torkel Odegaard Date: Sun, 9 Feb 2014 19:31:06 +0100 Subject: [PATCH] more work on annotations --- src/app/controllers/all.js | 1 + src/app/controllers/submenuCtrl.js | 30 +++ src/app/directives/grafanaGraph.js | 4 +- src/app/panels/annotations/module.html | 11 +- src/app/panels/annotations/module.js | 29 ++- src/app/panels/graphite/module.js | 18 +- src/app/partials/dashboard.html | 14 +- src/app/partials/dasheditor.html | 2 +- src/app/services/all.js | 1 + src/app/services/annotationsSrv.js | 77 ++++++ src/app/services/graphite/graphiteSrv.js | 6 +- src/css/bootstrap.dark.min.css | 2 +- src/css/bootstrap.light.min.css | 2 +- .../less/grafana-responsive.less | 0 .../bootstrap => css}/less/grafana.less | 34 +-- .../bootstrap => css}/less/overrides.less | 0 src/css/less/submenu.less | 41 ++++ .../less/variables.dark.less | 0 .../less/variables.light.less | 0 src/vendor/jquery/jquery.flot.fillbetween.js | 225 ++++++++++++++++++ tasks/options/less.js | 2 +- 21 files changed, 426 insertions(+), 73 deletions(-) create mode 100644 src/app/controllers/submenuCtrl.js create mode 100644 src/app/services/annotationsSrv.js rename src/{vendor/bootstrap => css}/less/grafana-responsive.less (100%) rename src/{vendor/bootstrap => css}/less/grafana.less (94%) rename src/{vendor/bootstrap => css}/less/overrides.less (100%) create mode 100644 src/css/less/submenu.less rename src/{vendor/bootstrap => css}/less/variables.dark.less (100%) rename src/{vendor/bootstrap => css}/less/variables.light.less (100%) create mode 100644 src/vendor/jquery/jquery.flot.fillbetween.js diff --git a/src/app/controllers/all.js b/src/app/controllers/all.js index 1968daab360..5c30be1d0e1 100644 --- a/src/app/controllers/all.js +++ b/src/app/controllers/all.js @@ -2,6 +2,7 @@ define([ './dash', './dashLoader', './row', + './submenuCtrl', './pulldown', './search', './metricKeys', diff --git a/src/app/controllers/submenuCtrl.js b/src/app/controllers/submenuCtrl.js new file mode 100644 index 00000000000..ca06f122e60 --- /dev/null +++ b/src/app/controllers/submenuCtrl.js @@ -0,0 +1,30 @@ +define([ + 'angular', + 'app', + 'underscore' +], +function (angular, app, _) { + 'use strict'; + + var module = angular.module('kibana.controllers'); + + module.controller('SubmenuCtrl', function($scope) { + var _d = { + collapse: false, + notice: false, + enable: true + }; + + _.defaults($scope.pulldown,_d); + + $scope.init = function() { + $scope.panel = $scope.pulldown; + $scope.row = $scope.pulldown; + }; + + $scope.init(); + + } + ); + +}); \ No newline at end of file diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 694ba02421d..085dc115a6d 100644 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -206,13 +206,13 @@ function (angular, $, kbn, moment, _) { } function addAnnotations(options) { - if(!scope.panel.annotate.enable) { + if(!data.annotations || data.annotations.length === 0) { return; } options.events = { levels: 1, - data: scope.annotations, + data: data.annotations, types: { 'annotation': { level: 1, diff --git a/src/app/panels/annotations/module.html b/src/app/panels/annotations/module.html index fc847469f9b..2b7449d8c65 100644 --- a/src/app/panels/annotations/module.html +++ b/src/app/panels/annotations/module.html @@ -1,8 +1,13 @@
- \ No newline at end of file diff --git a/src/app/panels/annotations/module.js b/src/app/panels/annotations/module.js index cc499eb006e..5475d50128e 100644 --- a/src/app/panels/annotations/module.js +++ b/src/app/panels/annotations/module.js @@ -14,7 +14,7 @@ function (angular, app, _) { var module = angular.module('kibana.panels.annotations', []); app.useModule(module); - module.controller('AnnotationsCtrl', function($scope) { + module.controller('AnnotationsCtrl', function($scope, dashboard, annotationsSrv, $rootScope) { $scope.panelMeta = { status : "Stable", @@ -24,19 +24,26 @@ function (angular, app, _) { // Set and populate defaults var _d = { }; + _.defaults($scope.panel,_d); $scope.init = function() { - $scope.panel.annotations = [ - { - type: 'graphite-target', - target: 'metric' - }, - { - type: 'graphite-target', - target: 'metric2' - } - ]; + $scope.annotationList = annotationsSrv.annotationList; + }; + + $scope.hideAll = function () { + $scope.panel.hideAll = !$scope.panel.hideAll; + + _.each($scope.annotationList, function(annotation) { + annotation.enabled = !$scope.panel.hideAll; + }); + }; + + $scope.hide = function (annotation) { + annotation.enabled = !annotation.enabled; + $scope.panel.hideAll = !annotation.enabled; + + $rootScope.$broadcast('refresh'); }; diff --git a/src/app/panels/graphite/module.js b/src/app/panels/graphite/module.js index 6f71f1c3f19..b419cf15a47 100644 --- a/src/app/panels/graphite/module.js +++ b/src/app/panels/graphite/module.js @@ -34,7 +34,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { var module = angular.module('kibana.panels.graphite', []); app.useModule(module); - module.controller('graphite', function($scope, $rootScope, filterSrv, graphiteSrv, $timeout) { + module.controller('graphite', function($scope, $rootScope, filterSrv, graphiteSrv, $timeout, annotationsSrv) { $scope.panelMeta = { modals : [], @@ -243,6 +243,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.updateTimeRange = function () { $scope.range = filterSrv.timeRange(); + $scope.rangeUnparsed = filterSrv.timeRange(false); + $scope.interval = '10m'; if ($scope.range) { @@ -279,12 +281,14 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.updateTimeRange(); var graphiteQuery = { - range: filterSrv.timeRange(false), + range: $scope.rangeUnparsed, targets: $scope.panel.targets, - renderer: $scope.panel.renderer, + format: $scope.panel.renderer === 'png' ? 'png' : 'json', maxDataPoints: $scope.panel.span * 50 }; + $scope.annotationsPromise = annotationsSrv.getAnnotations($scope.rangeUnparsed); + return graphiteSrv.query(graphiteQuery) .then($scope.receiveGraphiteData) .then(null, function(err) { @@ -327,7 +331,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) { data.push(series); }); - $scope.render(data); + $scope.annotationsPromise + .then(function(annotations) { + data.annotations = annotations; + $scope.render(data); + }, function() { + $scope.render(data); + }); }; $scope.add_target = function() { diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 77c8541f60d..5549b4f5239 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -1,17 +1,5 @@ - - -