From 20e13a427551b8ad8eedfd9c3a53c602dd377ce8 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 5 Apr 2017 23:41:28 -0500 Subject: [PATCH 1/4] Workaround InfluxQL bugs by returning original query. --- influx/query.go | 2 +- influx/query_test.go | 42 +++++++++++++++++++++++++++++++++++++++ server/dashboards_test.go | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 influx/query_test.go diff --git a/influx/query.go b/influx/query.go index 2601898243..c3340bb9c0 100644 --- a/influx/query.go +++ b/influx/query.go @@ -15,7 +15,7 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) { } raw := chronograf.QueryConfig{ - RawText: query.String(), + RawText: influxQL, Fields: []chronograf.Field{}, GroupBy: chronograf.GroupBy{ Tags: []string{}, diff --git a/influx/query_test.go b/influx/query_test.go new file mode 100644 index 0000000000..b930cb4fa1 --- /dev/null +++ b/influx/query_test.go @@ -0,0 +1,42 @@ +package influx + +import ( + "reflect" + "testing" + + "github.com/influxdata/chronograf" +) + +func TestConvert(t *testing.T) { + tests := []struct { + name string + influxQL string + want chronograf.QueryConfig + wantErr bool + }{ + { + name: "Test named count field", + influxQL: `SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`, + want: chronograf.QueryConfig{ + RawText: `SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`, + Fields: []chronograf.Field{}, + Tags: map[string][]string{}, + GroupBy: chronograf.GroupBy{ + Tags: []string{}, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := Convert(tt.influxQL) + if (err != nil) != tt.wantErr { + t.Errorf("Convert() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("Convert() = %#v, want %#v", got, tt.want) + } + }) + } +} diff --git a/server/dashboards_test.go b/server/dashboards_test.go index 55547f5fb6..2d1c3c034f 100644 --- a/server/dashboards_test.go +++ b/server/dashboards_test.go @@ -246,7 +246,7 @@ func Test_newDashboardResponse(t *testing.T) { { Command: "SELECT donors from hill_valley_preservation_society where time > '1985-10-25 08:00:00'", QueryConfig: chronograf.QueryConfig{ - RawText: "SELECT donors FROM hill_valley_preservation_society WHERE time > '1985-10-25 08:00:00'", + RawText: "SELECT donors from hill_valley_preservation_society where time > '1985-10-25 08:00:00'", Fields: []chronograf.Field{}, GroupBy: chronograf.GroupBy{ Tags: []string{}, From 66f5c890d40ac9c60ab4ca16ceab7d2e3e321e51 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 6 Apr 2017 00:57:50 -0500 Subject: [PATCH 2/4] Update CHANGELOG to mention fixing no quoted raw influxql --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92b9643939..4496ec5d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ 1. [#1179](https://github.com/influxdata/chronograf/pull/1179): Admin Databases Page will render a database without retention policies 1. [#1128](https://github.com/influxdata/chronograf/pull/1128): No more ghost dashboards 👻 1. [#1189](https://github.com/influxdata/chronograf/pull/1189): Clicking inside the graph header edit box will no longer blur the field. Use the Escape key for that behavior instead. + 1. [#1193](https://github.com/influxdata/chronograf/issues/1193): Fix no quoting of raw InfluxQL fields with function names ### Features 1. [#1112](https://github.com/influxdata/chronograf/pull/1112): Add ability to delete a dashboard From b7f91df6f412f0b2ad6278bd70aa187810f3aa4b Mon Sep 17 00:00:00 2001 From: Luke Morris Date: Thu, 6 Apr 2017 13:46:50 -0700 Subject: [PATCH 3/4] No need to build a query if rawText exists --- ui/src/shared/components/LayoutRenderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/src/shared/components/LayoutRenderer.js b/ui/src/shared/components/LayoutRenderer.js index c8992cb4d6..f772b0f9aa 100644 --- a/ui/src/shared/components/LayoutRenderer.js +++ b/ui/src/shared/components/LayoutRenderer.js @@ -100,7 +100,8 @@ export const LayoutRenderer = React.createClass({ // on a stable query representation. let queryText if (query.queryConfig) { - queryText = buildInfluxQLQuery(timeRange, query.queryConfig) + const {queryConfig: {rawText}} = query + queryText = rawText || buildInfluxQLQuery(timeRange, query.queryConfig) } else { queryText = this.buildQueryForOldQuerySchema(query) } From ee9042bd602fe6f9e61793f33da82eef354bd4de Mon Sep 17 00:00:00 2001 From: lukevmorris Date: Thu, 6 Apr 2017 14:30:36 -0700 Subject: [PATCH 4/4] These three are siblings now; give them a stacking priority (#1215) --- ui/src/style/pages/dashboards.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/style/pages/dashboards.scss b/ui/src/style/pages/dashboards.scss index 7d4dff2d0d..ae500071e2 100644 --- a/ui/src/style/pages/dashboards.scss +++ b/ui/src/style/pages/dashboards.scss @@ -57,6 +57,7 @@ $dash-graph-options-arrow: 8px; left: 0; } .dash-graph--container { + z-index: 0; user-select: none !important; -o-user-select: none !important; -moz-user-select: none !important; @@ -88,7 +89,7 @@ $dash-graph-options-arrow: 8px; } } .dash-graph--heading { - z-index: 1; + z-index: 0; user-select: none !important; -o-user-select: none !important; -moz-user-select: none !important; @@ -146,7 +147,7 @@ $dash-graph-options-arrow: 8px; .dash-graph--options { width: $dash-graph-heading; position: absolute; - z-index: 2; + z-index: 1; right: 0px; top: 0px;