Commit b4980385 by Torkel Ödegaard

Closes #44, Closes #8. Fist release of annotations feature is ready

parent 7b906aa2
...@@ -11,5 +11,6 @@ define([ ...@@ -11,5 +11,6 @@ define([
'./configModal', './configModal',
'./spectrumPicker', './spectrumPicker',
'./grafanaGraph', './grafanaGraph',
'./bootstrap-tagsinput' './bootstrap-tagsinput',
'./bodyClass'
], function () {}); ], function () {});
\ No newline at end of file
define([
'angular',
'app',
'underscore'
],
function (angular, app, _) {
'use strict';
angular
.module('kibana.directives')
.directive('bodyClass', function() {
return {
link: function($scope, elem) {
var lastPulldownVal;
var lastHideControlsVal;
$scope.$watch('dashboard.current.pulldowns', function() {
var panel = _.find($scope.dashboard.current.pulldowns, function(pulldown) { return pulldown.enable; });
var panelEnabled = panel ? panel.enable : false;
if (lastPulldownVal !== panelEnabled) {
elem.toggleClass('submenu-controls-visible', panelEnabled);
lastPulldownVal = panelEnabled;
}
}, true);
$scope.$watch('dashboard.current.hideControls', function() {
var hideControls = $scope.dashboard.current.hideControls;
if (lastHideControlsVal !== hideControls) {
elem.toggleClass('hide-controls', hideControls);
lastHideControlsVal = hideControls;
}
});
}
};
});
});
\ No newline at end of file
...@@ -223,7 +223,7 @@ function (angular, $, kbn, moment, _) { ...@@ -223,7 +223,7 @@ function (angular, $, kbn, moment, _) {
types[event.annotation.name] = { types[event.annotation.name] = {
level: _.keys(types).length + 1, level: _.keys(types).length + 1,
icon: { icon: {
icon: "icon-chevron-up", icon: "icon-chevron-down",
size: event.annotation.iconSize, size: event.annotation.iconSize,
color: event.annotation.iconColor, color: event.annotation.iconColor,
} }
......
...@@ -30,9 +30,9 @@ function (angular, app, _) { ...@@ -30,9 +30,9 @@ function (angular, app, _) {
name: '', name: '',
type: 'graphite metric', type: 'graphite metric',
showLine: true, showLine: true,
iconColor: '#E24D42', iconColor: '#C0C6BE',
lineColor: '#E24D42', lineColor: 'rgba(255, 96, 96, 0.592157)',
iconSize: 15, iconSize: 13,
enable: true enable: true
}; };
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="container-fluid main" ng-class="{'grafana-dashboard-hide-controls': dashboard.current.hideControls}"> <div class="container-fluid main">
<div> <div>
<div class="grafana-container container"> <div class="grafana-container container">
<!-- Rows --> <!-- Rows -->
......
...@@ -30,7 +30,7 @@ define([ ...@@ -30,7 +30,7 @@ define([
this.getAnnotations = function(rangeUnparsed) { this.getAnnotations = function(rangeUnparsed) {
if (!annotationPanel.enable) { if (!annotationPanel.enable) {
return $q.when([]); return $q.when(null);
} }
if (promiseCached) { if (promiseCached) {
...@@ -40,7 +40,7 @@ define([ ...@@ -40,7 +40,7 @@ define([
var graphiteMetrics = this.getGraphiteMetrics(rangeUnparsed); var graphiteMetrics = this.getGraphiteMetrics(rangeUnparsed);
var graphiteEvents = this.getGraphiteEvents(rangeUnparsed); var graphiteEvents = this.getGraphiteEvents(rangeUnparsed);
promiseCached = $q.all([graphiteMetrics, graphiteEvents]) promiseCached = $q.all(graphiteMetrics.concat(graphiteEvents))
.then(function() { .then(function() {
return list; return list;
}); });
...@@ -51,23 +51,27 @@ define([ ...@@ -51,23 +51,27 @@ define([
this.getGraphiteEvents = function(rangeUnparsed) { this.getGraphiteEvents = function(rangeUnparsed) {
var annotations = this.getAnnotationsByType('graphite events'); var annotations = this.getAnnotationsByType('graphite events');
if (annotations.length === 0) { if (annotations.length === 0) {
return $q.when(null); return [];
} }
var tags = _.pluck(annotations, 'tags'); var promises = _.map(annotations, function(annotation) {
var eventsQuery = {
range: rangeUnparsed,
tags: tags.join(' '),
};
return datasourceSrv.default.events(eventsQuery) return datasourceSrv.default.events({ range: rangeUnparsed, tags: annotation.tags })
.then(function(results) { .then(function(results) {
_.each(results.data, function (event) { _.each(results.data, function (event) {
list.push(createAnnotation(annotations[0], event.when * 1000, event.what, event.tags, event.data)); addAnnotation({
annotation: annotation,
time: event.when * 1000,
description: event.what,
tags: event.tags,
data: event.data
});
}); });
}) })
.then(null, errorHandler); .then(null, errorHandler);
});
return promises;
}; };
this.getAnnotationsByType = function(type) { this.getAnnotationsByType = function(type) {
...@@ -80,7 +84,7 @@ define([ ...@@ -80,7 +84,7 @@ define([
this.getGraphiteMetrics = function(rangeUnparsed) { this.getGraphiteMetrics = function(rangeUnparsed) {
var annotations = this.getAnnotationsByType('graphite metric'); var annotations = this.getAnnotationsByType('graphite metric');
if (annotations.length === 0) { if (annotations.length === 0) {
return $q.when(null); return [];
} }
var promises = _.map(annotations, function(annotation) { var promises = _.map(annotations, function(annotation) {
...@@ -98,7 +102,7 @@ define([ ...@@ -98,7 +102,7 @@ define([
.then(null, errorHandler); .then(null, errorHandler);
}); });
return $q.all(promises); return promises;
}; };
function errorHandler(err) { function errorHandler(err) {
...@@ -114,28 +118,28 @@ define([ ...@@ -114,28 +118,28 @@ define([
var datapoint = target.datapoints[y]; var datapoint = target.datapoints[y];
if (datapoint[0] !== null) { if (datapoint[0] !== null) {
list.push(createAnnotation({ addAnnotation({
annotation: annotation, annotation: annotation,
time: datapoint[1] * 1000, time: datapoint[1] * 1000,
description: target.target description: target.target
})); });
} }
} }
} }
} }
function createAnnotation(options) { function addAnnotation(options) {
var tooltip = "<small><b>" + options.description + "</b><br/>"; var tooltip = "<small><b>" + options.description + "</b><br/>";
if (options.tags) { if (options.tags) {
tooltip += (options.tags || '') + '<br/>'; tooltip += (options.tags || '') + '<br/>';
} }
tooltip += '<i>' + moment(options.time).format('YYYY-MM-DD HH:mm:ss') + '</i><br/>'; tooltip += '<i>' + moment(options.time).format('YYYY-MM-DD HH:mm:ss') + '</i><br/>';
if (options.data) { if (options.data) {
tooltip += data; tooltip += options.data;
} }
tooltip += "</small>"; tooltip += "</small>";
return { list.push({
annotation: options.annotation, annotation: options.annotation,
min: options.time, min: options.time,
max: options.time, max: options.time,
...@@ -143,7 +147,7 @@ define([ ...@@ -143,7 +147,7 @@ define([
title: null, title: null,
description: tooltip, description: tooltip,
score: 1 score: 1
}; });
} }
// Now init // Now init
......
...@@ -28,7 +28,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) { ...@@ -28,7 +28,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
failover: false, failover: false,
panel_hints: true, panel_hints: true,
rows: [], rows: [],
pulldowns: [ { type: 'filtering' }, { type: 'annotations' } ], pulldowns: [ { type: 'templating' }, { type: 'annotations' } ],
nav: [ { type: 'timepicker' } ], nav: [ { type: 'timepicker' } ],
services: {}, services: {},
loader: { loader: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
@import "submenu.less"; @import "submenu.less";
@import "bootstrap-tagsinput.less"; @import "bootstrap-tagsinput.less";
.grafana-dashboard-hide-controls { .hide-controls {
padding: 0; padding: 0;
.grafana-row { .grafana-row {
display: none; display: none;
} }
.submenu-controls {
display: none;
}
} }
// Search // Search
......
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
} }
} }
.submenu-controls-visible:not(.hide-controls) {
.panel-fullscreen {
top: 82px;
}
}
.submenu-panel { .submenu-panel {
padding: 0 4px 0 8px; padding: 0 4px 0 8px;
border-right: 1px solid @submenuBorder; border-right: 1px solid @submenuBorder;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</head> </head>
<body ng-cloak> <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">-->
<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