Przeglądaj źródła

Tracking opentsdb version in opentsdb config

utkarshcmu 10 lat temu
rodzic
commit
f90fda8e6f

+ 21 - 0
public/app/plugins/datasource/opentsdb/config_ctrl.ts

@@ -0,0 +1,21 @@
+///<reference path="../../../headers/common.d.ts" />
+
+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},
+  ];
+
+}

+ 5 - 0
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 = {};
 

+ 1 - 4
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,

+ 13 - 0
public/app/plugins/datasource/opentsdb/partials/config.html

@@ -1,2 +1,15 @@
 <datasource-http-settings current="ctrl.current"></datasource-http-settings>
 
+<br>
+<h5>Opentsdb settings</h5>
+<div class="tight-form last">
+  <ul class="tight-form-list">
+    <li class="tight-form-item" style="width: 80px">
+      Version
+    </li>
+    <li class="tight-form-item">
+      <select class="input-medium tight-form-input" ng-model="ctrl.current.jsonData.tsdbVersion" ng-options="v.value as v.name for v in ctrl.tsdbVersions"></select>
+    </li>
+  </ul>
+  <div class="clearfix"></div>
+</div>

+ 1 - 1
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'));