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 @@ - - -