From c100054d68c1f198bca6741403c017c000758e5e Mon Sep 17 00:00:00 2001 From: Akeru Date: Wed, 18 Jun 2014 17:28:40 +0200 Subject: [PATCH 01/10] Allow [[..]] filter notation in all text panels Based on #408 with fixed filter service method. Supports html, text and markdown panels. --- src/app/panels/text/module.html | 7 +++---- src/app/panels/text/module.js | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/app/panels/text/module.html b/src/app/panels/text/module.html index adaf823be52..5b6c55c9954 100644 --- a/src/app/panels/text/module.html +++ b/src/app/panels/text/module.html @@ -1,10 +1,9 @@
- - {{panel.content}} + -

+

-

+

diff --git a/src/app/panels/text/module.js b/src/app/panels/text/module.js index 37735d3b376..460a6c09919 100644 --- a/src/app/panels/text/module.js +++ b/src/app/panels/text/module.js @@ -14,7 +14,8 @@ define([ 'angular', 'app', 'underscore', - 'require' + 'require', + 'services/filterSrv' ], function (angular, app, _, require) { 'use strict'; @@ -98,4 +99,25 @@ function (angular, app, _, require) { .replace(//g, '>') + .replace(/ Date: Tue, 24 Jun 2014 13:57:46 +0200 Subject: [PATCH 02/10] updated default dashboard info text --- src/app/dashboards/default.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/dashboards/default.json b/src/app/dashboards/default.json index c0e58b154e0..bf3450fd9a4 100644 --- a/src/app/dashboards/default.json +++ b/src/app/dashboards/default.json @@ -24,7 +24,7 @@ "type": "text", "loadingEditor": false, "mode": "markdown", - "content": "####Thank you for trying out Grafana! \n\nGeneral documentation is found in the readme and in the wiki section of the [Github Project](https://github.com/torkelo/grafana). If you encounter any problem or have an idea for an improvement do not hesitate to open a github issue. \n\nTips: \n\n- Ctrl+S saves the current dashboard\n- Ctrl+F Opens the dashboard finder (searches elastic search)\n- Ctrl+H Hide/show row controls \n- Click and drag graph title to move panel (only works when row controls are enabled)\n\nIf you do not see a graph in the panel bellow the browser cannot access your graphite installation. Please make sure that the graphiteUrl property in config.js is correctly set and accessible.", + "content": "####Thank you for trying out Grafana! \n\nGeneral documentation is found in the readme and in the wiki section of the [Github Project](https://github.com/torkelo/grafana). If you encounter any problem or have an idea for an improvement do not hesitate to open a github issue. \n\nTips: \n\n- Ctrl+S saves the current dashboard\n- Ctrl+F Opens the dashboard finder (searches elastic search)\n- Ctrl+H Hide/show row controls \n- Click and drag graph title to move panel (only works when row controls are enabled)\n\nIf you do not see a graph in the panel below the browser cannot access your graphite installation. Please make sure that datasources property in config.js is correctly set and that any urls accessible from your browser.", "style": {}, "title": "Welcome to Grafana" } @@ -41,7 +41,7 @@ { "span": 12, "editable": true, - "type": "graphite", + "type": "graph", "x-axis": true, "y-axis": true, "scale": 1, From 32b11b104f3ef119ba9bb43780ca8aa833cd3628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 24 Jun 2014 15:06:51 +0200 Subject: [PATCH 03/10] updated version to 1.6.1 --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c8fe29f18..db37fa6e000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -vNext +# 1.6.1 (2014-06-24) **New features or improvements** - Ability to set y min/max for right y-axis (RR #519, Closes #360) - thx @acedrew diff --git a/package.json b/package.json index 004bd166b73..cb46712796c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "company": "Coding Instinct AB" }, "name": "grafana", - "version": "1.6.0", + "version": "1.6.1", "repository": { "type": "git", "url": "http://github.com/torkelo/grafana.git" From c925014bb5bba30330b616d8cdfe344e3543c621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 25 Jun 2014 10:09:19 -0400 Subject: [PATCH 04/10] Use unix epoch for Graphite from/to for absolute time ranges, #536 --- CHANGELOG.md | 5 +++++ src/app/services/graphite/graphiteDatasource.js | 10 +--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db37fa6e000..567c44795b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +vNext + +**Changes** +- Use unix epoch for Graphite from/to for absolute time ranges (Closes #536) + # 1.6.1 (2014-06-24) **New features or improvements** diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 33f809cf411..dd181ef1720 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -104,15 +104,7 @@ function (angular, _, $, config, kbn, moment) { } } - if (dashboard.current.timezone === 'browser') { - date = date.local(); - } - - if (config.timezoneOffset) { - date = date.zone(config.timezoneOffset); - } - - return date.format('HH:mm_YYYYMMDD'); + return date.unix(); }; GraphiteDatasource.prototype.metricFindQuery = function(filterSrv, query) { From dd2b43dc730bfeec2e76d5e31f4d6cc1082b88f7 Mon Sep 17 00:00:00 2001 From: Christophe Furmaniak Date: Wed, 25 Jun 2014 23:56:25 +0200 Subject: [PATCH 05/10] Display tag values whenever a tag is part of the query (opentsdb datasource) --- src/app/services/opentsdb/opentsdbDatasource.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/services/opentsdb/opentsdbDatasource.js b/src/app/services/opentsdb/opentsdbDatasource.js index 8d463b4b518..fddcec04d05 100644 --- a/src/app/services/opentsdb/opentsdbDatasource.js +++ b/src/app/services/opentsdb/opentsdbDatasource.js @@ -33,9 +33,7 @@ function (angular, _, kbn) { var groupByTags = {}; _.each(queries, function(query) { _.each(query.tags, function(val, key) { - if (val === "*") { - groupByTags[key] = true; - } + groupByTags[key] = true; }); }); From 65bb6a8b73d9aa6775c38860bee06751be376b78 Mon Sep 17 00:00:00 2001 From: Akeru Date: Fri, 27 Jun 2014 13:52:43 +0200 Subject: [PATCH 06/10] Fix HTML code --- src/app/partials/dashboard.html | 34 ++++++++++++++++---------------- src/app/partials/dasheditor.html | 2 +- src/app/partials/playlist.html | 7 ++++--- src/app/partials/search.html | 1 + 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 0c4976148a7..43b6b5741e6 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -39,32 +39,32 @@ \ No newline at end of file From 73fc437c7dce70a9d58683f56cb9d0e1451b4a5f Mon Sep 17 00:00:00 2001 From: Akeru Date: Fri, 27 Jun 2014 15:24:06 +0200 Subject: [PATCH 07/10] Add diffSeries function support --- src/app/services/graphite/gfunc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index d0821df6d6e..63c28bc1dfc 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -63,6 +63,11 @@ function (_) { category: categories.Combine, }); + addFuncDef({ + name: 'diffSeries', + category: categories.Combine, + }); + addFuncDef({ name: 'averageSeries', shortName: 'avg', From 6346f835af4876d1035872e03462b76f3deceb39 Mon Sep 17 00:00:00 2001 From: Akeru Date: Fri, 27 Jun 2014 15:37:11 +0200 Subject: [PATCH 08/10] Fix formatting negative values --- src/app/components/kbn.js | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 67bab9ff061..ce15ef0cbeb 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -26,52 +26,52 @@ function($, _, moment) { kbn.round_interval = function(interval) { switch (true) { // 0.5s - case (interval <= 500): + case (Math.abs(interval) <= 500): return 100; // 0.1s // 5s - case (interval <= 5000): + case (Math.abs(interval) <= 5000): return 1000; // 1s // 7.5s - case (interval <= 7500): + case (Math.abs(interval) <= 7500): return 5000; // 5s // 15s - case (interval <= 15000): + case (Math.abs(interval) <= 15000): return 10000; // 10s // 45s - case (interval <= 45000): + case (Math.abs(interval) <= 45000): return 30000; // 30s // 3m - case (interval <= 180000): + case (Math.abs(interval) <= 180000): return 60000; // 1m // 9m - case (interval <= 450000): + case (Math.abs(interval) <= 450000): return 300000; // 5m // 20m - case (interval <= 1200000): + case (Math.abs(interval) <= 1200000): return 600000; // 10m // 45m - case (interval <= 2700000): + case (Math.abs(interval) <= 2700000): return 1800000; // 30m // 2h - case (interval <= 7200000): + case (Math.abs(interval) <= 7200000): return 3600000; // 1h // 6h - case (interval <= 21600000): + case (Math.abs(interval) <= 21600000): return 10800000; // 3h // 24h - case (interval <= 86400000): + case (Math.abs(interval) <= 86400000): return 43200000; // 12h // 48h - case (interval <= 172800000): + case (Math.abs(interval) <= 172800000): return 86400000; // 24h // 1w - case (interval <= 604800000): + case (Math.abs(interval) <= 604800000): return 86400000; // 24h // 3w - case (interval <= 1814400000): + case (Math.abs(interval) <= 1814400000): return 604800000; // 1w // 2y - case (interval < 3628800000): + case (Math.abs(interval) < 3628800000): return 2592000000; // 30d default: return 31536000000; // 1y @@ -481,23 +481,23 @@ function($, _, moment) { }; kbn.msFormat = function(size, decimals) { - if (size < 1000) { + if (Math.abs(size) < 1000) { return size.toFixed(0) + " ms"; } // Less than 1 min - else if (size < 60000) { + else if (Math.abs(size) < 60000) { return (size / 1000).toFixed(decimals) + " s"; } // Less than 1 hour, devide in minutes - else if (size < 3600000) { + else if (Math.abs(size) < 3600000) { return (size / 60000).toFixed(decimals) + " min"; } // Less than one day, devide in hours - else if (size < 86400000) { + else if (Math.abs(size) < 86400000) { return (size / 3600000).toFixed(decimals) + " hour"; } // Less than one year, devide in days - else if (size < 31536000000) { + else if (Math.abs(size) < 31536000000) { return (size / 86400000).toFixed(decimals) + " day"; } @@ -506,23 +506,23 @@ function($, _, moment) { kbn.sFormat = function(size, decimals) { // Less than 10 min, use seconds - if (size < 600) { + if (Math.abs(size) < 600) { return size.toFixed(decimals) + " s"; } // Less than 1 hour, devide in minutes - else if (size < 3600) { + else if (Math.abs(size) < 3600) { return (size / 60).toFixed(decimals) + " min"; } // Less than one day, devide in hours - else if (size < 86400) { + else if (Math.abs(size) < 86400) { return (size / 3600).toFixed(decimals) + " hour"; } // Less than one week, devide in days - else if (size < 604800) { + else if (Math.abs(size) < 604800) { return (size / 86400).toFixed(decimals) + " day"; } // Less than one year, devide in week - else if (size < 31536000) { + else if (Math.abs(size) < 31536000) { return (size / 604800).toFixed(decimals) + " week"; } @@ -530,10 +530,10 @@ function($, _, moment) { }; kbn.microsFormat = function(size, decimals) { - if (size < 1000) { + if (Math.abs(size) < 1000) { return size.toFixed(0) + " µs"; } - else if (size < 1000000) { + else if (Math.abs(size) < 1000000) { return (size / 1000).toFixed(decimals) + " ms"; } else { @@ -542,16 +542,16 @@ function($, _, moment) { }; kbn.nanosFormat = function(size, decimals) { - if (size < 1000) { + if (Math.abs(size) < 1000) { return size.toFixed(0) + " ns"; } - else if (size < 1000000) { + else if (Math.abs(size) < 1000000) { return (size / 1000).toFixed(decimals) + " µs"; } - else if (size < 1000000000) { + else if (Math.abs(size) < 1000000000) { return (size / 1000000).toFixed(decimals) + " ms"; } - else if (size < 60000000000){ + else if (Math.abs(size) < 60000000000){ return (size / 1000000000).toFixed(decimals) + " s"; } else { From 505f0f65d078114ac68f9c9e81e92a6a94191bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 30 Jun 2014 07:56:35 +0200 Subject: [PATCH 09/10] updated change log with PR #545 --- CHANGELOG.md | 4 ++++ src/app/components/kbn.js | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 567c44795b2..9c354cf3c37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ vNext **Changes** - Use unix epoch for Graphite from/to for absolute time ranges (Closes #536) +**Fixes** +- Fix formatting negative values (PR #545) + + # 1.6.1 (2014-06-24) **New features or improvements** diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index ce15ef0cbeb..5faeafeb1ff 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -26,52 +26,52 @@ function($, _, moment) { kbn.round_interval = function(interval) { switch (true) { // 0.5s - case (Math.abs(interval) <= 500): + case (interval <= 500): return 100; // 0.1s // 5s - case (Math.abs(interval) <= 5000): + case (interval <= 5000): return 1000; // 1s // 7.5s - case (Math.abs(interval) <= 7500): + case (interval <= 7500): return 5000; // 5s // 15s - case (Math.abs(interval) <= 15000): + case (interval <= 15000): return 10000; // 10s // 45s - case (Math.abs(interval) <= 45000): + case (interval <= 45000): return 30000; // 30s // 3m - case (Math.abs(interval) <= 180000): + case (interval <= 180000): return 60000; // 1m // 9m - case (Math.abs(interval) <= 450000): + case (interval <= 450000): return 300000; // 5m // 20m - case (Math.abs(interval) <= 1200000): + case (interval <= 1200000): return 600000; // 10m // 45m - case (Math.abs(interval) <= 2700000): + case (interval <= 2700000): return 1800000; // 30m // 2h - case (Math.abs(interval) <= 7200000): + case (interval <= 7200000): return 3600000; // 1h // 6h - case (Math.abs(interval) <= 21600000): + case (interval <= 21600000): return 10800000; // 3h // 24h - case (Math.abs(interval) <= 86400000): + case (interval <= 86400000): return 43200000; // 12h // 48h - case (Math.abs(interval) <= 172800000): + case (interval <= 172800000): return 86400000; // 24h // 1w - case (Math.abs(interval) <= 604800000): + case (interval <= 604800000): return 86400000; // 24h // 3w - case (Math.abs(interval) <= 1814400000): + case (interval <= 1814400000): return 604800000; // 1w // 2y - case (Math.abs(interval) < 3628800000): + case (interval < 3628800000): return 2592000000; // 30d default: return 31536000000; // 1y From 91b48258f0f58ca181b6d06d012727d819a76626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 30 Jun 2014 09:10:32 +0200 Subject: [PATCH 10/10] Refactoring PR #511, Allow filter notation [[..]] in text panels --- CHANGELOG.md | 3 + src/app/panels/text/module.html | 7 +- src/app/panels/text/module.js | 116 +++++++++++++------------------- 3 files changed, 49 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c354cf3c37..61e9d0c1f43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ vNext +**New features or improvements** +- Allow [[..]] filter notation in all text panels (markdown/html/text) (Issue #511) + **Changes** - Use unix epoch for Graphite from/to for absolute time ranges (Closes #536) diff --git a/src/app/panels/text/module.html b/src/app/panels/text/module.html index 5b6c55c9954..3db0a30d031 100644 --- a/src/app/panels/text/module.html +++ b/src/app/panels/text/module.html @@ -1,9 +1,4 @@
- - - -

-

-

+

diff --git a/src/app/panels/text/module.js b/src/app/panels/text/module.js index 460a6c09919..65b50f3ee67 100644 --- a/src/app/panels/text/module.js +++ b/src/app/panels/text/module.js @@ -23,7 +23,7 @@ function (angular, app, _, require) { var module = angular.module('kibana.panels.text', []); app.useModule(module); - module.controller('text', function($scope) { + module.controller('text', function($scope, filterSrv) { $scope.panelMeta = { description : "A static text panel that can use plain text, markdown, or (sanitized) HTML" @@ -40,84 +40,58 @@ function (angular, app, _, require) { $scope.init = function() { $scope.initBaseController(this, $scope); - $scope.ready = false; + $scope.$on('refresh', $scope.render); + $scope.render(); }; $scope.render = function() { - $scope.$emit('render'); + if ($scope.panel.mode === 'markdown') { + $scope.renderMarkdown($scope.panel.content); + } + else if ($scope.panel.mode === 'html') { + $scope.updateContent($scope.panel.content); + } + else if ($scope.panel.mode === 'text') { + $scope.renderText($scope.panel.content); + } + }; + + $scope.renderText = function(content) { + content = content + .replace(/&/g, '&') + .replace(/>/g, '>') + .replace(/'); + + $scope.updateContent(content); + }; + + $scope.renderMarkdown = function(content) { + require(['./lib/showdown'], function (Showdown) { + var converter = new Showdown.converter(); + var text = content + .replace(/&/g, '&') + .replace(/>/g, '>') + .replace(//g, '>') - .replace(/'); - }; - }); - - module.filter('striphtml', function () { - return function(text) { - return text - .replace(/&/g, '&') - .replace(/>/g, '>') - .replace(//g, '>') - .replace(/