From 10f9022d7c706306acbe4975d9296a981c17f845 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 19 Sep 2014 14:03:08 +0100 Subject: [PATCH 1/7] Support fields from nested objects pulled from Elasticsearch --- .../services/elasticsearch/es-datasource.js | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/app/services/elasticsearch/es-datasource.js b/src/app/services/elasticsearch/es-datasource.js index ab03c614a83..4cc1da3843e 100644 --- a/src/app/services/elasticsearch/es-datasource.js +++ b/src/app/services/elasticsearch/es-datasource.js @@ -86,7 +86,23 @@ function (angular, _, config, kbn, moment) { var list = []; var hits = results.data.hits.hits; + var getFieldFromSource = function(source, fieldName) { + var fieldValue; + if (fieldName) { + var fieldNames = fieldName.split('.'); + fieldValue = source; + for (var i = 0; i < fieldNames.length; i++) { + fieldValue = fieldValue[fieldNames[i]]; + } + if (_.isArray(fieldValue)) { + fieldValue = fieldValue.join(','); + } + } + return fieldValue; + }; + for (var i = 0; i < hits.length; i++) { + console.log('annotationQuery', hits[i]); var source = hits[i]._source; var fields = hits[i].fields; var time = source[timeField]; @@ -98,21 +114,11 @@ function (angular, _, config, kbn, moment) { var event = { annotation: annotation, time: moment.utc(time).valueOf(), - title: source[titleField], + title: getFieldFromSource(source, titleField), + tags: getFieldFromSource(source, tagsField), + text: getFieldFromSource(source, textField) }; - if (source[tagsField]) { - if (_.isArray(source[tagsField])) { - event.tags = source[tagsField].join(', '); - } - else { - event.tags = source[tagsField]; - } - } - if (textField && source[textField]) { - event.text = source[textField]; - } - list.push(event); } return list; From 06ec91c899ed69bf32a8b628c86c353151c8497c Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 19 Sep 2014 14:16:53 +0100 Subject: [PATCH 2/7] Give maximum width & height constraint to tooltip boxes Extreme values that go beyond the screen resolution are very likely to be misplaced. This is a simple workaround. A better solution would be to improve the code placing the tooltip and make it handle tooltips containing more content than they can safely display. --- src/css/less/grafana.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index 8d52f749ff5..b291b548219 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -435,6 +435,9 @@ select.grafana-target-segment-input { background-color: rgb(58, 57, 57); border-radius: 5px; z-index: 9999; + max-width: 800px; + max-height: 600px; + overflow: hidden; } .tooltip.in { From 40a491a80bb5beac046128a01ec59c453edbf4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 20 Sep 2014 08:30:59 +0200 Subject: [PATCH 3/7] Annotations: Elasticsearch annotation and field mapping fixes, small changes for PR #830 --- CHANGELOG.md | 1 + src/app/directives/grafanaGraph.js | 5 ----- src/app/services/annotationsSrv.js | 3 ++- .../services/elasticsearch/es-datasource.js | 22 +++++++++---------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d233c8237..69835953dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [Issue #795](https://github.com/grafana/grafana/issues/795). Chrome: Fix for display issue in chrome beta & chrome canary when entering edit mode - [Issue #818](https://github.com/grafana/grafana/issues/818). Graph: Added percent y-axis format - [Issue #828](https://github.com/grafana/grafana/issues/828). Elasticsearch: saving new dashboard with title equal to slugified url would cause it to deleted. +- [Issue #830](https://github.com/grafana/grafana/issues/830). Annotations: Fix for elasticsearch annotations and mapping nested fields # 1.8.0-RC1 (2014-09-12) diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index ee6b0fb7dd7..15f1556aa62 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -110,11 +110,6 @@ function (angular, $, kbn, moment, _) { // Populate element var options = { - hooks: { - drawSeries: [function() { - console.log('drawSeries', arguments); - }] - }, legend: { show: false }, series: { stackpercent: panel.stack ? panel.percentage : false, diff --git a/src/app/services/annotationsSrv.js b/src/app/services/annotationsSrv.js index c1733189462..04fb4224cc6 100644 --- a/src/app/services/annotationsSrv.js +++ b/src/app/services/annotationsSrv.js @@ -57,7 +57,8 @@ define([ function errorHandler(err) { console.log('Annotation error: ', err); - alertSrv.set('Annotations','Could not fetch annotations','error'); + var message = err.message || "Aannotation query failed"; + alertSrv.set('Annotations error', message,'error'); } function addAnnotation(options) { diff --git a/src/app/services/elasticsearch/es-datasource.js b/src/app/services/elasticsearch/es-datasource.js index 4cc1da3843e..04d1e62ce04 100644 --- a/src/app/services/elasticsearch/es-datasource.js +++ b/src/app/services/elasticsearch/es-datasource.js @@ -87,22 +87,22 @@ function (angular, _, config, kbn, moment) { var hits = results.data.hits.hits; var getFieldFromSource = function(source, fieldName) { - var fieldValue; - if (fieldName) { - var fieldNames = fieldName.split('.'); - fieldValue = source; - for (var i = 0; i < fieldNames.length; i++) { - fieldValue = fieldValue[fieldNames[i]]; - } - if (_.isArray(fieldValue)) { - fieldValue = fieldValue.join(','); - } + if (!fieldName) { return; } + + var fieldNames = fieldName.split('.'); + var fieldValue = source; + + for (var i = 0; i < fieldNames.length; i++) { + fieldValue = fieldValue[fieldNames[i]]; + } + + if (_.isArray(fieldValue)) { + fieldValue = fieldValue.join(', '); } return fieldValue; }; for (var i = 0; i < hits.length; i++) { - console.log('annotationQuery', hits[i]); var source = hits[i]._source; var fields = hits[i].fields; var time = source[timeField]; From a19a2c70abf01bcf3a9979bc5aa7a51a3dbe3893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 20 Sep 2014 08:33:16 +0200 Subject: [PATCH 4/7] Fixed spelling in config.sample.js --- src/config.sample.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/config.sample.js b/src/config.sample.js index 6046a753d5a..740c0d4b8c9 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -1,8 +1,7 @@ -///// @scratch /configuration/config.js/1 - // == Configuration - // config.js is where you will find the core Grafana configuration. This file contains parameter that - // must be set before Grafana is run for the first time. - /// +// == Configuration +// config.js is where you will find the core Grafana configuration. This file contains parameter that +// must be set before Grafana is run for the first time. + define(['settings'], function (Settings) { "use strict"; @@ -97,7 +96,7 @@ function (Settings) { // Change window title prefix from 'Grafana - ' window_title_prefix: 'Grafana - ', - // Add your own custom pannels + // Add your own custom panels plugins: { // list of plugin panels panels: [], From b56c3eb035db4287fdef8629a4dfcc522c8c5928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 20 Sep 2014 13:32:26 +0200 Subject: [PATCH 5/7] Changed color for warning alert --- src/css/less/variables.dark.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/less/variables.dark.less b/src/css/less/variables.dark.less index 608dfb609b0..c65a6f99179 100644 --- a/src/css/less/variables.dark.less +++ b/src/css/less/variables.dark.less @@ -257,7 +257,7 @@ // Form states and alerts // ------------------------- @warningText: darken(#c09853, 10%); -@warningBackground: @grayLighter; +@warningBackground: @orange; @warningBorder: transparent; @errorText: #b94a48; From 4f261389db0ac42a5662eef3b42045824a12e8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 20 Sep 2014 16:55:02 +0200 Subject: [PATCH 6/7] changed placement of color selector popup --- src/app/panels/graph/legend.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/graph/legend.html b/src/app/panels/graph/legend.html index 0e5edc459ce..31458060803 100755 --- a/src/app/panels/graph/legend.html +++ b/src/app/panels/graph/legend.html @@ -5,7 +5,7 @@ ng-class="{'pull-right': series.yaxis === 2, 'graph-legend-series-hidden': hiddenSeries[series.alias]}" >
- +
From e82d17104185f9565c8cc0500c67ed517fe1fb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 21 Sep 2014 08:19:41 +0200 Subject: [PATCH 7/7] Dashboard: when opening search or dashboard settings, click the icon again will now hide the view, Closes #836 --- src/app/directives/dashEditLink.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/directives/dashEditLink.js b/src/app/directives/dashEditLink.js index fbdfc4fa5cc..599cf341fe5 100644 --- a/src/app/directives/dashEditLink.js +++ b/src/app/directives/dashEditLink.js @@ -51,9 +51,12 @@ function (angular, $) { scope.onAppEvent('hide-dash-editor', hideEditorPane); scope.onAppEvent('show-dash-editor', function(evt, payload) { - hideEditorPane(); + if (lastEditor === payload.src) { + hideEditorPane(); + return; + } - if (lastEditor === payload.src) { return; } + hideEditorPane(); scope.exitFullscreen();