From f90fda8e6fd0c2cd0d773c5a3a12ef46b7a67d4a Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Sun, 7 Feb 2016 21:13:00 -0800 Subject: [PATCH] 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'));