mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Search: Include collapsed panels in search v2 (#83047)
* Include collapsed panels in searchv2 * Include collapsed row in TestReadSummaries
This commit is contained in:
parent
91cd17f012
commit
467302480f
@ -60,6 +60,23 @@ func NewStaticDashboardSummaryBuilder(lookup DatasourceLookup, sanitize bool) en
|
||||
summary.Fields["schemaVersion"] = fmt.Sprint(dash.SchemaVersion)
|
||||
|
||||
for _, panel := range dash.Panels {
|
||||
s := panelSummary(panel, uid, dashboardRefs)
|
||||
summary.Nested = append(summary.Nested, s...)
|
||||
}
|
||||
|
||||
summary.References = dashboardRefs.Get()
|
||||
if sanitize {
|
||||
body, err = json.MarshalIndent(parsed, "", " ")
|
||||
}
|
||||
|
||||
return summary, body, err
|
||||
}
|
||||
}
|
||||
|
||||
// panelSummary take panel info and returns entity summaries for the given panel and all its collapsed panels.
|
||||
func panelSummary(panel panelInfo, uid string, dashboardRefs ReferenceAccumulator) []*entity.EntitySummary {
|
||||
panels := []*entity.EntitySummary{}
|
||||
|
||||
panelRefs := NewReferenceAccumulator()
|
||||
p := &entity.EntitySummary{
|
||||
UID: uid + "#" + strconv.FormatInt(panel.ID, 10),
|
||||
@ -90,13 +107,11 @@ func NewStaticDashboardSummaryBuilder(lookup DatasourceLookup, sanitize bool) en
|
||||
dashboardRefs.Add(entity.ExternalEntityReferenceRuntime, entity.ExternalEntityReferenceRuntime_Transformer, v)
|
||||
}
|
||||
p.References = panelRefs.Get()
|
||||
summary.Nested = append(summary.Nested, p)
|
||||
}
|
||||
panels = append(panels, p)
|
||||
|
||||
summary.References = dashboardRefs.Get()
|
||||
if sanitize {
|
||||
body, err = json.MarshalIndent(parsed, "", " ")
|
||||
}
|
||||
return summary, body, err
|
||||
for _, c := range panel.Collapsed {
|
||||
collapsed := panelSummary(c, uid, dashboardRefs)
|
||||
panels = append(panels, collapsed...)
|
||||
}
|
||||
return panels
|
||||
}
|
||||
|
@ -45,6 +45,32 @@
|
||||
"type": "panel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UID": "with-library-panels#3",
|
||||
"kind": "panel",
|
||||
"name": "collapsed row",
|
||||
"fields": {
|
||||
"type": "row"
|
||||
}
|
||||
},
|
||||
{
|
||||
"UID": "with-library-panels#42",
|
||||
"kind": "panel",
|
||||
"name": "blue pie",
|
||||
"fields": {
|
||||
"type": ""
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"family": "librarypanel",
|
||||
"identifier": "l3d2s634-fdgf-75u4-3fg3-67j966ii7jur"
|
||||
},
|
||||
{
|
||||
"family": "plugin",
|
||||
"type": "panel"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
@ -59,6 +85,10 @@
|
||||
"family": "librarypanel",
|
||||
"identifier": "e1d5f519-dabd-47c6-9ad7-83d181ce1cee"
|
||||
},
|
||||
{
|
||||
"family": "librarypanel",
|
||||
"identifier": "l3d2s634-fdgf-75u4-3fg3-67j966ii7jur"
|
||||
},
|
||||
{
|
||||
"family": "plugin",
|
||||
"type": "panel"
|
||||
|
@ -49,6 +49,34 @@
|
||||
"uid": "e1d5f519-dabd-47c6-9ad7-83d181ce1cee"
|
||||
},
|
||||
"title": "green pie"
|
||||
},
|
||||
{
|
||||
"collapsed": true,
|
||||
"gridPos": {
|
||||
"h": 1,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 9
|
||||
},
|
||||
"id": 3,
|
||||
"panels": [
|
||||
{
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"id": 42,
|
||||
"libraryPanel": {
|
||||
"name": "blue pie",
|
||||
"uid": "l3d2s634-fdgf-75u4-3fg3-67j966ii7jur"
|
||||
},
|
||||
"title": "blue pie"
|
||||
}
|
||||
],
|
||||
"title": "collapsed row",
|
||||
"type": "row"
|
||||
}
|
||||
],
|
||||
"refresh": "",
|
||||
|
Loading…
Reference in New Issue
Block a user