From 599b1eb6892b34340be8a940061d9e57f6b0c81f Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 10 Feb 2016 00:35:39 -0800 Subject: [PATCH] Smooth transition from opentsdb 2.1 to 2.2 --- .../plugins/datasource/opentsdb/datasource.js | 2 ++ .../opentsdb/partials/query.editor.html | 36 ++++++++++++------- .../plugins/datasource/opentsdb/query_ctrl.ts | 20 +++++++++++ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 2cf0ecf2571..802ea16076b 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -315,6 +315,8 @@ function (angular, _, dateMath) { } } + query.filters = angular.copy(target.filters); + return query; } diff --git a/public/app/plugins/datasource/opentsdb/partials/query.editor.html b/public/app/plugins/datasource/opentsdb/partials/query.editor.html index f01d63f356c..def68d19bf9 100644 --- a/public/app/plugins/datasource/opentsdb/partials/query.editor.html +++ b/public/app/plugins/datasource/opentsdb/partials/query.editor.html @@ -86,6 +86,7 @@
@@ -163,15 +169,21 @@ spellcheck='false' bs-typeahead="ctrl.suggestTagValues" data-min-length=0 data-items=100 ng-model="ctrl.target.currentTagValue" placeholder="value"> - + + + + + + add tag - - - - + + + + +
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 = {};