From ad8dbbb559d2f885b306da98d57a1f33917c8d4a Mon Sep 17 00:00:00 2001 From: woodsaj Date: Thu, 28 Apr 2016 18:39:23 +0800 Subject: [PATCH 1/3] allow updates to secureJsonData. SecureJsonData is stored as a json object in the DB. As the secureJsonData is never returned to the user they are unable to provide the full json object when performing updates instead the user can only provide the specific keys they wish to update. This commit ensures that only the provided keys are updated and existing keys in the secureJsonData object are left untouched. --- pkg/services/sqlstore/plugin_setting.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/services/sqlstore/plugin_setting.go b/pkg/services/sqlstore/plugin_setting.go index b3285e905cf..ec0b9b2e2d7 100644 --- a/pkg/services/sqlstore/plugin_setting.go +++ b/pkg/services/sqlstore/plugin_setting.go @@ -61,7 +61,6 @@ func UpdatePluginSetting(cmd *m.UpdatePluginSettingCmd) error { for key, data := range cmd.SecureJsonData { pluginSetting.SecureJsonData[key] = util.Encrypt([]byte(data), setting.SecretKey) } - pluginSetting.SecureJsonData = cmd.GetEncryptedJsonData() pluginSetting.Updated = time.Now() pluginSetting.Enabled = cmd.Enabled pluginSetting.JsonData = cmd.JsonData From 69c2fafa7a4d88067ae0c16f7e8475148fefe308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 28 Apr 2016 15:29:54 +0200 Subject: [PATCH 2/3] feat(elasticsearch): added geo hash bucket aggregation --- .../plugins/datasource/elasticsearch/bucket_agg.js | 11 +++++++++++ .../datasource/elasticsearch/partials/bucket_agg.html | 7 +++++++ .../plugins/datasource/elasticsearch/query_builder.js | 4 ++++ .../app/plugins/datasource/elasticsearch/query_def.js | 1 + 4 files changed, 23 insertions(+) diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js index 18e2f3cf3b1..43ef4f91ab7 100644 --- a/public/app/plugins/datasource/elasticsearch/bucket_agg.js +++ b/public/app/plugins/datasource/elasticsearch/bucket_agg.js @@ -60,6 +60,10 @@ function (angular, _, queryDef) { $scope.agg.query = '*'; break; } + case 'geohash_grid': { + $scope.agg.settings.precision = 3; + break; + } } $scope.validateModel(); @@ -121,6 +125,13 @@ function (angular, _, queryDef) { if (settings.trimEdges && settings.trimEdges > 0) { settingsLinkText += ', Trim edges: ' + settings.trimEdges; } + break; + } + case 'geohash_grid': { + // limit precision to 7 + settings.precision = Math.max(Math.min(settings.precision, 7), 1); + settingsLinkText = 'Precision: ' + settings.precision; + break; } } diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html index cb541c15fed..198c8f5636a 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html @@ -86,6 +86,13 @@ +
+
+ + +
+
+ diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index dd071ba137d..9c8217102aa 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -153,6 +153,10 @@ function (queryDef) { this.buildTermsAgg(aggDef, esAgg, target); break; } + case 'geohash_grid': { + esAgg['geohash_grid'] = {field: aggDef.field, precision: aggDef.settings.precision}; + break; + } } nestedAggs.aggs = nestedAggs.aggs || {}; diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 099cb3607c3..b40fcb73023 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -22,6 +22,7 @@ function (_) { bucketAggTypes: [ {text: "Terms", value: 'terms', requiresField: true}, {text: "Filters", value: 'filters' }, + {text: "Geo Hash Grid", value: 'geohash_grid', requiresField: true}, {text: "Date Histogram", value: 'date_histogram', requiresField: true}, ], From 5d652dcaef499d721296d7181e0de80189e343ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 28 Apr 2016 15:48:49 +0200 Subject: [PATCH 3/3] fix(table): table column sorting fix --- public/app/core/table_model.ts | 2 ++ public/app/plugins/panel/table/module.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/public/app/core/table_model.ts b/public/app/core/table_model.ts index fa0aeccc54b..f3d0b81998f 100644 --- a/public/app/core/table_model.ts +++ b/public/app/core/table_model.ts @@ -32,6 +32,8 @@ export default class TableModel { if (options.desc) { this.rows.reverse(); this.columns[options.col].desc = true; + } else { + this.columns[options.col].desc = false; } } } diff --git a/public/app/plugins/panel/table/module.ts b/public/app/plugins/panel/table/module.ts index 837cf0df916..473ce4baa48 100644 --- a/public/app/plugins/panel/table/module.ts +++ b/public/app/plugins/panel/table/module.ts @@ -120,6 +120,11 @@ class TablePanelCtrl extends MetricsPanelCtrl { } toggleColumnSort(col, colIndex) { + // remove sort flag from current column + if (this.table.columns[this.panel.sort.col]) { + this.table.columns[this.panel.sort.col].sort = false; + } + if (this.panel.sort.col === colIndex) { if (this.panel.sort.desc) { this.panel.sort.desc = false;