Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fixed dashboard cells and check query builder update bug #17202

Merged
merged 3 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyone else curious about this foreboding line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, definitely shows it to @gavincabbage this morning, especially since the issue was closed a couple days ago. I'd love to see @desa 's opinion on this

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