-
Notifications
You must be signed in to change notification settings - Fork 2
Find filters in map visualizations #5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ func (v VisualizationDescriptor) findDocumentPathsAsString(paths []string) strin | |
| m := objx.Map(v.Doc) | ||
|
|
||
| for _, path := range paths { | ||
| if m.Get(path).IsStr() { | ||
| if m.Get(path).IsStr() && m.Get(path).Str() != "" { | ||
| return m.Get(path).Str() | ||
| } | ||
| } | ||
|
|
@@ -137,6 +137,7 @@ func (v VisualizationDescriptor) HasFilters() (bool, error) { | |
| queryPaths := []string{ | ||
| "attributes.kibanaSavedObjectMeta.searchSourceJSON.query.query", | ||
| "attributes.state.query.query", | ||
| "embeddableConfig.attributes.mapStateJSON.query.query", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you also add the path Maps uses Kibana's unified search, which applies filtering from 2 locations.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The structure for queries and filters are different, so there are two different checks, each one with its own list of paths. |
||
| "embeddableConfig.attributes.state.query.query", | ||
| "embeddableConfig.savedVis.data.searchSource.query.query", | ||
| } | ||
|
|
@@ -150,6 +151,7 @@ func (v VisualizationDescriptor) HasFilters() (bool, error) { | |
| filterPaths := []string{ | ||
| "attributes.state.filters", | ||
| "embeddableConfig.attributes.state.filters", | ||
| "embeddableConfig.attributes.mapStateJSON.filters", | ||
| "embeddableConfig.savedVis.data.searchSource.filter", | ||
| "attributes.kibanaSavedObjectMeta.searchSourceJSON.filter", | ||
| } | ||
|
|
@@ -178,10 +180,6 @@ func (v VisualizationDescriptor) TSVBType() string { | |
|
|
||
| // Title returns the visualization title | ||
| func (v VisualizationDescriptor) Title() string { | ||
| if v.SavedObjectType != "visualization" { | ||
| return "" | ||
| } | ||
|
|
||
|
Comment on lines
-181
to
-184
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to return a title only for visualizations? |
||
| return v.findDocumentPathsAsString([]string{ | ||
| "attributes.title", | ||
| "title", | ||
|
|
@@ -191,9 +189,14 @@ func (v VisualizationDescriptor) Title() string { | |
|
|
||
| func deserializeSubPaths(doc objx.Map) error { | ||
| jsonPaths := []string{ | ||
| "attributes.kibanaSavedObjectMeta.searchSourceJSON", | ||
| "attributes.mapStateJSON", | ||
| "attributes.uiStateJSON", | ||
| "attributes.visState", | ||
| "attributes.kibanaSavedObjectMeta.searchSourceJSON", | ||
| "embeddableConfig.attributes.kibanaSavedObjectMeta.searchSourceJSON", | ||
| "embeddableConfig.attributes.mapStateJSON", | ||
| "embeddableConfig.attributes.uiStateJSON", | ||
| "embeddableConfig.attributes.visState", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the paths with the |
||
| } | ||
| for _, fieldName := range jsonPaths { | ||
| field := doc.Get(fieldName) | ||
|
|
@@ -207,6 +210,22 @@ func deserializeSubPaths(doc objx.Map) error { | |
| doc.Set(fieldName, parsed) | ||
| } | ||
|
|
||
| jsonSlicePaths := []string{ | ||
| "attributes.layerListJSON", | ||
| "embeddableConfig.attributes.layerListJSON", | ||
|
Comment on lines
+214
to
+215
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| for _, fieldName := range jsonSlicePaths { | ||
| field := doc.Get(fieldName) | ||
| if !field.IsStr() { | ||
| continue | ||
| } | ||
| parsed, err := objx.FromJSONSlice(field.Str()) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to decode embedded json in %q: %w", fieldName, err) | ||
| } | ||
| doc.Set(fieldName, parsed) | ||
| } | ||
|
|
||
| /* these transformations from the original script facilitate the vis_tsvb_aggs and other TSVB-related runtime fields | ||
| TODO - implement these or convert the | ||
| vis_tsvb_aggs and any other necessary runtime fields to Go | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change this seems to return the first path it founds, even if it is empty. There are cases where the first path is empty, but there are others with values.