mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
3d51ca7377
commit
05dda7f0a1
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -173,6 +174,23 @@ func (s *StandardSearchService) doSearchQuery(ctx context.Context, qry Query, _
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame := newSearchFrame(res)
|
||||||
|
for _, r := range res.Items {
|
||||||
|
doc, err := getDoc(r.Value)
|
||||||
|
if err != nil {
|
||||||
|
s.logger.Error("Failed to parse doc", "error", err)
|
||||||
|
response.Error = err
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
kind := strings.ToLower(doc.Kind)
|
||||||
|
link := dashboardPageItemLink(doc, s.cfg.AppSubURL)
|
||||||
|
frame.AppendRow(kind, doc.UID, doc.Spec.Title, link, nil, doc.FolderID)
|
||||||
|
}
|
||||||
|
response.Frames = append(response.Frames, frame)
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSearchFrame(res *resource.SearchResponse) *data.Frame {
|
||||||
fScore := data.NewFieldFromFieldType(data.FieldTypeFloat64, 0)
|
fScore := data.NewFieldFromFieldType(data.FieldTypeFloat64, 0)
|
||||||
fUID := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
fUID := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
||||||
fKind := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
fKind := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
||||||
@ -202,19 +220,14 @@ func (s *StandardSearchService) doSearchQuery(ctx context.Context, qry Query, _
|
|||||||
Count: uint64(len(res.Items)),
|
Count: uint64(len(res.Items)),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
return frame
|
||||||
|
}
|
||||||
|
|
||||||
for _, r := range res.Items {
|
func dashboardPageItemLink(doc *DashboardListDoc, subURL string) string {
|
||||||
doc, err := getDoc(r.Value)
|
if doc.FolderID == "" {
|
||||||
if err != nil {
|
return fmt.Sprintf("%s/d/%s/%s", subURL, doc.Name, doc.Namespace)
|
||||||
s.logger.Error("Failed to parse doc", "error", err)
|
|
||||||
response.Error = err
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
kind := strings.ToLower(doc.Kind)
|
|
||||||
frame.AppendRow(kind, doc.UID, doc.Spec.Title, "", nil, doc.FolderID)
|
|
||||||
}
|
}
|
||||||
response.Frames = append(response.Frames, frame)
|
return fmt.Sprintf("%s/dashboards/f/%s/%s", subURL, doc.Name, doc.Namespace)
|
||||||
return response
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type customMeta struct {
|
type customMeta struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user