Skip to content

Commit

Permalink
fix(ui): fixed dashboard cells and check query builder update bug (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
asalem1 authored Mar 11, 2020
1 parent 0980773 commit d2a49b8
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 81 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
1. [17161](https://github.com/influxdata/influxdb/pull/17161): Update table custom decimal feature for tables to update table onFocus
1. [17168](https://github.com/influxdata/influxdb/pull/17168): Fixed UI bug that was setting Telegraf config buttons off-center and was resizing config selections when filtering through the data
1. [17208](https://github.com/influxdata/influxdb/pull/17208): Fixed UI bug that was setting causing dashboard cells to error when the a v.bucket was being used and was being configured for the first time
1. [17202](https://github.com/influxdata/influxdb/pull/17202): Fixed UI bug that was preventing checks created with the query builder from updating. Also fixed a bug that was preventing dashboard cell queries from working properly when creating group queries using the query builder

## v2.0.0-beta.5 [2020-02-27]

Expand Down
27 changes: 16 additions & 11 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,9 @@ type DashboardQuery struct {
type BuilderConfig struct {
Buckets []string `json:"buckets"`
Tags []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
} `json:"tags"`
Functions []struct {
Name string `json:"name"`
Expand All @@ -895,8 +896,9 @@ func (b BuilderConfig) MarshalJSON() ([]byte, error) {
}
if copyCfg.Tags == nil {
copyCfg.Tags = []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{}
}
if copyCfg.Functions == nil {
Expand All @@ -911,16 +913,19 @@ func (b BuilderConfig) MarshalJSON() ([]byte, error) {
// isn't technically required, but working with struct literals with embedded
// struct tags is really painful. This is to get around that bit. Would be nicer
// to have these as actual types maybe.
func NewBuilderTag(key string, values ...string) struct {
Key string `json:"key"`
Values []string `json:"values"`
func NewBuilderTag(key string, functionType string, values ...string) struct {
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
} {
return struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
Key: key,
Values: values,
Key: key,
Values: values,
AggregateFunctionType: functionType,
}
}

Expand Down
10 changes: 6 additions & 4 deletions notification/check/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ func TestJSON(t *testing.T) {
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{},
Functions: []struct {
Name string `json:"name"`
Expand Down Expand Up @@ -232,8 +233,9 @@ func TestJSON(t *testing.T) {
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{},
Functions: []struct {
Name string `json:"name"`
Expand Down
20 changes: 12 additions & 8 deletions notification/check/deadman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ func TestDeadman_GenerateFlux(t *testing.T) {
Text: `from(bucket: "foo") |> range(start: -1d, stop: now()) |> aggregateWindow(fn: mean, every: 1m) |> yield()`,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -99,12 +101,14 @@ data
Text: `from(bucket: "foo") |> range(start: -1d, stop: now()) |> yield()`,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkger/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ func (q queries) influxDashQueries() []influxdb.DashboardQuery {
EditMode: "advanced",
}
// TODO: axe this builder configs when issue https://github.com/influxdata/influxdb/issues/15708 is fixed up
newQuery.BuilderConfig.Tags = append(newQuery.BuilderConfig.Tags, influxdb.NewBuilderTag("_measurement", ""))
newQuery.BuilderConfig.Tags = append(newQuery.BuilderConfig.Tags, influxdb.NewBuilderTag("_measurement", "filter", ""))
iQueries = append(iQueries, newQuery)
}
return iQueries
Expand Down
2 changes: 1 addition & 1 deletion pkger/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ func TestService(t *testing.T) {
EditMode: "advanced",
}
// TODO: remove this when issue that forced the builder tag to be here to render in UI.
q.BuilderConfig.Tags = append(q.BuilderConfig.Tags, influxdb.NewBuilderTag("_measurement", ""))
q.BuilderConfig.Tags = append(q.BuilderConfig.Tags, influxdb.NewBuilderTag("_measurement", "filter", ""))
return q
}

Expand Down
125 changes: 75 additions & 50 deletions testing/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ var deadman1 = &check.Deadman{
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
Functions: []struct {
Expand Down Expand Up @@ -91,8 +93,9 @@ var threshold1 = &check.Threshold{
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{},
Functions: []struct {
Name string `json:"name"`
Expand Down Expand Up @@ -270,12 +273,14 @@ func CreateCheck(
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -326,12 +331,14 @@ func CreateCheck(
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
Functions: []struct {
Expand Down Expand Up @@ -519,12 +526,14 @@ func CreateCheck(
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -611,12 +620,14 @@ func CreateCheck(
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -657,12 +668,14 @@ func CreateCheck(
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
Functions: []struct {
Expand Down Expand Up @@ -705,12 +718,14 @@ func CreateCheck(
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -1495,12 +1510,14 @@ data = from(bucket: "telegraf") |> range(start: -1m)`,
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -1555,12 +1572,14 @@ data = from(bucket: "telegraf") |> range(start: -1m)`,
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -1624,12 +1643,14 @@ data = from(bucket: "telegraf") |> range(start: -1m)`,
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down Expand Up @@ -1763,12 +1784,14 @@ data = from(bucket: "telegraf") |> range(start: -1m)`,
BuilderConfig: influxdb.BuilderConfig{
Buckets: []string{},
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
Functions: []struct {
Expand Down Expand Up @@ -1816,12 +1839,14 @@ data = from(bucket: "telegraf") |> range(start: -1m)`,
Text: script,
BuilderConfig: influxdb.BuilderConfig{
Tags: []struct {
Key string `json:"key"`
Values []string `json:"values"`
Key string `json:"key"`
Values []string `json:"values"`
AggregateFunctionType string `json:"aggregateFunctionType"`
}{
{
Key: "_field",
Values: []string{"usage_user"},
Key: "_field",
Values: []string{"usage_user"},
AggregateFunctionType: "filter",
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion ui/cypress/fixtures/view.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"tags": [
{
"key": "",
"values": []
"values": [],
"aggregateFunctionType": ""
}
],
"functions": [],
Expand Down
1 change: 1 addition & 0 deletions ui/mocks/dummyData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ export const viewProperties: ViewProperties = {
{
key: '_measurement',
values: [],
aggregateFunctionType: 'filter',
},
],
functions: [],
Expand Down
Loading

0 comments on commit d2a49b8

Please sign in to comment.