From 14312d225c223963f41f2b19bccba356fd91e6a0 Mon Sep 17 00:00:00 2001 From: Marcus Kempe Date: Mon, 15 Feb 2016 19:02:41 +0100 Subject: [PATCH 01/44] Added exporting graph data to CSV with series.alias in columns. --- public/app/core/utils/file_export.ts | 35 ++++++++++++++++++++++++ public/app/plugins/panel/graph/module.ts | 5 ++++ 2 files changed, 40 insertions(+) diff --git a/public/app/core/utils/file_export.ts b/public/app/core/utils/file_export.ts index ad203f58495..944b6ae8a80 100644 --- a/public/app/core/utils/file_export.ts +++ b/public/app/core/utils/file_export.ts @@ -14,6 +14,41 @@ export function exportSeriesListToCsv(seriesList) { saveSaveBlob(text, 'grafana_data_export.csv'); }; +export function exportSeriesListToCsvColumns(seriesList) { + var text = 'Time;'; + // add header + _.each(seriesList, function(series) { + text += series.alias + ';'; + }); + text = text.substring(0,text.length-1); + text += '\n'; + + // process data + var dataArr = [[]]; + var sIndex = 1; + _.each(seriesList, function(series) { + var cIndex = 0; + dataArr.push([]); + _.each(series.datapoints, function(dp) { + dataArr[0][cIndex] = new Date(dp[1]).toISOString(); + dataArr[sIndex][cIndex] = dp[0]; + cIndex++; + }); + sIndex++; + }); + + // make text + for (var i = 0; i < dataArr[0].length; i++) { + text += dataArr[0][i] + ';'; + for (var j = 1; j < dataArr.length; j++) { + text += dataArr[j][i] + ';'; + } + text = text.substring(0,text.length-1); + text += '\n'; + } + saveSaveBlob(text, 'grafana_data_export.csv'); +}; + export function exportTableDataToCsv(table) { var text = ''; // add header diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index b1d48d98649..8f3e178b37c 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -126,6 +126,7 @@ class GraphCtrl extends MetricsPanelCtrl { getExtendedMenu() { var menu = super.getExtendedMenu(); menu.push({text: 'Export CSV', click: 'ctrl.exportCsv()'}); + menu.push({text: 'Export CSV (series2columns)', click: 'ctrl.exportCsvColumns()'}); menu.push({text: 'Toggle legend', click: 'ctrl.toggleLegend()'}); return menu; } @@ -295,6 +296,10 @@ class GraphCtrl extends MetricsPanelCtrl { exportCsv() { fileExport.exportSeriesListToCsv(this.seriesList); } + + exportCsvColumns() { + fileExport.exportSeriesListToCsvColumns(this.seriesList); + } } export {GraphCtrl, GraphCtrl as PanelCtrl} From d6e4fb46cff7d9f34eb9972d78a082c79bddef13 Mon Sep 17 00:00:00 2001 From: benrubson Date: Sun, 21 Feb 2016 21:48:09 +0100 Subject: [PATCH 02/44] Add a minimum value option for template auto interval --- public/app/core/utils/kbn.js | 6 +++++- public/app/features/templating/partials/editor.html | 6 ++++++ public/app/features/templating/templateValuesSrv.js | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index fbb854148f9..a6b08f1526f 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -119,10 +119,14 @@ function($, _) { s: 1 }; - kbn.calculateInterval = function(range, resolution, userInterval) { + kbn.calculateInterval = function(range, resolution, userInterval, lowLimit) { var lowLimitMs = 1; // 1 millisecond default low limit var intervalMs, lowLimitInterval; + if(lowLimit) { + lowLimitMs = kbn.interval_to_ms(lowLimit); + } + if (userInterval) { if (userInterval[0] === '>') { lowLimitInterval = userInterval.slice(1); diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 98212225f25..0aa69aaf714 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -134,6 +134,12 @@
  • +
  • + Auto interval min value The calculated value will not go below this threshold +
  • +
  • + +
  • diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 6029bdf899c..aa2cb177727 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -60,7 +60,7 @@ function (angular, _, kbn) { variable.options.unshift({ text: 'auto', value: '$__auto_interval' }); } - var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count); + var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count, null, variable.auto_min); templateSrv.setGrafanaVariable('$__auto_interval', interval); }; From ab9757082efa2f94f1a0fa659cd47037a79f6d90 Mon Sep 17 00:00:00 2001 From: benrubson Date: Sun, 21 Feb 2016 22:00:00 +0100 Subject: [PATCH 03/44] Code style typo --- public/app/core/utils/kbn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index a6b08f1526f..430c2175561 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -123,7 +123,7 @@ function($, _) { var lowLimitMs = 1; // 1 millisecond default low limit var intervalMs, lowLimitInterval; - if(lowLimit) { + if (lowLimit) { lowLimitMs = kbn.interval_to_ms(lowLimit); } From b9843fe6d164195df5083a44d16ce0f7dd8991b0 Mon Sep 17 00:00:00 2001 From: benrubson Date: Sun, 21 Feb 2016 22:07:01 +0100 Subject: [PATCH 04/44] Code style typo --- public/app/core/utils/kbn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index 430c2175561..8f4970b0a83 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -124,7 +124,7 @@ function($, _) { var intervalMs, lowLimitInterval; if (lowLimit) { - lowLimitMs = kbn.interval_to_ms(lowLimit); + lowLimitMs = kbn.interval_to_ms(lowLimit); } if (userInterval) { From 6f704456548e928f43fd987e36aac7c82e35e2f0 Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 22 Feb 2016 08:02:01 +0100 Subject: [PATCH 05/44] Add some more auto interval steps --- public/app/features/templating/partials/editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 98212225f25..aae301d43bb 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -132,7 +132,7 @@ Auto interval steps How many times should the current time range be divided to calculate the value
  • - +
  • From 69b87fdb9a8d189ec1220d037b1fef8338382f21 Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 22 Feb 2016 08:55:52 +0100 Subject: [PATCH 06/44] make auto interval calculation more accurate --- public/app/core/utils/kbn.js | 57 ++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index fbb854148f9..b2741ad8f82 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -12,39 +12,66 @@ function($, _) { kbn.round_interval = function(interval) { switch (true) { - // 0.5s - case (interval <= 500): + // 0.3s + case (interval <= 300): return 100; // 0.1s - // 5s - case (interval <= 5000): + // 0.75s + case (interval <= 750): + return 500; // 0.5s + // 1.5s + case (interval <= 1500): return 1000; // 1s + // 3.5s + case (interval <= 3500): + return 2000; // 2s // 7.5s case (interval <= 7500): return 5000; // 5s - // 15s - case (interval <= 15000): + // 12.5s + case (interval <= 12500): return 10000; // 10s + // 17.5s + case (interval <= 17500): + return 15000; // 15s + // 25s + case (interval <= 25000): + return 20000; // 20s // 45s case (interval <= 45000): return 30000; // 30s - // 3m - case (interval <= 180000): + // 1.5m + case (interval <= 90000): return 60000; // 1m - // 9m + // 3.5m + case (interval <= 210000): + return 120000; // 2m + // 7.5m case (interval <= 450000): return 300000; // 5m - // 20m - case (interval <= 1200000): + // 12.5m + case (interval <= 750000): return 600000; // 10m + // 12.5m + case (interval <= 1050000): + return 900000; // 15m + // 25m + case (interval <= 1500000): + return 1200000; // 20m // 45m case (interval <= 2700000): return 1800000; // 30m - // 2h - case (interval <= 7200000): + // 1.5h + case (interval <= 5400000): return 3600000; // 1h - // 6h - case (interval <= 21600000): + // 2.5h + case (interval <= 9000000): + return 7200000; // 2h + // 4.5h + case (interval <= 16200000): return 10800000; // 3h + // 9h + case (interval <= 32400000): + return 21600000; // 6h // 24h case (interval <= 86400000): return 43200000; // 12h From 2034d4b9710b0cb9fd0cdf14aa9981cd0417eda4 Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 22 Feb 2016 10:12:02 +0100 Subject: [PATCH 07/44] update kbn specs to make tests OK --- public/test/core/utils/kbn_specs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/test/core/utils/kbn_specs.js b/public/test/core/utils/kbn_specs.js index 23c752fe471..7e75e880546 100644 --- a/public/test/core/utils/kbn_specs.js +++ b/public/test/core/utils/kbn_specs.js @@ -127,7 +127,7 @@ define([ it('10m 1600 resolution', function() { var range = { from: dateMath.parse('now-10m'), to: dateMath.parse('now') }; var str = kbn.calculateInterval(range, 1600, null); - expect(str).to.be('100ms'); + expect(str).to.be('500ms'); }); it('fixed user interval', function() { @@ -145,7 +145,7 @@ define([ it('large time range and user low limit', function() { var range = { from: dateMath.parse('now-14d'), to: dateMath.parse('now') }; var str = kbn.calculateInterval(range, 1000, '>10s'); - expect(str).to.be('30m'); + expect(str).to.be('20m'); }); }); }); From c9fe2bab6042efc12cfda9d75dfd842bc738a31a Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 22 Feb 2016 10:27:08 +0100 Subject: [PATCH 08/44] make it more smartly --- public/app/core/utils/kbn.js | 6 +----- public/app/features/templating/templateValuesSrv.js | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index 8f4970b0a83..fbb854148f9 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -119,14 +119,10 @@ function($, _) { s: 1 }; - kbn.calculateInterval = function(range, resolution, userInterval, lowLimit) { + kbn.calculateInterval = function(range, resolution, userInterval) { var lowLimitMs = 1; // 1 millisecond default low limit var intervalMs, lowLimitInterval; - if (lowLimit) { - lowLimitMs = kbn.interval_to_ms(lowLimit); - } - if (userInterval) { if (userInterval[0] === '>') { lowLimitInterval = userInterval.slice(1); diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index aa2cb177727..2760bb42ca0 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -60,7 +60,7 @@ function (angular, _, kbn) { variable.options.unshift({ text: 'auto', value: '$__auto_interval' }); } - var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count, null, variable.auto_min); + var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count, (variable.auto_min ? ">"+variable.auto_min : null)); templateSrv.setGrafanaVariable('$__auto_interval', interval); }; From 45e6187c1aaf202062fb6e6da87e4c616fd45aaf Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 26 Feb 2016 00:43:48 +0900 Subject: [PATCH 09/44] add hide template variable option --- public/app/features/dashboard/submenu/submenu.html | 2 +- public/app/features/templating/partials/editor.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/submenu/submenu.html b/public/app/features/dashboard/submenu/submenu.html index eb8de17676c..21a9744b359 100644 --- a/public/app/features/dashboard/submenu/submenu.html +++ b/public/app/features/dashboard/submenu/submenu.html @@ -1,6 +1,6 @@ From 8e7a127792486707adf6504e24ceda8ce5ef75cf Mon Sep 17 00:00:00 2001 From: godfreyhe Date: Fri, 26 Feb 2016 20:47:22 +0800 Subject: [PATCH 10/44] fix bug: can't get the aggregators from opentsdb server --- public/app/plugins/datasource/opentsdb/query_ctrl.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/opentsdb/query_ctrl.ts b/public/app/plugins/datasource/opentsdb/query_ctrl.ts index 43096b2ec36..7e853564cc3 100644 --- a/public/app/plugins/datasource/opentsdb/query_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/query_ctrl.ts @@ -38,8 +38,9 @@ export class OpenTsQueryCtrl extends QueryCtrl { this.target.downsampleFillPolicy = 'none'; } + var self = this; this.datasource.getAggregators().then(function(aggs) { - this.aggregators = aggs; + self.aggregators = aggs; }); // needs to be defined here as it is called from typeahead From 781041369941cbb5ad55d5cc86432003eed0d02c Mon Sep 17 00:00:00 2001 From: godfreyhe Date: Sun, 28 Feb 2016 11:48:54 +0800 Subject: [PATCH 11/44] use ES6 arrow function instead of self var on getAggregators --- public/app/plugins/datasource/opentsdb/query_ctrl.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/query_ctrl.ts b/public/app/plugins/datasource/opentsdb/query_ctrl.ts index 7e853564cc3..c973bd3a223 100644 --- a/public/app/plugins/datasource/opentsdb/query_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/query_ctrl.ts @@ -38,9 +38,8 @@ export class OpenTsQueryCtrl extends QueryCtrl { this.target.downsampleFillPolicy = 'none'; } - var self = this; - this.datasource.getAggregators().then(function(aggs) { - self.aggregators = aggs; + this.datasource.getAggregators().then((aggs) => { + this.aggregators = aggs; }); // needs to be defined here as it is called from typeahead From 3125177e5c31eb6da04a8dbb9d1353e82cea74aa Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Sun, 28 Feb 2016 13:33:29 +0900 Subject: [PATCH 12/44] (prometheus) fix label_values() templating --- .../datasource/prometheus/metric_find_query.js | 6 +++--- .../prometheus/specs/metric_find_query_specs.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/metric_find_query.js b/public/app/plugins/datasource/prometheus/metric_find_query.js index 65ea92e05b1..25704df1e2c 100644 --- a/public/app/plugins/datasource/prometheus/metric_find_query.js +++ b/public/app/plugins/datasource/prometheus/metric_find_query.js @@ -11,16 +11,16 @@ function (_, moment) { } PrometheusMetricFindQuery.prototype.process = function() { - var label_values_regex = /^label_values\(([^,]+)(?:,\s*(.+))?\)$/; + var label_values_regex = /^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]+)\)$/; var metric_names_regex = /^metrics\((.+)\)$/; var query_result_regex = /^query_result\((.+)\)$/; var label_values_query = this.query.match(label_values_regex); if (label_values_query) { - if (label_values_query[2]) { + if (label_values_query[1]) { return this.labelValuesQuery(label_values_query[2], label_values_query[1]); } else { - return this.labelValuesQuery(label_values_query[1], null); + return this.labelValuesQuery(label_values_query[2], null); } } diff --git a/public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts b/public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts index dfc6b597598..5edf7038cd3 100644 --- a/public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts +++ b/public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts @@ -48,6 +48,22 @@ describe('PrometheusMetricFindQuery', function() { ctx.$rootScope.$apply(); expect(results.length).to.be(3); }); + it('label_values(metric{label1="foo", label2="bar", label3="baz"}, resource) should generate series query', function() { + response = { + status: "success", + data: [ + {__name__: "metric", resource: "value1"}, + {__name__: "metric", resource: "value2"}, + {__name__: "metric", resource: "value3"} + ] + }; + ctx.$httpBackend.expect('GET', 'proxied/api/v1/series?match[]=metric').respond(response); + var pm = new PrometheusMetricFindQuery(ctx.ds, 'label_values(metric, resource)'); + pm.process().then(function(data) { results = data; }); + ctx.$httpBackend.flush(); + ctx.$rootScope.$apply(); + expect(results.length).to.be(3); + }); it('metrics(metric.*) should generate metric name query', function() { response = { status: "success", From f90fda8e6fd0c2cd0d773c5a3a12ef46b7a67d4a Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Sun, 7 Feb 2016 21:13:00 -0800 Subject: [PATCH 13/44] Tracking opentsdb version in opentsdb config --- .../datasource/opentsdb/config_ctrl.ts | 21 +++++++++++++++++++ .../plugins/datasource/opentsdb/datasource.js | 5 +++++ .../app/plugins/datasource/opentsdb/module.ts | 5 +---- .../datasource/opentsdb/partials/config.html | 13 ++++++++++++ .../opentsdb/specs/datasource-specs.ts | 2 +- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 public/app/plugins/datasource/opentsdb/config_ctrl.ts diff --git a/public/app/plugins/datasource/opentsdb/config_ctrl.ts b/public/app/plugins/datasource/opentsdb/config_ctrl.ts new file mode 100644 index 00000000000..bbf7ced7ef1 --- /dev/null +++ b/public/app/plugins/datasource/opentsdb/config_ctrl.ts @@ -0,0 +1,21 @@ +/// + +import angular from 'angular'; +import _ from 'lodash'; + +export class OpenTsConfigCtrl { + static templateUrl = 'public/app/plugins/datasource/opentsdb/partials/config.html'; + current: any; + + /** @ngInject */ + constructor($scope) { + this.current.jsonData = this.current.jsonData || {}; + this.current.jsonData.tsdbVersion = this.current.jsonData.tsdbVersion || 1; + } + + tsdbVersions = [ + {name: '<=2.1', value: 1}, + {name: '>=2.2', value: 2}, + ]; + +} diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index c80d58a2ac7..a652f429a48 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -14,6 +14,11 @@ function (angular, _, dateMath) { this.name = instanceSettings.name; this.withCredentials = instanceSettings.withCredentials; this.basicAuth = instanceSettings.basicAuth; + this.tsdbVersions = [ + {name: '<=2.1', value: 1}, + {name: '>=2.2', value: 2}, + ]; + this.tsdbVersion = instanceSettings.jsonData.tsdbVersion; this.supportMetrics = true; this.tagKeys = {}; diff --git a/public/app/plugins/datasource/opentsdb/module.ts b/public/app/plugins/datasource/opentsdb/module.ts index 429cda5e5ea..e18552ac64c 100644 --- a/public/app/plugins/datasource/opentsdb/module.ts +++ b/public/app/plugins/datasource/opentsdb/module.ts @@ -1,9 +1,6 @@ import {OpenTsDatasource} from './datasource'; import {OpenTsQueryCtrl} from './query_ctrl'; - -class OpenTsConfigCtrl { - static templateUrl = 'partials/config.html'; -} +import {OpenTsConfigCtrl} from './config_ctrl'; export { OpenTsDatasource as Datasource, diff --git a/public/app/plugins/datasource/opentsdb/partials/config.html b/public/app/plugins/datasource/opentsdb/partials/config.html index 3b7f169a0a8..d212b31686d 100644 --- a/public/app/plugins/datasource/opentsdb/partials/config.html +++ b/public/app/plugins/datasource/opentsdb/partials/config.html @@ -1,2 +1,15 @@ +
    +
    Opentsdb settings
    +
    +
      +
    • + Version +
    • +
    • + +
    • +
    +
    +
    diff --git a/public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts b/public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts index b786a93f14c..1da4268e433 100644 --- a/public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts +++ b/public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts @@ -4,7 +4,7 @@ import {OpenTsDatasource} from "../datasource"; describe('opentsdb', function() { var ctx = new helpers.ServiceTestContext(); - var instanceSettings = {url: '' }; + var instanceSettings = {url: '', jsonData: { tsdbVersion: 1 }}; beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); From 908e8577bbce4b75a0f04f6953f346165aa0d670 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Sun, 7 Feb 2016 21:14:43 -0800 Subject: [PATCH 14/44] Removed unused code from datasource.js --- public/app/plugins/datasource/opentsdb/datasource.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index a652f429a48..2cf0ecf2571 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -14,10 +14,6 @@ function (angular, _, dateMath) { this.name = instanceSettings.name; this.withCredentials = instanceSettings.withCredentials; this.basicAuth = instanceSettings.basicAuth; - this.tsdbVersions = [ - {name: '<=2.1', value: 1}, - {name: '>=2.2', value: 2}, - ]; this.tsdbVersion = instanceSettings.jsonData.tsdbVersion; this.supportMetrics = true; this.tagKeys = {}; From 26232406359e3f5d4bddfbfe26d0e9a36e3e8111 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Sun, 7 Feb 2016 22:03:01 -0800 Subject: [PATCH 15/44] Fill Policy visible only in <=2.2 --- .../plugins/datasource/opentsdb/partials/query.editor.html | 5 ++--- public/app/plugins/datasource/opentsdb/query_ctrl.ts | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/partials/query.editor.html b/public/app/plugins/datasource/opentsdb/partials/query.editor.html index 0c7c7d25a57..d896381274e 100644 --- a/public/app/plugins/datasource/opentsdb/partials/query.editor.html +++ b/public/app/plugins/datasource/opentsdb/partials/query.editor.html @@ -63,12 +63,11 @@ -
  • +
  • Fill - Available since OpenTSDB 2.2
  • -
  • +
  • + + + + + add filter + + + + +
  • + +
    + +
    diff --git a/public/app/plugins/datasource/opentsdb/query_ctrl.ts b/public/app/plugins/datasource/opentsdb/query_ctrl.ts index 0ab2cd911aa..57afd75ab30 100644 --- a/public/app/plugins/datasource/opentsdb/query_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/query_ctrl.ts @@ -76,6 +76,11 @@ export class OpenTsQueryCtrl extends QueryCtrl { } addTag() { + + if (this.target.filters && this.target.filters.length > 0) { + this.errors.tags = "Please remove filters to use tags, tags and filters are mutually exclusive."; + } + if (!this.addTagMode) { this.addTagMode = true; return; @@ -109,7 +114,17 @@ export class OpenTsQueryCtrl extends QueryCtrl { this.addTag(); } + closeAddTagMode() { + this.addTagMode = false; + return; + } + addFilter() { + + if (this.target.tags && _.size(this.target.tags) > 0) { + this.errors.filters = "Please remove tags to use filters, tags and filters are mutually exclusive."; + } + if (!this.addFilterMode) { this.addFilterMode = true; return; @@ -161,6 +176,11 @@ export class OpenTsQueryCtrl extends QueryCtrl { this.addFilter(); } + closeAddFilterMode() { + this.addFilterMode = false; + return; + } + validateTarget() { var errs: any = {}; From 63dfa303e54a688ed115df008fa21104eab55153 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 10 Feb 2016 21:54:36 -0800 Subject: [PATCH 19/44] Datasource working with filters after fixing bugs --- .../app/plugins/datasource/opentsdb/datasource.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 802ea16076b..8e2956c6448 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -89,6 +89,7 @@ function (angular, _, dateMath) { // In case the backend is 3rd-party hosted and does not suport OPTIONS, urlencoded requests // go as POST rather than OPTIONS+POST options.headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; + return backendSrv.datasourceRequest(options); }; @@ -308,15 +309,17 @@ function (angular, _, dateMath) { } } - query.tags = angular.copy(target.tags); - if(query.tags){ - for(var key in query.tags){ - query.tags[key] = templateSrv.replace(query.tags[key], options.scopedVars); + if (target.filters && target.filters.length > 0) { + query.filters = angular.copy(target.filters); + } else { + query.tags = angular.copy(target.tags); + if(query.tags){ + for(var key in query.tags){ + query.tags[key] = templateSrv.replace(query.tags[key], options.scopedVars); + } } } - query.filters = angular.copy(target.filters); - return query; } From 09e80f03902e5cc1dd927f8f07e053e31a6590f3 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 10 Feb 2016 22:49:27 -0800 Subject: [PATCH 20/44] Labels fixed in legend for Filters --- .../plugins/datasource/opentsdb/datasource.js | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 8e2956c6448..eab5c4a992c 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -40,9 +40,15 @@ function (angular, _, dateMath) { var groupByTags = {}; _.each(queries, function(query) { - _.each(query.tags, function(val, key) { - groupByTags[key] = true; - }); + if (query.filters && query.filters.length > 0) { + _.each(query.filters, function(val) { + groupByTags[val.tagk] = true; + }); + } else { + _.each(query.tags, function(val, key) { + groupByTags[key] = true; + }); + } }); return this.performTimeSeriesQuery(queries, start, end).then(function(response) { @@ -327,11 +333,18 @@ function (angular, _, dateMath) { var interpolatedTagValue; return _.map(metrics, function(metricData) { return _.findIndex(options.targets, function(target) { - return target.metric === metricData.metric && + if (target.filters && target.filters.length > 0) { + return target.metric === metricData.metric && + _.all(target.filters, function(filter) { + return filter.tagk === interpolatedTagValue === "*"; + }); + } else { + return target.metric === metricData.metric && _.all(target.tags, function(tagV, tagK) { - interpolatedTagValue = templateSrv.replace(tagV, options.scopedVars); - return metricData.tags[tagK] === interpolatedTagValue || interpolatedTagValue === "*"; - }); + interpolatedTagValue = templateSrv.replace(tagV, options.scopedVars); + return metricData.tags[tagK] === interpolatedTagValue || interpolatedTagValue === "*"; + }); + } }); }); } From 936dd2eaaa641e67876f93fcf82ee192e560ae06 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 10 Feb 2016 23:01:37 -0800 Subject: [PATCH 21/44] Added relevant docs and changes --- CHANGELOG.md | 1 + docs/sources/datasources/opentsdb.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7763166f20..c8f4fbef587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * **Prometheus**: Prometheus annotation support, closes[#2883](https://github.com/grafana/grafana/pull/2883) * **Cli**: New cli tool for downloading and updating plugins * **Annotations**: Annotations can now contain links that can be clicked (you can navigate on to annotation popovers), closes [#1588](https://github.com/grafana/grafana/issues/1588) +* **Opentsdb**: Opentsdb 2.2 filters support, closes[#3077](https://github.com/grafana/grafana/issues/3077) ### Breaking changes * **Plugin API**: Both datasource and panel plugin api (and plugin.json schema) have been updated, requiring an update to plugins. See [plugin api](https://github.com/grafana/grafana/blob/master/public/app/plugins/plugin_api.md) for more info. diff --git a/docs/sources/datasources/opentsdb.md b/docs/sources/datasources/opentsdb.md index 43fcda643ee..757ddcefab5 100644 --- a/docs/sources/datasources/opentsdb.md +++ b/docs/sources/datasources/opentsdb.md @@ -23,6 +23,7 @@ Name | The data source name, important that this is the same as in Grafana v1.x Default | Default data source means that it will be pre-selected for new panels. Url | The http protocol, ip and port of you opentsdb server (default port is usually 4242) Access | Proxy = access via Grafana backend, Direct = access directory from browser. +Version | Version = opentsdb version, either <=2.1 or 2.2 ## Query editor Open a graph in edit mode by click the title. From 4aa5dab62d56d26a32afbca9fb8c9325785d3575 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 17 Feb 2016 07:11:53 -0800 Subject: [PATCH 22/44] Added query ctrl tests for Opentsdb --- .../opentsdb/specs/query-ctrl-specs.ts | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts diff --git a/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts new file mode 100644 index 00000000000..d59bf0c64c7 --- /dev/null +++ b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts @@ -0,0 +1,85 @@ +import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; +import helpers from 'test/specs/helpers'; +import {OpenTsQueryCtrl} from "../query_ctrl"; + +describe('OpenTsQueryCtrl', function() { + var ctx = new helpers.ControllerTestContext(); + + beforeEach(angularMocks.module('grafana.core')); + beforeEach(angularMocks.module('grafana.services')); + beforeEach(ctx.providePhase(['backendSrv','templateSrv'])); + + beforeEach(ctx.providePhase()); + beforeEach(angularMocks.inject(($rootScope, $controller, $q) => { + ctx.$q = $q; + ctx.scope = $rootScope.$new(); + ctx.target = {target: ''}; + ctx.panelCtrl = {panel: {}}; + ctx.panelCtrl.refresh = sinon.spy(); + ctx.datasource.getAggregators = sinon.stub().returns(ctx.$q.when([])); + + ctx.ctrl = $controller(OpenTsQueryCtrl, {$scope: ctx.scope}, { + panelCtrl: ctx.panelCtrl, + datasource: ctx.datasource, + target: ctx.target, + }); + ctx.scope.$digest(); + })); + + describe('init query_ctrl variables', function() { + + it('filter types should be initialized', function() { + expect(ctx.ctrl.filterTypes.length).to.be(7); + }); + + it('aggregators should be initialized', function() { + expect(ctx.ctrl.aggregators.length).to.be(8); + }); + + it('fill policy options should be initialized', function() { + expect(ctx.ctrl.fillPolicies.length).to.be(4); + }); + + }); + + describe('when adding filters and tags', function() { + + it('addTagMode should be false when closed', function() { + ctx.ctrl.addTagMode = true; + ctx.ctrl.closeAddTagMode(); + expect(ctx.ctrl.addTagMode).to.be(false); + }); + + it('addFilterMode should be false when closed', function() { + ctx.ctrl.addFilterMode = true; + ctx.ctrl.closeAddFilterMode(); + expect(ctx.ctrl.addFilterMode).to.be(false); + }); + + it('removing a tag from the tags list', function() { + ctx.ctrl.target.tags = {"tagk": "tag_key", "tagk2": "tag_value2"}; + ctx.ctrl.removeTag("tagk"); + expect(Object.keys(ctx.ctrl.target.tags).length).to.be(1); + }); + + it('removing a filter from the filters list', function() { + ctx.ctrl.target.filters = [{"tagk": "tag_key", "filter": "tag_value2", "type": "wildcard", "groupBy": true}]; + ctx.ctrl.removeFilter(0); + expect(ctx.ctrl.target.filters.length).to.be(0); + }); + + it('adding a filter when tags exist should generate error', function() { + ctx.ctrl.target.tags = {"tagk": "tag_key", "tagk2": "tag_value2"}; + ctx.ctrl.addFilter(); + expect(ctx.ctrl.errors.filters).to.be('Please remove tags to use filters, tags and filters are mutually exclusive.'); + }); + + it('adding a tag when filters exist should generate error', function() { + ctx.ctrl.target.filters = [{"tagk": "tag_key", "filter": "tag_value2", "type": "wildcard", "groupBy": true}]; + ctx.ctrl.addTag(); + expect(ctx.ctrl.errors.tags).to.be('Please remove filters to use tags, tags and filters are mutually exclusive.'); + }); + + }); + +}); From 8925329950d3072edf9e0270de70ec7537f33e1e Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 26 Feb 2016 10:15:41 -0800 Subject: [PATCH 23/44] Added default opentsdb version to datasource --- public/app/plugins/datasource/opentsdb/datasource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index eab5c4a992c..75a0560f5a8 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -14,7 +14,7 @@ function (angular, _, dateMath) { this.name = instanceSettings.name; this.withCredentials = instanceSettings.withCredentials; this.basicAuth = instanceSettings.basicAuth; - this.tsdbVersion = instanceSettings.jsonData.tsdbVersion; + this.tsdbVersion = instanceSettings.jsonData.tsdbVersion || 1; this.supportMetrics = true; this.tagKeys = {}; From 7fa170cee9704ff915f710962738091352e1ad4e Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 26 Feb 2016 10:27:00 -0800 Subject: [PATCH 24/44] Fixed the UI as per new UX convention --- .../datasource/opentsdb/partials/config.html | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/partials/config.html b/public/app/plugins/datasource/opentsdb/partials/config.html index d212b31686d..f4f0bedfc19 100644 --- a/public/app/plugins/datasource/opentsdb/partials/config.html +++ b/public/app/plugins/datasource/opentsdb/partials/config.html @@ -2,14 +2,12 @@
    Opentsdb settings
    -
    -
      -
    • - Version -
    • -
    • - -
    • -
    +
    + + Version + + + +
    From a883424d25ef9b9316830704287c0f4d28dcf161 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 26 Feb 2016 19:01:06 -0800 Subject: [PATCH 25/44] smooth upgrade from Grafana 2.6 to 3.0 --- public/app/plugins/datasource/opentsdb/datasource.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 75a0560f5a8..83e7168399f 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -14,6 +14,7 @@ function (angular, _, dateMath) { this.name = instanceSettings.name; this.withCredentials = instanceSettings.withCredentials; this.basicAuth = instanceSettings.basicAuth; + instanceSettings.jsonData = instanceSettings.jsonData || {}; this.tsdbVersion = instanceSettings.jsonData.tsdbVersion || 1; this.supportMetrics = true; this.tagKeys = {}; From 18c57ea230003f8617b6b7904d605d3fd9f51e26 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Sun, 28 Feb 2016 01:35:21 -0800 Subject: [PATCH 26/44] Made opentsdb query_ctrl robust --- .../app/plugins/datasource/opentsdb/datasource.js | 15 ++++++++++++++- .../app/plugins/datasource/opentsdb/query_ctrl.ts | 12 ++++++++++-- .../datasource/opentsdb/specs/query-ctrl-specs.ts | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 83e7168399f..14605151752 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -224,7 +224,7 @@ function (angular, _, dateMath) { this.getAggregators = function() { if (aggregatorsPromise) { return aggregatorsPromise; } - aggregatorsPromise = this._get('/api/aggregators').then(function(result) { + aggregatorsPromise = this._get('/api/aggregators').then(function(result) { if (result.data && _.isArray(result.data)) { return result.data.sort(); } @@ -233,6 +233,19 @@ function (angular, _, dateMath) { return aggregatorsPromise; }; + var filterTypesPromise = null; + this.getFilterTypes = function() { + if (filterTypesPromise) { return filterTypesPromise; } + + filterTypesPromise = this._get('/api/config/filters').then(function(result) { + if (result.data) { + return Object.keys(result.data).sort(); + } + return []; + }); + return filterTypesPromise; + }; + function transformMetricData(md, groupByTags, target, options) { var metricLabel = createMetricLabel(md, target, groupByTags, options); var dps = []; diff --git a/public/app/plugins/datasource/opentsdb/query_ctrl.ts b/public/app/plugins/datasource/opentsdb/query_ctrl.ts index 57afd75ab30..60466a00ff5 100644 --- a/public/app/plugins/datasource/opentsdb/query_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/query_ctrl.ts @@ -45,7 +45,15 @@ export class OpenTsQueryCtrl extends QueryCtrl { } this.datasource.getAggregators().then((aggs) => { - this.aggregators = aggs; + if (aggs.length !== 0) { + this.aggregators = aggs; + } + }); + + this.datasource.getFilterTypes().then((filterTypes) => { + if (filterTypes.length !== 0) { + this.filterTypes = filterTypes; + } }); // needs to be defined here as it is called from typeahead @@ -135,7 +143,7 @@ export class OpenTsQueryCtrl extends QueryCtrl { } if (!this.target.currentFilterType) { - this.target.currentFilterType = 'literal_or'; + this.target.currentFilterType = 'iliteral_or'; } if (!this.target.currentFilterGroupBy) { diff --git a/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts index d59bf0c64c7..5924fac7a38 100644 --- a/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts +++ b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts @@ -17,6 +17,7 @@ describe('OpenTsQueryCtrl', function() { ctx.panelCtrl = {panel: {}}; ctx.panelCtrl.refresh = sinon.spy(); ctx.datasource.getAggregators = sinon.stub().returns(ctx.$q.when([])); + ctx.datasource.getFilterTypes = sinon.stub().returns(ctx.$q.when([])); ctx.ctrl = $controller(OpenTsQueryCtrl, {$scope: ctx.scope}, { panelCtrl: ctx.panelCtrl, From 641845519db1b090ebc6565be7dd6705a88af916 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Mon, 29 Feb 2016 15:50:02 +0800 Subject: [PATCH 27/44] replace 'app' with 'plugins' where needed. --- public/app/features/plugins/page_ctrl.ts | 7 +++---- public/app/features/plugins/partials/edit.html | 2 +- public/app/features/plugins/partials/page.html | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/public/app/features/plugins/page_ctrl.ts b/public/app/features/plugins/page_ctrl.ts index 15b08ca1cfe..9157f14202e 100644 --- a/public/app/features/plugins/page_ctrl.ts +++ b/public/app/features/plugins/page_ctrl.ts @@ -5,14 +5,13 @@ import _ from 'lodash'; export class AppPageCtrl { page: any; - appId: any; + pluginId: any; appModel: any; /** @ngInject */ constructor(private backendSrv, private $routeParams: any, private $rootScope) { - this.appId = $routeParams.appId; - - this.backendSrv.get(`/api/org/apps/${this.appId}/settings`).then(app => { + this.pluginId = $routeParams.pluginId; + this.backendSrv.get(`/api/org/plugins/${this.pluginId}/settings`).then(app => { this.appModel = app; this.page = _.findWhere(app.pages, {slug: this.$routeParams.slug}); if (!this.page) { diff --git a/public/app/features/plugins/partials/edit.html b/public/app/features/plugins/partials/edit.html index 8747ac66610..815e165cc85 100644 --- a/public/app/features/plugins/partials/edit.html +++ b/public/app/features/plugins/partials/edit.html @@ -72,7 +72,7 @@ {{ds.name}}
  • - {{page.name}} + {{page.name}}
  • diff --git a/public/app/features/plugins/partials/page.html b/public/app/features/plugins/partials/page.html index c65053b47fe..db6d64457bf 100644 --- a/public/app/features/plugins/partials/page.html +++ b/public/app/features/plugins/partials/page.html @@ -1,4 +1,4 @@ - +
    From ae604b62896959cb4370ecaee02e3127baca0a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 09:50:40 +0100 Subject: [PATCH 28/44] ux(annotations): minor polish to annotations editor --- public/app/features/annotations/editor_ctrl.js | 5 +---- public/app/features/annotations/partials/editor.html | 2 +- public/sass/components/_color_picker.scss | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/public/app/features/annotations/editor_ctrl.js b/public/app/features/annotations/editor_ctrl.js index d9731686a4f..8d3887ee757 100644 --- a/public/app/features/annotations/editor_ctrl.js +++ b/public/app/features/annotations/editor_ctrl.js @@ -12,10 +12,7 @@ function (angular, _, $) { var annotationDefaults = { name: '', datasource: null, - showLine: true, - iconColor: '#C0C6BE', - lineColor: 'rgba(255, 96, 96, 0.592157)', - iconSize: 13, + iconColor: 'rgba(255, 96, 96, 1)', enable: true }; diff --git a/public/app/features/annotations/partials/editor.html b/public/app/features/annotations/partials/editor.html index c54d33fe939..702d8921bef 100644 --- a/public/app/features/annotations/partials/editor.html +++ b/public/app/features/annotations/partials/editor.html @@ -76,8 +76,8 @@
    +
    diff --git a/public/sass/components/_color_picker.scss b/public/sass/components/_color_picker.scss index 9e8adfd6226..d5f04265fc8 100644 --- a/public/sass/components/_color_picker.scss +++ b/public/sass/components/_color_picker.scss @@ -31,7 +31,7 @@ width: 15px; height: 15px; border: none; - margin-right: 5px; + margin: 0; float: left; z-index: 0; } From 09dfaf98755bbb30aed53074537aba1393d08a95 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Mon, 29 Feb 2016 17:42:38 +0900 Subject: [PATCH 29/44] timeFrom and timeShift templating --- public/app/core/directives/ng_model_on_blur.js | 3 +++ public/app/features/panel/metrics_panel_ctrl.ts | 10 +++++++--- public/app/plugins/panel/singlestat/module.ts | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/public/app/core/directives/ng_model_on_blur.js b/public/app/core/directives/ng_model_on_blur.js index 1e3ebc38a25..6f4a55b53f0 100644 --- a/public/app/core/directives/ng_model_on_blur.js +++ b/public/app/core/directives/ng_model_on_blur.js @@ -47,6 +47,9 @@ function (coreModule, kbn, rangeUtil) { if (ctrl.$isEmpty(modelValue)) { return true; } + if (viewValue.indexOf('$') === 0) { + return true; // allow template variable + } var info = rangeUtil.describeTextRange(viewValue); return info.invalid !== true; }; diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 537bdbbcbdb..e1ad782fa74 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -17,6 +17,7 @@ class MetricsPanelCtrl extends PanelCtrl { $timeout: any; datasourceSrv: any; timeSrv: any; + templateSrv: any; timing: any; range: any; rangeRaw: any; @@ -34,6 +35,7 @@ class MetricsPanelCtrl extends PanelCtrl { this.$q = $injector.get('$q'); this.datasourceSrv = $injector.get('datasourceSrv'); this.timeSrv = $injector.get('timeSrv'); + this.templateSrv = $injector.get('templateSrv'); if (!this.panel.targets) { this.panel.targets = [{}]; @@ -119,7 +121,8 @@ class MetricsPanelCtrl extends PanelCtrl { // check panel time overrrides if (this.panel.timeFrom) { - var timeFromInfo = rangeUtil.describeTextRange(this.panel.timeFrom); + var timeFromInterpolated = this.templateSrv.replace(this.panel.timeFrom, this.panel.scopedVars); + var timeFromInfo = rangeUtil.describeTextRange(timeFromInterpolated); if (timeFromInfo.invalid) { this.timeInfo = 'invalid time override'; return; @@ -136,13 +139,14 @@ class MetricsPanelCtrl extends PanelCtrl { } if (this.panel.timeShift) { - var timeShiftInfo = rangeUtil.describeTextRange(this.panel.timeShift); + var timeShiftInterpolated = this.templateSrv.replace(this.panel.timeShift, this.panel.scopedVars); + var timeShiftInfo = rangeUtil.describeTextRange(timeShiftInterpolated); if (timeShiftInfo.invalid) { this.timeInfo = 'invalid timeshift'; return; } - var timeShift = '-' + this.panel.timeShift; + var timeShift = '-' + timeShiftInterpolated; this.timeInfo += ' timeshift ' + timeShift; this.range.from = dateMath.parseDateMath(timeShift, this.range.from, false); this.range.to = dateMath.parseDateMath(timeShift, this.range.to, true); diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 7f576cc3f2d..6f692c700de 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -50,7 +50,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { unitFormats: any[]; /** @ngInject */ - constructor($scope, $injector, private $location, private linkSrv, private templateSrv) { + constructor($scope, $injector, private $location, private linkSrv) { super($scope, $injector); _.defaults(this.panel, panelDefaults); } From c30c12d36950fc9a21b0f5a8b5423454bab33721 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 10:05:00 +0100 Subject: [PATCH 30/44] fix(single_stat): rounding bug in value => text --- public/app/plugins/panel/singlestat/editor.html | 4 ++-- public/app/plugins/panel/singlestat/module.ts | 2 +- .../panel/singlestat/specs/singlestat-specs.ts | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/panel/singlestat/editor.html b/public/app/plugins/panel/singlestat/editor.html index bf3227f7582..6b0806133b8 100644 --- a/public/app/plugins/panel/singlestat/editor.html +++ b/public/app/plugins/panel/singlestat/editor.html @@ -167,13 +167,13 @@
  • - +
  • - +
  • diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 7f576cc3f2d..88e09937186 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -213,7 +213,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { // value/number to text mapping var value = parseFloat(map.value); - if (value === data.value) { + if (value === data.valueRounded) { data.valueFormated = map.text; return; } diff --git a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts index 283389ee400..90bd5339737 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts @@ -69,14 +69,20 @@ describe('SingleStatCtrl', function() { singleStatScenario('When value to text mapping is specified', function(ctx) { ctx.setup(function() { - ctx.datapoints = [[10,1]]; + ctx.datapoints = [[9.9,1]]; ctx.ctrl.panel.valueMaps = [{value: '10', text: 'OK'}]; }); - it('Should replace value with text', function() { - expect(ctx.data.value).to.be(10); - expect(ctx.data.valueFormated).to.be('OK'); + it('value should remain', function() { + expect(ctx.data.value).to.be(9.9); }); + it('round should be rounded up', function() { + expect(ctx.data.valueRounded).to.be(10); + }); + + it('Should replace value with text', function() { + expect(ctx.data.valueFormated).to.be('OK'); + }); }); }); From 05ba32b55292d8643659cd6e300e7fb91b48971f Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 10:18:50 +0100 Subject: [PATCH 31/44] feat(datasource): add type to datasource list closes #4183 --- public/app/features/datasources/partials/list.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/features/datasources/partials/list.html b/public/app/features/datasources/partials/list.html index 6ad9c18bc53..940927df688 100644 --- a/public/app/features/datasources/partials/list.html +++ b/public/app/features/datasources/partials/list.html @@ -23,6 +23,7 @@ name + type url @@ -37,7 +38,10 @@ - {{ds.url}} + {{ds.type}} + + + {{ds.url}} From 86b1906798f61c97abde151779a4e412fc117ba1 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 10:29:40 +0100 Subject: [PATCH 32/44] fix(templating): make checkboxes a new row --- .../app/features/templating/partials/editor.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 1ea99617f1d..aab5f048465 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -91,12 +91,17 @@ -
    - Label - - - +
    +
    + Label + +
    +
    + + +
    +
    Value Options
    From 4299feee3799402119972083696194f7ab6984cc Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 10:49:11 +0100 Subject: [PATCH 33/44] feat(templates): collapse submenu if none visable templates --- public/app/features/dashboard/dashboardSrv.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index be404dd1ce1..01c5787481b 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -140,7 +140,11 @@ function (angular, $, _, moment) { }; p.isSubmenuFeaturesEnabled = function() { - return this.templating.list.length > 0 || this.annotations.list.length > 0 || this.links.length > 0; + var visableTemplates = _.filter(this.templating.list, function(template) { + return template.hideVariable === undefined || template.hideVariable === false; + }); + + return visableTemplates.length > 0 || this.annotations.list.length > 0 || this.links.length > 0; }; p.getPanelInfoById = function(panelId) { From fb33cf4576a329c6f6a3f7aab1c7ba0b6e20fde3 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 11:14:24 +0100 Subject: [PATCH 34/44] docs(changelog): add info about templated timeshift --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f4fbef587..dcdc838115c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ * **Admin**: Admin can now have global overview of Grafana setup, closes [#3812](https://github.com/grafana/grafana/issues/3812) * **graph**: Right side legend height is now fixed at row height, closes [#1277](https://github.com/grafana/grafana/issues/1277) * **Table**: All content in table panel is now html escaped, closes [#3673](https://github.com/grafana/grafana/issues/3673) +* **graph**: Template variables can now be used in TimeShift and TimeFrom, closes[#1960](https://github.com/grafana/grafana/issues/1960) ### Bug fixes * **Playlist**: Fix for memory leak when running a playlist, closes [#3794](https://github.com/grafana/grafana/pull/3794) From 4741152f0526b1998e786558798cb0b67b14ba3d Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Mon, 29 Feb 2016 19:37:35 +0800 Subject: [PATCH 35/44] correct path for app page links. --- pkg/api/index.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/index.go b/pkg/api/index.go index df752109530..a5199fa79ae 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -85,13 +85,13 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { if plugin.Pinned { pageLink := &dtos.NavLink{ Text: plugin.Name, - Url: setting.AppSubUrl + "/apps/" + plugin.Id + "/edit", + Url: setting.AppSubUrl + "/plugins/" + plugin.Id + "/edit", Img: plugin.Info.Logos.Small, } for _, page := range plugin.Pages { pageLink.Children = append(pageLink.Children, &dtos.NavLink{ - Url: setting.AppSubUrl + "/apps/" + plugin.Id + "/page/" + page.Slug, + Url: setting.AppSubUrl + "/plugins/" + plugin.Id + "/page/" + page.Slug, Text: page.Name, }) } From 35f7a71f9a2a70f873db475044330b0e75af0376 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Mon, 29 Feb 2016 19:54:36 +0800 Subject: [PATCH 36/44] fix app->plugin renamin in more places --- pkg/api/api.go | 5 +++-- public/app/features/plugins/partials/page.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 90d613e46e0..ed029a5171a 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -43,8 +43,9 @@ func Register(r *macaron.Macaron) { r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, Index) r.Get("/admin/stats", reqGrafanaAdmin, Index) - r.Get("/apps", reqSignedIn, Index) - r.Get("/apps/edit/*", reqSignedIn, Index) + r.Get("/plugins", reqSignedIn, Index) + r.Get("/plugins/:id/edit", reqSignedIn, Index) + r.Get("/plugins/:id/page/:page", reqSignedIn, Index) r.Get("/dashboard/*", reqSignedIn, Index) r.Get("/dashboard-solo/*", reqSignedIn, Index) diff --git a/public/app/features/plugins/partials/page.html b/public/app/features/plugins/partials/page.html index db6d64457bf..949175419ac 100644 --- a/public/app/features/plugins/partials/page.html +++ b/public/app/features/plugins/partials/page.html @@ -1,4 +1,4 @@ - +
    From 56c080417a30bbb52ee74eea70c3682fa9d185a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 13:42:07 +0100 Subject: [PATCH 37/44] fix(logging): only log to xorm.log when in dev mode, fixes #4182 --- pkg/services/sqlstore/sqlstore.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/services/sqlstore/sqlstore.go b/pkg/services/sqlstore/sqlstore.go index e3db2d7f537..8dae7247a39 100644 --- a/pkg/services/sqlstore/sqlstore.go +++ b/pkg/services/sqlstore/sqlstore.go @@ -77,7 +77,7 @@ func NewEngine() { log.Fatal(3, "Sqlstore: Fail to connect to database: %v", err) } - err = SetEngine(x, true) + err = SetEngine(x, setting.Env == setting.DEV) if err != nil { log.Fatal(3, "fail to initialize orm engine: %v", err) @@ -105,14 +105,6 @@ func SetEngine(engine *xorm.Engine, enableLog bool) (err error) { return fmt.Errorf("sqlstore.init(fail to create xorm.log): %v", err) } x.Logger = xorm.NewSimpleLogger(f) - - if setting.Env == setting.DEV { - x.ShowSQL = false - x.ShowInfo = false - x.ShowDebug = false - x.ShowErr = true - x.ShowWarn = true - } } return nil From 3624587f08a8e179ff1c823f803a24f3e20c9eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 13:42:55 +0100 Subject: [PATCH 38/44] misc(): added elasticsearch.yml config file to docker test env --- docker/blocks/elastic/elasticsearch.yml | 2 ++ docker/blocks/elastic/elasticsearch/config/.placeholder | 1 - docker/blocks/elastic/fig | 2 ++ public/app/features/templating/templateValuesSrv.js | 1 + public/sass/base/_fonts.scss | 6 +----- 5 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 docker/blocks/elastic/elasticsearch.yml delete mode 100644 docker/blocks/elastic/elasticsearch/config/.placeholder diff --git a/docker/blocks/elastic/elasticsearch.yml b/docker/blocks/elastic/elasticsearch.yml new file mode 100644 index 00000000000..c57b2c12908 --- /dev/null +++ b/docker/blocks/elastic/elasticsearch.yml @@ -0,0 +1,2 @@ +script.inline: on +script.indexed: on diff --git a/docker/blocks/elastic/elasticsearch/config/.placeholder b/docker/blocks/elastic/elasticsearch/config/.placeholder deleted file mode 100644 index 9ad266259c2..00000000000 --- a/docker/blocks/elastic/elasticsearch/config/.placeholder +++ /dev/null @@ -1 +0,0 @@ -Ensure the existence of the parent folder. diff --git a/docker/blocks/elastic/fig b/docker/blocks/elastic/fig index 498402ac7b0..357352cabaa 100644 --- a/docker/blocks/elastic/fig +++ b/docker/blocks/elastic/fig @@ -4,3 +4,5 @@ elasticsearch: ports: - "9200:9200" - "9300:9300" + volumes: + - ./blocks/elastic/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 2760bb42ca0..bcc27317998 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -45,6 +45,7 @@ function (angular, _, kbn) { }; this.setVariableFromUrl = function(variable, urlValue) { + debugger; var option = _.findWhere(variable.options, { text: urlValue }); option = option || { text: urlValue, value: urlValue }; diff --git a/public/sass/base/_fonts.scss b/public/sass/base/_fonts.scss index f43721afb3a..eece414d45d 100644 --- a/public/sass/base/_fonts.scss +++ b/public/sass/base/_fonts.scss @@ -8,7 +8,7 @@ font-weight: normal; font-style: normal; } - + .icon-gf { /* use !important to prevent issues with browser extensions that change fonts */ font-family: 'grafana-icons' !important; @@ -28,10 +28,6 @@ vertical-align: middle; } - - - - .icon-gf-raintank_wordmark:before { content: "\e600"; } From e5970e83ffccf7db3b8bd5532e11413f21ed7701 Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 26 Feb 2016 10:09:38 +0100 Subject: [PATCH 39/44] feat(dashlist): list last x viewed dashboards closes #3896 --- public/app/features/dashboard/all.js | 1 + .../features/dashboard/dashboardLoaderSrv.js | 25 +++++++---- public/app/features/dashboard/impressions.js | 7 ++++ public/app/features/dashboard/impressions2.ts | 41 +++++++++++++++++++ public/app/plugins/panel/dashlist/module.html | 2 +- public/app/plugins/panel/dashlist/module.ts | 16 +++++++- public/dashboards/home.json | 4 +- 7 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 public/app/features/dashboard/impressions.js create mode 100644 public/app/features/dashboard/impressions2.ts diff --git a/public/app/features/dashboard/all.js b/public/app/features/dashboard/all.js index 073ca2ae1d9..15b96f2a1b6 100644 --- a/public/app/features/dashboard/all.js +++ b/public/app/features/dashboard/all.js @@ -16,4 +16,5 @@ define([ './graphiteImportCtrl', './dynamicDashboardSrv', './importCtrl', + './impressions', ], function () {}); diff --git a/public/app/features/dashboard/dashboardLoaderSrv.js b/public/app/features/dashboard/dashboardLoaderSrv.js index f578a9d1075..5b775166381 100644 --- a/public/app/features/dashboard/dashboardLoaderSrv.js +++ b/public/app/features/dashboard/dashboardLoaderSrv.js @@ -5,8 +5,9 @@ define([ 'jquery', 'app/core/utils/kbn', 'app/core/utils/datemath', + './impressions', ], -function (angular, moment, _, $, kbn, dateMath) { +function (angular, moment, _, $, kbn, dateMath, impressions) { 'use strict'; var module = angular.module('grafana.services'); @@ -24,19 +25,27 @@ function (angular, moment, _, $, kbn, dateMath) { }; this.loadDashboard = function(type, slug) { - if (type === 'script') { - return this._loadScriptedDashboard(slug); - } + var promise; - if (type === 'snapshot') { - return backendSrv.get('/api/snapshots/' + $routeParams.slug).catch(function() { + if (type === 'script') { + promise = this._loadScriptedDashboard(slug); + } else if (type === 'snapshot') { + promise = backendSrv.get('/api/snapshots/' + $routeParams.slug).catch(function() { return {meta:{isSnapshot: true, canSave: false, canEdit: false}, dashboard: {title: 'Snapshot not found'}}; }); + } else { + promise = backendSrv.getDashboard($routeParams.type, $routeParams.slug) + .catch(function() { + return self._dashboardLoadFailed("Not found"); + }); } - return backendSrv.getDashboard($routeParams.type, $routeParams.slug).catch(function() { - return self._dashboardLoadFailed("Not found"); + promise.then(function(result) { + impressions.addImpression(slug); + return result; }); + + return promise; }; this._loadScriptedDashboard = function(file) { diff --git a/public/app/features/dashboard/impressions.js b/public/app/features/dashboard/impressions.js new file mode 100644 index 00000000000..2a83f4543a5 --- /dev/null +++ b/public/app/features/dashboard/impressions.js @@ -0,0 +1,7 @@ +define([ + './impressions2' +], function(impressions) { + 'use strict'; + // backward compatability hack; + return impressions.impressions; +}); diff --git a/public/app/features/dashboard/impressions2.ts b/public/app/features/dashboard/impressions2.ts new file mode 100644 index 00000000000..3a0ec574344 --- /dev/null +++ b/public/app/features/dashboard/impressions2.ts @@ -0,0 +1,41 @@ +/// + +import store from 'app/core/store'; +import _ from 'lodash'; + +export class Impressions { + constructor() {} + + addImpression(slug) { + var impressions = []; + if (store.exists("dashboard_impressions")) { + impressions = JSON.parse(store.get("dashboard_impressions")); + if (!_.isArray(impressions)) { + impressions = []; + } + } + + var exists = impressions.indexOf(slug); + if (exists >= 0) { + impressions.splice(exists, 1); + } + + impressions.unshift(slug); + + if (impressions.length > 20) { + impressions.shift(); + } + store.set("dashboard_impressions", JSON.stringify(impressions)); + } + + getImpressions() { + var k = store.get("dashboard_impressions"); + return JSON.parse(k); + } +} + +var impressions = new Impressions(); + +export { + impressions +}; diff --git a/public/app/plugins/panel/dashlist/module.html b/public/app/plugins/panel/dashlist/module.html index 455291409d5..79952d0032c 100644 --- a/public/app/plugins/panel/dashlist/module.html +++ b/public/app/plugins/panel/dashlist/module.html @@ -5,7 +5,7 @@ {{dash.title}} - +
    diff --git a/public/app/plugins/panel/dashlist/module.ts b/public/app/plugins/panel/dashlist/module.ts index a1c72434b38..46da2e4f519 100644 --- a/public/app/plugins/panel/dashlist/module.ts +++ b/public/app/plugins/panel/dashlist/module.ts @@ -3,6 +3,7 @@ import _ from 'lodash'; import config from 'app/core/config'; import {PanelCtrl} from 'app/plugins/sdk'; +import {impressions} from 'app/features/dashboard/impressions2'; // Set and populate defaults var panelDefaults = { @@ -31,7 +32,7 @@ class DashListCtrl extends PanelCtrl { initEditMode() { super.initEditMode(); - this.modes = ['starred', 'search']; + this.modes = ['starred', 'search', 'last viewed']; this.icon = "fa fa-star"; this.addEditorTab('Options', () => { return {templateUrl: 'public/app/plugins/panel/dashlist/editor.html'}; @@ -41,6 +42,19 @@ class DashListCtrl extends PanelCtrl { refresh() { var params: any = {limit: this.panel.limit}; + if (this.panel.mode === 'last viewed') { + var dashListNames = _.first(impressions.getImpressions(), this.panel.limit).map((dashboard) => { + return { + title: dashboard, + uri: 'db/' + dashboard + }; + }); + + this.dashList = dashListNames; + this.renderingCompleted(); + return; + } + if (this.panel.mode === 'starred') { params.starred = "true"; } else { diff --git a/public/dashboards/home.json b/public/dashboards/home.json index e05a882ef57..d54e276db5c 100644 --- a/public/dashboards/home.json +++ b/public/dashboards/home.json @@ -47,11 +47,11 @@ { "id": 3, "limit": 10, - "mode": "search", + "mode": "last viewed", "query": "", "span": 6, "tags": [], - "title": "Dashboards", + "title": "Last 10 viewed dashboards", "type": "dashlist" } ], From 97c27668bc5a4f590ccdec574d3f9153e960692e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 14:15:46 +0100 Subject: [PATCH 40/44] fix(): fix failing build and removed panel icon from edit mode tabs --- public/app/features/panel/panel_directive.ts | 1 - public/app/features/templating/templateValuesSrv.js | 1 - 2 files changed, 2 deletions(-) diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index ce6d031c6af..a15224a622a 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -31,7 +31,6 @@ var panelTemplate = `

    - {{ctrl.pluginName}}

    diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index bcc27317998..2760bb42ca0 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -45,7 +45,6 @@ function (angular, _, kbn) { }; this.setVariableFromUrl = function(variable, urlValue) { - debugger; var option = _.findWhere(variable.options, { text: urlValue }); option = option || { text: urlValue, value: urlValue }; From d27a0f5b0c2ec799818df78ec84fc3a9602e71c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 14:35:55 +0100 Subject: [PATCH 41/44] ux(): small ux fix for inspector modal --- public/app/partials/inspector.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/app/partials/inspector.html b/public/app/partials/inspector.html index 9caa38bb39f..9187e429613 100644 --- a/public/app/partials/inspector.html +++ b/public/app/partials/inspector.html @@ -18,8 +18,8 @@
    -
    Request details
    - +
    Request details
    +
    @@ -38,8 +38,8 @@
    Url {{inspector.error.config.url}}
    -
    Request parameters
    - +
    Request parameters
    +
    {{param.key}} From b79217be1e48d21b25b5cd1e04f8c73e63951b3c Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 14:37:09 +0100 Subject: [PATCH 42/44] feat(impressionStore): remove un needed js-ts bridge --- public/app/features/dashboard/all.js | 2 +- public/app/features/dashboard/dashboardLoaderSrv.js | 6 +++--- .../dashboard/{impressions2.ts => impressionStore.ts} | 8 ++++---- public/app/features/dashboard/impressions.js | 7 ------- public/app/plugins/panel/dashlist/module.ts | 4 ++-- 5 files changed, 10 insertions(+), 17 deletions(-) rename public/app/features/dashboard/{impressions2.ts => impressionStore.ts} (84%) delete mode 100644 public/app/features/dashboard/impressions.js diff --git a/public/app/features/dashboard/all.js b/public/app/features/dashboard/all.js index 15b96f2a1b6..d5cc13b4270 100644 --- a/public/app/features/dashboard/all.js +++ b/public/app/features/dashboard/all.js @@ -16,5 +16,5 @@ define([ './graphiteImportCtrl', './dynamicDashboardSrv', './importCtrl', - './impressions', + './impressionStore', ], function () {}); diff --git a/public/app/features/dashboard/dashboardLoaderSrv.js b/public/app/features/dashboard/dashboardLoaderSrv.js index 5b775166381..f975c47800f 100644 --- a/public/app/features/dashboard/dashboardLoaderSrv.js +++ b/public/app/features/dashboard/dashboardLoaderSrv.js @@ -5,9 +5,9 @@ define([ 'jquery', 'app/core/utils/kbn', 'app/core/utils/datemath', - './impressions', + './impressionStore', ], -function (angular, moment, _, $, kbn, dateMath, impressions) { +function (angular, moment, _, $, kbn, dateMath, impressionStore) { 'use strict'; var module = angular.module('grafana.services'); @@ -41,7 +41,7 @@ function (angular, moment, _, $, kbn, dateMath, impressions) { } promise.then(function(result) { - impressions.addImpression(slug); + impressionStore.impressions.addDashboardImpression(slug); return result; }); diff --git a/public/app/features/dashboard/impressions2.ts b/public/app/features/dashboard/impressionStore.ts similarity index 84% rename from public/app/features/dashboard/impressions2.ts rename to public/app/features/dashboard/impressionStore.ts index 3a0ec574344..61be1131cb6 100644 --- a/public/app/features/dashboard/impressions2.ts +++ b/public/app/features/dashboard/impressionStore.ts @@ -3,10 +3,10 @@ import store from 'app/core/store'; import _ from 'lodash'; -export class Impressions { +export class ImpressionsStore { constructor() {} - addImpression(slug) { + addDashboardImpression(slug) { var impressions = []; if (store.exists("dashboard_impressions")) { impressions = JSON.parse(store.get("dashboard_impressions")); @@ -28,13 +28,13 @@ export class Impressions { store.set("dashboard_impressions", JSON.stringify(impressions)); } - getImpressions() { + getDashboardOpened() { var k = store.get("dashboard_impressions"); return JSON.parse(k); } } -var impressions = new Impressions(); +var impressions = new ImpressionsStore(); export { impressions diff --git a/public/app/features/dashboard/impressions.js b/public/app/features/dashboard/impressions.js deleted file mode 100644 index 2a83f4543a5..00000000000 --- a/public/app/features/dashboard/impressions.js +++ /dev/null @@ -1,7 +0,0 @@ -define([ - './impressions2' -], function(impressions) { - 'use strict'; - // backward compatability hack; - return impressions.impressions; -}); diff --git a/public/app/plugins/panel/dashlist/module.ts b/public/app/plugins/panel/dashlist/module.ts index 46da2e4f519..fd0e905d923 100644 --- a/public/app/plugins/panel/dashlist/module.ts +++ b/public/app/plugins/panel/dashlist/module.ts @@ -3,7 +3,7 @@ import _ from 'lodash'; import config from 'app/core/config'; import {PanelCtrl} from 'app/plugins/sdk'; -import {impressions} from 'app/features/dashboard/impressions2'; +import {impressions} from 'app/features/dashboard/impressionStore'; // Set and populate defaults var panelDefaults = { @@ -43,7 +43,7 @@ class DashListCtrl extends PanelCtrl { var params: any = {limit: this.panel.limit}; if (this.panel.mode === 'last viewed') { - var dashListNames = _.first(impressions.getImpressions(), this.panel.limit).map((dashboard) => { + var dashListNames = _.first(impressions.getDashboardOpened(), this.panel.limit).map((dashboard) => { return { title: dashboard, uri: 'db/' + dashboard From 0cbb95ed1eb6ab53173c545199f155df77cefedb Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 29 Feb 2016 15:01:26 +0100 Subject: [PATCH 43/44] fix(export_csv): rename export to csv label --- public/app/plugins/panel/graph/module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 50ad7f87083..357da9b6877 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -125,8 +125,8 @@ class GraphCtrl extends MetricsPanelCtrl { getExtendedMenu() { var menu = super.getExtendedMenu(); - menu.push({text: 'Export CSV', click: 'ctrl.exportCsv()'}); - menu.push({text: 'Export CSV (series2columns)', click: 'ctrl.exportCsvColumns()'}); + menu.push({text: 'Export CSV (series as rows)', click: 'ctrl.exportCsv()'}); + menu.push({text: 'Export CSV (series as columns)', click: 'ctrl.exportCsvColumns()'}); menu.push({text: 'Toggle legend', click: 'ctrl.toggleLegend()'}); return menu; } From 839c675cb9a322f5d50f4ccc8472458497e71178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 29 Feb 2016 16:38:45 +0100 Subject: [PATCH 44/44] ux(): minor tweak --- public/app/partials/metrics.html | 2 +- public/sass/base/_type.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/partials/metrics.html b/public/app/partials/metrics.html index f7b1672cd97..7297d415c25 100644 --- a/public/app/partials/metrics.html +++ b/public/app/partials/metrics.html @@ -37,7 +37,7 @@ -
    +