From 98d934c8a4507c790906495cd0b5a0eba3ccdc56 Mon Sep 17 00:00:00 2001 From: Jo De Boeck Date: Tue, 11 Nov 2014 19:20:06 +0200 Subject: [PATCH 01/19] Add mbytes and kbytes y_formats Usefull when input data is stored in kbytes or mbytes --- src/app/components/kbn.js | 2 ++ src/app/panels/graph/axisEditor.html | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 567e7c78f23..a9fe6c08f5b 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -362,6 +362,8 @@ function($, _, moment) { kbn.valueFormats.bits = kbn.formatFuncCreator(1024, [' b', ' Kib', ' Mib', ' Gib', ' Tib', ' Pib', ' Eib', ' Zib', ' Yib']); kbn.valueFormats.bytes = kbn.formatFuncCreator(1024, [' B', ' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB']); + kbn.valueFormats.kbytes = kbn.formatFuncCreator(1024, [' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB']); + kbn.valueFormats.mbytes = kbn.formatFuncCreator(1024, [' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB']); kbn.valueFormats.bps = kbn.formatFuncCreator(1000, [' bps', ' Kbps', ' Mbps', ' Gbps', ' Tbps', ' Pbps', ' Ebps', ' Zbps', ' Ybps']); kbn.valueFormats.short = kbn.formatFuncCreator(1000, ['', ' K', ' Mil', ' Bil', ' Tri', ' Qaudr', ' Quint', ' Sext', ' Sept']); kbn.valueFormats.none = kbn.toFixed; diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 7c1b3d73b04..6f6c5b45dae 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -4,7 +4,7 @@
Left Y Axis
- +
@@ -23,7 +23,7 @@
Right Y Axis
- +
From a77c33d9b7c6960bd31f517361f5fdf20bcd6ba0 Mon Sep 17 00:00:00 2001 From: chrono Date: Fri, 14 Nov 2014 14:19:55 +0100 Subject: [PATCH 02/19] Added J,W & eV to unit formatting --- src/app/components/kbn.js | 3 +++ src/app/panels/graph/axisEditor.html | 4 ++-- src/app/panels/graph/graph.js | 9 +++++++++ src/app/panels/singlestat/editor.html | 3 +-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index ecef4bd164e..5e2a30fb3da 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -364,6 +364,9 @@ function($, _, moment) { kbn.valueFormats.bytes = kbn.formatFuncCreator(1024, [' B', ' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB']); kbn.valueFormats.bps = kbn.formatFuncCreator(1000, [' bps', ' Kbps', ' Mbps', ' Gbps', ' Tbps', ' Pbps', ' Ebps', ' Zbps', ' Ybps']); kbn.valueFormats.short = kbn.formatFuncCreator(1000, ['', ' K', ' Mil', ' Bil', ' Tri', ' Qaudr', ' Quint', ' Sext', ' Sept']); + kbn.valueFormats.joule = kbn.formatFuncCreator(1000, [' J', ' kJ', ' MJ', 'GJ', 'TJ', 'PJ', 'EJ', 'ZJ', 'YJ']); + kbn.valueFormats.watt = kbn.formatFuncCreator(1000, [' W', ' kW', ' MW', 'GW', 'TW', 'PW', 'EW', 'ZW', 'YW']); + kbn.valueFormats.ev = kbn.formatFuncCreator(1000, [' eV', ' keV', ' MeV', 'GeV', 'TeV', 'PeV', 'EeV', 'ZeV', 'YeV']); kbn.valueFormats.none = kbn.toFixed; kbn.valueFormats.ms = function(size, decimals, scaledDecimals) { diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 7c1b3d73b04..6951caac287 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -4,7 +4,7 @@
Left Y Axis
- +
@@ -23,7 +23,7 @@
Right Y Axis
- +
diff --git a/src/app/panels/graph/graph.js b/src/app/panels/graph/graph.js index e0ddfc76402..d38f11be3c3 100755 --- a/src/app/panels/graph/graph.js +++ b/src/app/panels/graph/graph.js @@ -402,6 +402,15 @@ function (angular, $, kbn, moment, _, GraphTooltip) { case 'short': url += '&yUnitSystem=si'; break; + case 'joule': + url += '&yUnitSystem=si'; + break; + case 'watt': + url += '&yUnitSystem=si'; + break; + case 'ev': + url += '&yUnitSystem=si'; + break; case 'none': url += '&yUnitSystem=none'; break; diff --git a/src/app/panels/singlestat/editor.html b/src/app/panels/singlestat/editor.html index 885b1f20077..1e34243ca29 100644 --- a/src/app/panels/singlestat/editor.html +++ b/src/app/panels/singlestat/editor.html @@ -35,7 +35,7 @@
Formats
- +
@@ -73,4 +73,3 @@
- From 16f7f68636202d658337cee06ab57dbd319e480a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 9 Jan 2015 09:37:42 +0100 Subject: [PATCH 03/19] Plugins: fixed broken example panel plugin, Fixes #1318 --- src/plugins/custom.panel.example/module.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/plugins/custom.panel.example/module.js b/src/plugins/custom.panel.example/module.js index d04d8fca959..8ed4a450533 100644 --- a/src/plugins/custom.panel.example/module.js +++ b/src/plugins/custom.panel.example/module.js @@ -2,9 +2,9 @@ define([ 'angular', 'app', 'lodash', - 'require', + 'components/panelmeta', ], -function (angular, app, _) { +function (angular, app, _, PanelMeta) { 'use strict'; var module = angular.module('grafana.panels.custom', []); @@ -12,9 +12,9 @@ function (angular, app, _) { module.controller('CustomPanelCtrl', function($scope, panelSrv) { - $scope.panelMeta = { - description : "Example plugin panel", - }; + $scope.panelMeta = new PanelMeta({ + description : "A static text panel that can use plain text, markdown, or (sanitized) HTML" + }); // set and populate defaults var _d = { @@ -22,10 +22,6 @@ function (angular, app, _) { _.defaults($scope.panel, _d); - $scope.init = function() { - panelSrv.init($scope); - }; - - $scope.init(); + panelSrv.init($scope); }); }); From 4edf0c976871974192ea1a5b6f52a1adf3e4ee6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 9 Jan 2015 16:28:58 +0100 Subject: [PATCH 04/19] Fixed alert popup close icon --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 84e7787b83d..779c54d7ef0 100644 --- a/src/index.html +++ b/src/index.html @@ -27,7 +27,7 @@
{{alert.title}}
From 92c3d801893bf67de31ef953382fb77a5873ba9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 10 Jan 2015 12:49:35 +0100 Subject: [PATCH 05/19] SingleStatPanel: You can now use template variables in pre & postfix, Closes #1321 --- CHANGELOG.md | 1 + src/app/panels/singlestat/singleStatPanel.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0331dfd5d95..578156a0229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ **Enhancements** - [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions - [Issue #1296](https://github.com/grafana/grafana/issues/1296). InfluxDB: Auto escape column names with special characters. Thanks @steven-aerts +- [Issue #1321](https://github.com/grafana/grafana/issues/1321). SingleStatPanel: You can now use template variables in pre & postfix **Fixes** - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query diff --git a/src/app/panels/singlestat/singleStatPanel.js b/src/app/panels/singlestat/singleStatPanel.js index 01ecfe2499d..80e3fa1391d 100644 --- a/src/app/panels/singlestat/singleStatPanel.js +++ b/src/app/panels/singlestat/singleStatPanel.js @@ -11,7 +11,7 @@ function (angular, app, _, $) { var module = angular.module('grafana.panels.singlestat', []); app.useModule(module); - module.directive('singlestatPanel', function($location, linkSrv, $timeout) { + module.directive('singlestatPanel', function($location, linkSrv, $timeout, templateSrv) { return { link: function(scope, elem) { @@ -63,6 +63,7 @@ function (angular, app, _, $) { } function getSpan(className, fontSize, value) { + value = templateSrv.replace(value); return '' + value + ''; } From ccbe055e5b482edea8f65005b6d12477ae986c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 11 Jan 2015 20:04:33 +0100 Subject: [PATCH 06/19] Graph: Added right y axis label setting and graph support, Closes #599 --- CHANGELOG.md | 1 + src/app/panels/graph/axisEditor.html | 6 +++- src/app/panels/graph/graph.js | 50 +++++++++++++++++----------- src/css/less/grafana.less | 23 ------------- src/css/less/graph.less | 41 +++++++++++++++++++++++ 5 files changed, 78 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 578156a0229..c0c5802ccef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions - [Issue #1296](https://github.com/grafana/grafana/issues/1296). InfluxDB: Auto escape column names with special characters. Thanks @steven-aerts - [Issue #1321](https://github.com/grafana/grafana/issues/1321). SingleStatPanel: You can now use template variables in pre & postfix +- [Issue #599](https://github.com/grafana/grafana/issues/599). Graph: Added right y axis label setting and graph support **Fixes** - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 36353464324..9965d7ff2f2 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -16,7 +16,7 @@
- +
@@ -32,6 +32,10 @@
+
+
+ +
diff --git a/src/app/panels/graph/graph.js b/src/app/panels/graph/graph.js index 62fd543d0e8..48bd68c9483 100755 --- a/src/app/panels/graph/graph.js +++ b/src/app/panels/graph/graph.js @@ -109,9 +109,9 @@ function (angular, $, kbn, moment, _, GraphTooltip) { } } - function updateLegendValues(plot) { + function drawHook(plot) { + // Update legend values var yaxis = plot.getYAxes(); - for (var i = 0; i < data.length; i++) { var series = data[i]; var axis = yaxis[series.yaxis - 1]; @@ -124,6 +124,29 @@ function (angular, $, kbn, moment, _, GraphTooltip) { series.updateLegendValues(formater, tickDecimals, axis.scaledDecimals + 2); if(!scope.$$phase) { scope.$digest(); } } + + // add left axis labels + if (scope.panel.leftYAxisLabel) { + var yaxisLabel = $("
") + .text(scope.panel.leftYAxisLabel) + .appendTo(elem); + + yaxisLabel.css("margin-top", yaxisLabel.width() / 2); + } + + // add right axis labels + if (scope.panel.rightYAxisLabel) { + var rightLabel = $("
") + .text(scope.panel.rightYAxisLabel) + .appendTo(elem); + + rightLabel.css("margin-top", rightLabel.width() / 2); + } + } + + function processOffsetHook(plot, gridMargin) { + if (scope.panel.leftYAxisLabel) { gridMargin.left = 20; } + if (scope.panel.rightYAxisLabel) { gridMargin.right = 20; } } // Function for rendering panel @@ -137,7 +160,10 @@ function (angular, $, kbn, moment, _, GraphTooltip) { // Populate element var options = { - hooks: { draw: [updateLegendValues] }, + hooks: { + draw: [drawHook], + processOffset: [processOffsetHook], + }, legend: { show: false }, series: { stackpercent: panel.stack ? panel.percentage : false, @@ -173,7 +199,8 @@ function (angular, $, kbn, moment, _, GraphTooltip) { backgroundColor: null, borderWidth: 0, hoverable: true, - color: '#c8c8c8' + color: '#c8c8c8', + margin: { left: 0, right: 0 }, }, selection: { mode: "x", @@ -213,8 +240,6 @@ function (angular, $, kbn, moment, _, GraphTooltip) { } catch (e) { console.log('flotcharts error', e); } - - addAxisLabels(); } if (shouldDelayDraw(panel)) { @@ -317,19 +342,6 @@ function (angular, $, kbn, moment, _, GraphTooltip) { }; } - function addAxisLabels() { - if (scope.panel.leftYAxisLabel) { - elem.css('margin-left', '10px'); - var yaxisLabel = $("
") - .text(scope.panel.leftYAxisLabel) - .appendTo(elem); - - yaxisLabel.css("margin-top", yaxisLabel.width() / 2 - 20); - } else if (elem.css('margin-left')) { - elem.css('margin-left', ''); - } - } - function configureAxisOptions(data, options) { var defaults = { position: 'left', diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index edaa639a897..d5dad2c7920 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -87,29 +87,6 @@ } } -.yaxisLabel { - top: 50%; - left: -20px; - transform: rotate(-90deg); - -o-transform: rotate(-90deg); - -ms-transform: rotate(-90deg); - -moz-transform: rotate(-90deg); - -webkit-transform: rotate(-90deg); - transform-origin: 0 0; - -o-transform-origin: 0 0; - -ms-transform-origin: 0 0; - -moz-transform-origin: 0 0; - -webkit-transform-origin: 0 0; -} - -.axisLabel { - color: @textColor; - font-size: @fontSizeSmall; - position: absolute; - text-align: center; - font-size: 12px; -} - .dashboard-fullscreen { .main-view-container { overflow: hidden; diff --git a/src/css/less/graph.less b/src/css/less/graph.less index d6856f5bbf9..5ad38283689 100644 --- a/src/css/less/graph.less +++ b/src/css/less/graph.less @@ -228,3 +228,44 @@ text-align: right; } } + +.left-yaxis-label { + top: 50%; + left: -5px; + transform: rotate(-90deg); + -o-transform: rotate(-90deg); + -ms-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); + -webkit-transform: rotate(-90deg); + transform-origin: left top; + -o-transform-origin: left top; + -ms-transform-origin: left top; + -moz-transform-origin: left top; + -webkit-transform-origin: left top; +} + +.right-yaxis-label { + top: 50%; + right: -5px; + + -webkit-transform: rotate(90deg); + -webkit-transform-origin: right top; + -moz-transform: rotate(90deg); + -moz-transform-origin: right top; + -ms-transform: rotate(90deg); + -ms-transform-origin: right top; + -o-transform: rotate(90deg); + -o-transform-origin: right top; + transform: rotate(90deg); + transform-origin: right top; +} + + +.axisLabel { + color: @textColor; + font-size: @fontSizeSmall; + position: absolute; + text-align: center; + font-size: 12px; +} + From 09a0ef2013eecb12864b71ea324e645576049a56 Mon Sep 17 00:00:00 2001 From: Ties Bos Date: Sun, 11 Jan 2015 22:19:59 -0800 Subject: [PATCH 07/19] Add Bps support, much like bps --- src/app/components/kbn.js | 1 + src/app/panels/graph/axisEditor.html | 4 ++-- src/app/panels/graph/graph.js | 3 +++ src/app/panels/singlestat/editor.html | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index aedfbb90f17..63c785b9ff5 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -363,6 +363,7 @@ function($, _, moment) { kbn.valueFormats.bits = kbn.formatFuncCreator(1024, [' b', ' Kib', ' Mib', ' Gib', ' Tib', ' Pib', ' Eib', ' Zib', ' Yib']); kbn.valueFormats.bytes = kbn.formatFuncCreator(1024, [' B', ' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB']); kbn.valueFormats.bps = kbn.formatFuncCreator(1000, [' bps', ' Kbps', ' Mbps', ' Gbps', ' Tbps', ' Pbps', ' Ebps', ' Zbps', ' Ybps']); + kbn.valueFormats.Bps = kbn.formatFuncCreator(1000, [' Bps', ' KBps', ' MBps', ' GBps', ' TBps', ' PBps', ' EBps', ' ZBps', ' YBps']); kbn.valueFormats.short = kbn.formatFuncCreator(1000, ['', ' K', ' Mil', ' Bil', ' Tri', ' Qaudr', ' Quint', ' Sext', ' Sept']); kbn.valueFormats.none = kbn.toFixed; diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 9965d7ff2f2..45282baaa11 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -4,7 +4,7 @@
Left Y Axis
- +
@@ -23,7 +23,7 @@
Right Y Axis
- +
diff --git a/src/app/panels/graph/graph.js b/src/app/panels/graph/graph.js index 48bd68c9483..b4934a7354c 100755 --- a/src/app/panels/graph/graph.js +++ b/src/app/panels/graph/graph.js @@ -418,6 +418,9 @@ function (angular, $, kbn, moment, _, GraphTooltip) { case 'bps': url += '&yUnitSystem=si'; break; + case 'Bps': + url += '&yUnitSystem=si'; + break; case 'short': url += '&yUnitSystem=si'; break; diff --git a/src/app/panels/singlestat/editor.html b/src/app/panels/singlestat/editor.html index 2460571a4b3..6c83c5ab821 100644 --- a/src/app/panels/singlestat/editor.html +++ b/src/app/panels/singlestat/editor.html @@ -39,7 +39,7 @@
Formats
- +
From 93fb02509b75d42ccc73b4e9f530f3a0ac941cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 09:27:20 +0100 Subject: [PATCH 08/19] Removed flicker when refreshing a singlestat panel with spark line --- src/app/panels/singlestat/singleStatPanel.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/panels/singlestat/singleStatPanel.js b/src/app/panels/singlestat/singleStatPanel.js index 80e3fa1391d..49c248bc5cd 100644 --- a/src/app/panels/singlestat/singleStatPanel.js +++ b/src/app/panels/singlestat/singleStatPanel.js @@ -134,9 +134,7 @@ function (angular, app, _, $) { color: panel.sparkline.lineColor }; - setTimeout(function() { - $.plot(plotCanvas, [plotSeries], options); - }, 10); + $.plot(plotCanvas, [plotSeries], options); } function render() { From 3dc30e4d8bf896e9dcf3d8e7744e7a32939da2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 12:55:19 +0100 Subject: [PATCH 09/19] Major reworking of the graph axis editor tab --- src/app/components/kbn.js | 28 +++ src/app/directives/dropdown.typeahead.js | 51 +++-- src/app/panels/graph/axisEditor.html | 240 +++++++++++++------- src/app/panels/graph/module.js | 6 + src/app/panels/graph/seriesOverridesCtrl.js | 17 +- src/app/panels/graph/styleEditor.html | 2 +- src/app/panels/singlestat/editor.html | 8 +- 7 files changed, 228 insertions(+), 124 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 234c4db122e..2885d3806b3 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -485,5 +485,33 @@ function($, _, moment) { return new RegExp(match[1], match[2]); }; + kbn.getUnitFormats = function() { + return [ + { + text: 'none', + submenu: [ + {text: 'none' , value: 'none'}, + {text: 'short', value: 'short'}, + ] + }, + { + text: 'duration', + submenu: [ + {text: 'nanoseconds (ns)' , value: 'ns'}, + {text: 'microseconds (µs)', value: 'µs'}, + {text: 'milliseconds (ms)', value: 'ms'}, + ] + }, + { + text: 'data', + submenu: [ + {text: 'bit', value: 'bit'}, + {text: 'bytes', value: 'bytes'}, + {text: 'kilobytes', value: 'kbytes'}, + ] + }, + ]; + }; + return kbn; }); diff --git a/src/app/directives/dropdown.typeahead.js b/src/app/directives/dropdown.typeahead.js index f46de052c06..e62663fee8f 100644 --- a/src/app/directives/dropdown.typeahead.js +++ b/src/app/directives/dropdown.typeahead.js @@ -17,35 +17,47 @@ function (angular, app, _, $) { var buttonTemplate = ''; + ' data-placement="top">'; return { scope: { - "menuItems": "=dropdownTypeahead", - "dropdownTypeaheadOnSelect": "&dropdownTypeaheadOnSelect" + menuItems: "=dropdownTypeahead", + dropdownTypeaheadOnSelect: "&dropdownTypeaheadOnSelect", + model: '=ngModel' }, - link: function($scope, elem) { + link: function($scope, elem, attrs) { var $input = $(inputTemplate); var $button = $(buttonTemplate); $input.appendTo(elem); $button.appendTo(elem); - var typeaheadValues = _.reduce($scope.menuItems, function(memo, value) { - _.each(value.submenu, function(item) { + if (attrs.linkText) { + $button.html(attrs.linkText); + } + + if (attrs.ngModel) { + $scope.$watch('model', function(newValue) { + _.each($scope.menuItems, function(item){ + _.each(item.submenu, function(subItem) { + if (subItem.value === newValue) { + $button.html(subItem.text); + } + }); + }); + }); + } + + var typeaheadValues = _.reduce($scope.menuItems, function(memo, value, index) { + _.each(value.submenu, function(item, subIndex) { + item.click = 'menuItemSelected(' + index + ',' + subIndex + ')'; memo.push(value.text + ' ' + item.text); }); return memo; }, []); - $scope.menuItemSelected = function(optionIndex, valueIndex) { - var option = $scope.menuItems[optionIndex]; - var result = { - $item: option.submenu[valueIndex], - $optionIndex: optionIndex, - $valueIndex: valueIndex - }; - - $scope.dropdownTypeaheadOnSelect(result); + $scope.menuItemSelected = function(index, subIndex) { + var item = $scope.menuItems[index]; + $scope.dropdownTypeaheadOnSelect({$item: item, $subItem: item.submenu[subIndex]}); }; $input.attr('data-provide', 'typeahead'); @@ -55,12 +67,11 @@ function (angular, app, _, $) { items: 10, updater: function (value) { var result = {}; - _.each($scope.menuItems, function(menuItem, optionIndex) { - _.each(menuItem.submenu, function(submenuItem, valueIndex) { + _.each($scope.menuItems, function(menuItem) { + _.each(menuItem.submenu, function(submenuItem) { if (value === (menuItem.text + ' ' + submenuItem.text)) { - result.$item = submenuItem; - result.$optionIndex = optionIndex; - result.$valueIndex = valueIndex; + result.$item = menuItem; + result.$subItem = submenuItem; } }); }); diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index c042ec11903..e9ac2e5a325 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -1,90 +1,160 @@
-
Left Y Axis
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
Right Y Axis
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
Legend styles
- - - - - +
+
+
    +
  • + Left Y Axis +
  • +
  • + Unit +
  • + +
  • +    Grid Max +
  • +
  • + +
  • +
  • + Min +
  • +
  • + +
  • +
  • + Label +
  • +
  • + +
  • +
  • + Show +
  • +
+
+
+
+
    +
  • + Right Y Axis +
  • +
  • + Unit +
  • + +
  • +    Grid Max +
  • +
  • + +
  • +
  • + Min +
  • +
  • + +
  • +
  • + Label +
  • +
  • + +
  • +
  • + Show +
  • +
+
+
+
- -
-
Legend values
- - - - - -
- -
-
Grid thresholds
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -
-
Show Axes
- - -
-
+ +
+
+
+
+
    +
  • + Thresholds +
  • +
  • + Level 1 +
  • +
  • + +
  • +
  • + +
  • +
  • + Level 2 +
  • +
  • + +
  • +
  • + +
  • +
  • + Line mode +
  • +
+
+
+
+
+
+ +
+
+
+
+
    +
  • + Legend +
  • +
  • + Show: +
  • +
  • + Table: +
  • +
  • + Right side: +
  • +
  • + Hide empty: +
  • +
  • + Min: +
  • +
  • + Max: +
  • +
  • + Avg: +
  • +
  • + Total: +
  • +
  • + Current: +
  • +
+
+
+
+
+
+ diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index a1ae2bf2b4f..f05c609bdb1 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -104,6 +104,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.hiddenSeries = {}; $scope.seriesList = []; + $scope.unitFormats = kbn.getUnitFormats(); + + $scope.setUnitFormat = function(axis, subItem) { + $scope.panel.y_formats[axis] = subItem.value; + $scope.render(); + }; $scope.updateTimeRange = function () { $scope.range = timeSrv.timeRange(); diff --git a/src/app/panels/graph/seriesOverridesCtrl.js b/src/app/panels/graph/seriesOverridesCtrl.js index 04d66ee5e73..80fb2ead6c2 100644 --- a/src/app/panels/graph/seriesOverridesCtrl.js +++ b/src/app/panels/graph/seriesOverridesCtrl.js @@ -20,26 +20,21 @@ define([ option.index = $scope.overrideMenu.length; option.values = values; - option.submenu = _.map(values, function(value, index) { - return { - text: String(value), - click: 'menuItemSelected(' + option.index + ',' + index + ')' - }; + option.submenu = _.map(values, function(value) { + return { text: String(value), value: value }; }); $scope.overrideMenu.push(option); }; - $scope.setOverride = function(optionIndex, valueIndex) { - var option = $scope.overrideMenu[optionIndex]; - var value = option.values[valueIndex]; - $scope.override[option.propertyName] = value; + $scope.setOverride = function(item, subItem) { + $scope.override[item.propertyName] = subItem.value; // automatically disable lines for this series and the fill bellow to series // can be removed by the user if they still want lines - if (option.propertyName === 'fillBelowTo') { + if (item.propertyName === 'fillBelowTo') { $scope.override['lines'] = false; - $scope.addSeriesOverride({ alias: value, lines: false }); + $scope.addSeriesOverride({ alias: subItem.value, lines: false }); } $scope.updateCurrentOverrides(); diff --git a/src/app/panels/graph/styleEditor.html b/src/app/panels/graph/styleEditor.html index 77eb933f855..f58fbab5c51 100644 --- a/src/app/panels/graph/styleEditor.html +++ b/src/app/panels/graph/styleEditor.html @@ -89,7 +89,7 @@ {{option.name}}: {{option.value}} - diff --git a/src/app/panels/singlestat/editor.html b/src/app/panels/singlestat/editor.html index e1d4646aa67..1381038f10c 100644 --- a/src/app/panels/singlestat/editor.html +++ b/src/app/panels/singlestat/editor.html @@ -39,13 +39,7 @@
Formats
-<<<<<<< HEAD - -||||||| merged common ancestors - -======= - ->>>>>>> 09a0ef2013eecb12864b71ea324e645576049a56 +
From 3a27b610d5f2146169ce17e3469d80a8953b331b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 13:42:16 +0100 Subject: [PATCH 10/19] Added all unit formats to new unit selector, #1331 --- src/app/components/kbn.js | 19 ++++++++++++++++++- src/app/panels/graph/axisEditor.html | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 2885d3806b3..80a2b976f6e 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -492,6 +492,7 @@ function($, _, moment) { submenu: [ {text: 'none' , value: 'none'}, {text: 'short', value: 'short'}, + {text: 'percent', value: 'percent'}, ] }, { @@ -500,16 +501,32 @@ function($, _, moment) { {text: 'nanoseconds (ns)' , value: 'ns'}, {text: 'microseconds (µs)', value: 'µs'}, {text: 'milliseconds (ms)', value: 'ms'}, + {text: 'seconds (s)', value: 's'}, ] }, { text: 'data', submenu: [ - {text: 'bit', value: 'bit'}, + {text: 'bits', value: 'bits'}, {text: 'bytes', value: 'bytes'}, {text: 'kilobytes', value: 'kbytes'}, ] }, + { + text: 'data rate', + submenu: [ + {text: 'bits/sec', value: 'bps'}, + {text: 'bytes/sec', value: 'Bps'}, + ] + }, + { + text: 'energy', + submenu: [ + {text: 'watt', value: 'watt'}, + {text: 'joule', value: 'joule'}, + {text: 'eV', value: 'ev'}, + ] + }, ]; }; diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index e9ac2e5a325..90e3f5c9a68 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -10,7 +10,7 @@
  • Unit
  • -
  • Unit
  • -
  • - +
  • Line mode From c39f9ed2f31b5d8a1ec4dabb342d4a4e3f984e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 14:00:30 +0100 Subject: [PATCH 11/19] More work on refactoring and changing graph axis edit view, #1331 --- src/app/directives/dropdown.typeahead.js | 2 +- src/app/directives/ngModelOnBlur.js | 12 +++++++++++ src/app/panels/graph/axisEditor.html | 22 +++++++++++++++------ src/app/panels/graph/module.js | 5 ----- src/test/specs/seriesOverridesCtrl-specs.js | 8 +------- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/app/directives/dropdown.typeahead.js b/src/app/directives/dropdown.typeahead.js index e62663fee8f..56203ee3c6f 100644 --- a/src/app/directives/dropdown.typeahead.js +++ b/src/app/directives/dropdown.typeahead.js @@ -37,7 +37,7 @@ function (angular, app, _, $) { if (attrs.ngModel) { $scope.$watch('model', function(newValue) { - _.each($scope.menuItems, function(item){ + _.each($scope.menuItems, function(item) { _.each(item.submenu, function(subItem) { if (subItem.value === newValue) { $button.html(subItem.text); diff --git a/src/app/directives/ngModelOnBlur.js b/src/app/directives/ngModelOnBlur.js index 0e9d94a282e..1aea09f9dc8 100644 --- a/src/app/directives/ngModelOnBlur.js +++ b/src/app/directives/ngModelOnBlur.js @@ -22,5 +22,17 @@ function (angular) { }); } }; + }) + .directive('emptyToNull', function () { + return { + restrict: 'A', + require: 'ngModel', + link: function (scope, elm, attrs, ctrl) { + ctrl.$parsers.push(function (viewValue) { + if(viewValue === "") { return null; } + return viewValue; + }); + } + }; }); }); diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 90e3f5c9a68..151f40f264d 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -19,19 +19,24 @@    Grid Max
  • - +
  • Min
  • - +
  • Label
  • - +
  • Show @@ -56,19 +61,24 @@    Grid Max
  • - +
  • Min
  • - +
  • Label
  • - +
  • Show diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index f05c609bdb1..5fbc3a76e6b 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -268,11 +268,6 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.render(); }; - $scope.toggleGridMinMax = function(key) { - $scope.panel.grid[key] = _.toggle($scope.panel.grid[key], null, 0); - $scope.render(); - }; - $scope.addSeriesOverride = function(override) { $scope.panel.seriesOverrides.push(override || {}); }; diff --git a/src/test/specs/seriesOverridesCtrl-specs.js b/src/test/specs/seriesOverridesCtrl-specs.js index 0542e613a34..ec7cc70159c 100644 --- a/src/test/specs/seriesOverridesCtrl-specs.js +++ b/src/test/specs/seriesOverridesCtrl-specs.js @@ -16,15 +16,9 @@ define([ ctx.scope.render = function() {}; }); - describe('Controller should init overrideMenu', function() { - it('click should include option and value index', function() { - expect(ctx.scope.overrideMenu[1].submenu[1].click).to.be('menuItemSelected(1,1)'); - }); - }); - describe('When setting an override', function() { beforeEach(function() { - ctx.scope.setOverride(1, 0); + ctx.scope.setOverride({propertyName: 'lines'}, {value: true}); }); it('should set override property', function() { From a1e39ce24daf16591c44145c460d140e9dd598f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 14:31:15 +0100 Subject: [PATCH 12/19] Fixed show/hide axis toggles, #1331 --- src/app/directives/arrayJoin.js | 1 + src/app/panels/graph/axisEditor.html | 184 +++++++++++++++------------ src/css/less/forms.less | 2 +- 3 files changed, 102 insertions(+), 85 deletions(-) diff --git a/src/app/directives/arrayJoin.js b/src/app/directives/arrayJoin.js index 9f0900d880d..a2b5fbe59dd 100644 --- a/src/app/directives/arrayJoin.js +++ b/src/app/directives/arrayJoin.js @@ -31,4 +31,5 @@ function (angular, app, _) { } }; }); + }); diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 151f40f264d..3bc49e3a1f0 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -5,7 +5,7 @@
    • - Left Y Axis + Left Y
    • Unit @@ -38,16 +38,13 @@
    • -
    • - Show -
    • - Right Y Axis + Right Y
    • Unit @@ -80,8 +77,105 @@
    • +
    +
    +
    +
    +
      +
    • + Show Axis +
    • - Show + X-Axis  + + +
    • +
    • + Y-Axis  + + +
    • +
    +
    +
    + + + + + +
    +
    +
    +
    +
      +
    • + Thresholds +
    • +
    • + Level 1 +
    • +
    • + +
    • +
    • + +
    • +
    • + Level 2 +
    • +
    • + +
    • +
    • + +
    • +
    • + Line mode +
    • +
    +
    +
    + +
    +
    +
    + +
    +
    +
    +
    +
      +
    • + Legend +
    • +
    • + Show: +
    • +
    • + Table: +
    • +
    • + Right side: +
    • +
    • + Hide empty: +
    • +
    • + Min: +
    • +
    • + Max: +
    • +
    • + Avg: +
    • +
    • + Total: +
    • +
    • + Current:
    @@ -90,81 +184,3 @@
    -
    -
    -
    -
    -
      -
    • - Thresholds -
    • -
    • - Level 1 -
    • -
    • - -
    • -
    • - -
    • -
    • - Level 2 -
    • -
    • - -
    • -
    • - -
    • -
    • - Line mode -
    • -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
      -
    • - Legend -
    • -
    • - Show: -
    • -
    • - Table: -
    • -
    • - Right side: -
    • -
    • - Hide empty: -
    • -
    • - Min: -
    • -
    • - Max: -
    • -
    • - Avg: -
    • -
    • - Total: -
    • -
    • - Current: -
    • -
    -
    -
    -
    -
    -
    - diff --git a/src/css/less/forms.less b/src/css/less/forms.less index e1affd09ae9..5018b9329da 100644 --- a/src/css/less/forms.less +++ b/src/css/less/forms.less @@ -15,7 +15,7 @@ input[type="checkbox"]+.cr1 { height: 19px; clear: none; text-indent: 2px; - margin-top: 4px; + margin: 0; padding: 0 0 0 20px; vertical-align:middle; background: url(@checkboxImageUrl) left top no-repeat; From d6f9ff34ce828a18969415d3c8357f6e98e5c2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 15:37:22 +0100 Subject: [PATCH 13/19] More work on new grap axis & grid edit tab, #1331 --- .../features/annotations/partials/editor.html | 4 +- .../graphite/partials/query.editor.html | 98 ++++++++-------- src/app/panels/graph/axisEditor.html | 111 ++++++++++++------ src/css/less/grafana.less | 7 +- 4 files changed, 130 insertions(+), 90 deletions(-) diff --git a/src/app/features/annotations/partials/editor.html b/src/app/features/annotations/partials/editor.html index b6118f15d63..14208dc2ab2 100644 --- a/src/app/features/annotations/partials/editor.html +++ b/src/app/features/annotations/partials/editor.html @@ -53,7 +53,7 @@
    -
    +
    @@ -62,7 +62,7 @@
    -
    +
    diff --git a/src/app/features/graphite/partials/query.editor.html b/src/app/features/graphite/partials/query.editor.html index 8857ab83983..9487106ecdf 100755 --- a/src/app/features/graphite/partials/query.editor.html +++ b/src/app/features/graphite/partials/query.editor.html @@ -7,66 +7,68 @@ ng-init="init()">
    - -
      +
      • {{targetLetters[$index]}} -
      • -
      • - - - -
      • -
      + +
    • + + + +
    • +
    - -
    +
      -
    • +
    • Left Y
    • @@ -19,7 +19,7 @@    Grid Max
    • -
    • @@ -27,7 +27,7 @@ Min
    • -
    • @@ -35,7 +35,7 @@ Label
    • -
    @@ -43,7 +43,7 @@
      -
    • +
    • Right Y
    • @@ -58,7 +58,7 @@    Grid Max
    • -
    • @@ -66,7 +66,7 @@ Min
    • -
    • @@ -74,15 +74,20 @@ Label
    • -
    -
    -
      -
    • +
    +
    + +
    +
    +
    +
      +
    • Show Axis
    • @@ -100,24 +105,17 @@
    - -
    -
    -
    - -
    -
    -
      -
    • +
    • Thresholds
    • Level 1
    • - +
    • @@ -126,56 +124,93 @@ Level 2
    • - +
    • - Line mode + Line mode  + + +
    -
    -
    +
      -
    • +
    • Legend
    • - Show: + Show  + +
    • - Table: + Table  + +
    • - Right side: + Right side  + +
    • - Hide empty: + Hide empty  + + +
    • +
    +
    +
    +
    +
    +
    +
    +
    +
      +
    • + Legend values
    • - Min: + Min  + +
    • - Max: + Max  + +
    • - Avg: + Avg  + +
    • - Total: -
    • -
    • - Current: + Current  + +
    diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index d5dad2c7920..6038356fafb 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -122,7 +122,6 @@ .grafana-segment-list { list-style: none; margin: 0; - margin-right: 90px; >li { float: left; } @@ -168,6 +167,9 @@ padding: 8px 15px; } + &.last { + border-right: none; + } } .grafana-target-segment-icon { @@ -243,7 +245,7 @@ input[type=text].grafana-target-text-input { border-right: 1px solid @grafanaTargetSegmentBorder; } -input[type=text].grafana-target-segment-input { +[type=text].grafana-target-segment-input, [type=number].grafana-target-segment-input { border: none; border-right: 1px solid @grafanaTargetSegmentBorder; margin: 0px; @@ -347,6 +349,7 @@ select.grafana-target-segment-input { background: inherit; border: none; color: inherit; + padding: 0; } .sp-replacer:hover, .sp-replacer.sp-active { From 66631da1c76a67877a6dfe03934358b805932e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 15:47:47 +0100 Subject: [PATCH 14/19] Some last polish to thew new axis editor view, #1331 --- src/app/panels/graph/axisEditor.html | 28 ++++++++++++++-------------- src/css/less/grafana.less | 3 +++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 6af8cb5c25a..5190dd4a56a 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -4,13 +4,13 @@
      -
    • +
    • Left Y
    • Unit
    • -
    • -
    @@ -43,13 +43,13 @@
      -
    • +
    • Right Y
    • Unit
    • -
    • -
    @@ -87,7 +87,7 @@
      -
    • +
    • Show Axis
    • @@ -96,7 +96,7 @@ ng-model="panel['x-axis']" ng-checked="panel['x-axis']" ng-change="render()">
    • -
    • +
    • Y-Axis  @@ -107,7 +107,7 @@
      -
    • +
    • Thresholds
    • @@ -130,7 +130,7 @@
    • -
    • +
    • Line mode  @@ -149,7 +149,7 @@
        -
      • +
      • Legend
      • @@ -170,8 +170,8 @@ ng-model="panel.legend.rightSide" ng-checked="panel.legend.rightSide" ng-change="render()">
      • -
      • - Hide empty  +
      • + Hide empty  @@ -206,7 +206,7 @@ ng-model="panel.legend.avg" ng-checked="panel.legend.avg" ng-change="render()">
      • -
      • +
      • Current  diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index 6038356fafb..fb6e85ac99c 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -251,6 +251,9 @@ input[type=text].grafana-target-text-input { margin: 0px; border-radius: 0; padding: 8px 4px; + &.last { + border-right: none; + } } input[type=checkbox].grafana-target-option-checkbox { From a3da11c5bc001ce5dde69a2af976b9667fa73227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 15:59:22 +0100 Subject: [PATCH 15/19] Fixed legend values check, got rid of the legend values checkbox, #1331 --- src/app/panels/graph/axisEditor.html | 16 +++++++++++----- src/app/panels/graph/module.js | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/app/panels/graph/axisEditor.html b/src/app/panels/graph/axisEditor.html index 5190dd4a56a..a851038b91e 100644 --- a/src/app/panels/graph/axisEditor.html +++ b/src/app/panels/graph/axisEditor.html @@ -191,25 +191,31 @@
      • Min  + ng-model="panel.legend.min" ng-checked="panel.legend.min" ng-change="legendValuesOptionChanged()">
      • Max  + ng-model="panel.legend.max" ng-checked="panel.legend.max" ng-change="legendValuesOptionChanged()">
      • Avg  + ng-model="panel.legend.avg" ng-checked="panel.legend.avg" ng-change="legendValuesOptionChanged()">
      • -
      • +
      • Current  + ng-model="panel.legend.current" ng-checked="panel.legend.current" ng-change="legendValuesOptionChanged()"> + +
      • +
      • + Total  +
      diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 5fbc3a76e6b..7fde36b475f 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -283,6 +283,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.get_data(); }; + $scope.legendValuesOptionChanged = function() { + var legend = $scope.panel.legend; + legend.values = legend.min || legend.max || legend.avg || legend.current || legend.total; + $scope.render(); + }; + $scope.exportCsv = function() { kbn.exportSeriesListToCsv($scope.seriesList); }; From 4544f794719f11589226b3ad88d160f63ff3d1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Jan 2015 16:18:35 +0100 Subject: [PATCH 16/19] Fixed influxdb and opentsdb editors to use latest markup and css, #1331 --- src/app/features/influxdb/funcEditor.js | 2 +- .../influxdb/partials/query.editor.html | 56 ++++++++++--------- .../opentsdb/partials/query.editor.html | 38 +++++++------ src/css/less/grafana.less | 31 ---------- 4 files changed, 50 insertions(+), 77 deletions(-) diff --git a/src/app/features/influxdb/funcEditor.js b/src/app/features/influxdb/funcEditor.js index b96ed301d4d..d072a1fa2c4 100644 --- a/src/app/features/influxdb/funcEditor.js +++ b/src/app/features/influxdb/funcEditor.js @@ -133,4 +133,4 @@ function (angular, _, $) { }); -}); \ No newline at end of file +}); diff --git a/src/app/features/influxdb/partials/query.editor.html b/src/app/features/influxdb/partials/query.editor.html index a960b364e5e..e93cb232b28 100644 --- a/src/app/features/influxdb/partials/query.editor.html +++ b/src/app/features/influxdb/partials/query.editor.html @@ -8,22 +8,24 @@
      -
        -