Merge branch 'master' into websocket
Conflicts: public/app/core/core.ts
This commit is contained in:
+16
-3
@@ -1,8 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
//"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
@@ -17,9 +20,10 @@ func GetDataSources(c *middleware.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
result := make([]*dtos.DataSource, len(query.Result))
|
||||
for i, ds := range query.Result {
|
||||
result[i] = &dtos.DataSource{
|
||||
result := make(dtos.DataSourceList, 0)
|
||||
for _, ds := range query.Result {
|
||||
|
||||
dsItem := dtos.DataSource{
|
||||
Id: ds.Id,
|
||||
OrgId: ds.OrgId,
|
||||
Name: ds.Name,
|
||||
@@ -32,8 +36,17 @@ func GetDataSources(c *middleware.Context) {
|
||||
BasicAuth: ds.BasicAuth,
|
||||
IsDefault: ds.IsDefault,
|
||||
}
|
||||
|
||||
if plugin, exists := plugins.DataSources[ds.Type]; exists {
|
||||
dsItem.TypeLogoUrl = plugin.Info.Logos.Small
|
||||
} else {
|
||||
dsItem.TypeLogoUrl = "public/img/plugin-default-logo_dark.svg"
|
||||
}
|
||||
|
||||
result = append(result, dsItem)
|
||||
}
|
||||
|
||||
sort.Sort(result)
|
||||
c.JSON(200, result)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ type DataSource struct {
|
||||
OrgId int64 `json:"orgId"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
TypeLogoUrl string `json:"typeLogoUrl"`
|
||||
Access m.DsAccess `json:"access"`
|
||||
Url string `json:"url"`
|
||||
Password string `json:"password"`
|
||||
@@ -75,6 +76,20 @@ type DataSource struct {
|
||||
JsonData *simplejson.Json `json:"jsonData,omitempty"`
|
||||
}
|
||||
|
||||
type DataSourceList []DataSource
|
||||
|
||||
func (slice DataSourceList) Len() int {
|
||||
return len(slice)
|
||||
}
|
||||
|
||||
func (slice DataSourceList) Less(i, j int) bool {
|
||||
return slice[i].Name < slice[j].Name
|
||||
}
|
||||
|
||||
func (slice DataSourceList) Swap(i, j int) {
|
||||
slice[i], slice[j] = slice[j], slice[i]
|
||||
}
|
||||
|
||||
type MetricQueryResultDto struct {
|
||||
Data []MetricQueryResultDataDto `json:"data"`
|
||||
}
|
||||
|
||||
@@ -26,6 +26,20 @@ type PluginListItem struct {
|
||||
Info *plugins.PluginInfo `json:"info"`
|
||||
}
|
||||
|
||||
type PluginList []PluginListItem
|
||||
|
||||
func (slice PluginList) Len() int {
|
||||
return len(slice)
|
||||
}
|
||||
|
||||
func (slice PluginList) Less(i, j int) bool {
|
||||
return slice[i].Name < slice[j].Name
|
||||
}
|
||||
|
||||
func (slice PluginList) Swap(i, j int) {
|
||||
slice[i], slice[j] = slice[j], slice[i]
|
||||
}
|
||||
|
||||
type ImportDashboardCommand struct {
|
||||
PluginId string `json:"pluginId"`
|
||||
Path string `json:"path"`
|
||||
|
||||
+5
-2
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
@@ -19,7 +21,7 @@ func GetPluginList(c *middleware.Context) Response {
|
||||
return ApiError(500, "Failed to get list of plugins", err)
|
||||
}
|
||||
|
||||
result := make([]*dtos.PluginListItem, 0)
|
||||
result := make(dtos.PluginList, 0)
|
||||
for _, pluginDef := range plugins.Plugins {
|
||||
// filter out app sub plugins
|
||||
if embeddedFilter == "0" && pluginDef.IncludedInAppId != "" {
|
||||
@@ -31,7 +33,7 @@ func GetPluginList(c *middleware.Context) Response {
|
||||
continue
|
||||
}
|
||||
|
||||
listItem := &dtos.PluginListItem{
|
||||
listItem := dtos.PluginListItem{
|
||||
Id: pluginDef.Id,
|
||||
Name: pluginDef.Name,
|
||||
Type: pluginDef.Type,
|
||||
@@ -58,6 +60,7 @@ func GetPluginList(c *middleware.Context) Response {
|
||||
result = append(result, listItem)
|
||||
}
|
||||
|
||||
sort.Sort(result)
|
||||
return Json(200, result)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user