Commit 1abdd170 by Torkel Ödegaard

ux(): fixes to cards and sorting plugin list, #4364

parent dddd155a
...@@ -26,6 +26,20 @@ type PluginListItem struct { ...@@ -26,6 +26,20 @@ type PluginListItem struct {
Info *plugins.PluginInfo `json:"info"` 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 { type ImportDashboardCommand struct {
PluginId string `json:"pluginId"` PluginId string `json:"pluginId"`
Path string `json:"path"` Path string `json:"path"`
......
package api package api
import ( import (
"sort"
"github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
...@@ -19,7 +21,7 @@ func GetPluginList(c *middleware.Context) Response { ...@@ -19,7 +21,7 @@ func GetPluginList(c *middleware.Context) Response {
return ApiError(500, "Failed to get list of plugins", err) 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 { for _, pluginDef := range plugins.Plugins {
// filter out app sub plugins // filter out app sub plugins
if embeddedFilter == "0" && pluginDef.IncludedInAppId != "" { if embeddedFilter == "0" && pluginDef.IncludedInAppId != "" {
...@@ -31,7 +33,7 @@ func GetPluginList(c *middleware.Context) Response { ...@@ -31,7 +33,7 @@ func GetPluginList(c *middleware.Context) Response {
continue continue
} }
listItem := &dtos.PluginListItem{ listItem := dtos.PluginListItem{
Id: pluginDef.Id, Id: pluginDef.Id,
Name: pluginDef.Name, Name: pluginDef.Name,
Type: pluginDef.Type, Type: pluginDef.Type,
...@@ -58,6 +60,7 @@ func GetPluginList(c *middleware.Context) Response { ...@@ -58,6 +60,7 @@ func GetPluginList(c *middleware.Context) Response {
result = append(result, listItem) result = append(result, listItem)
} }
sort.Sort(result)
return Json(200, result) return Json(200, result)
} }
......
...@@ -76,6 +76,8 @@ ...@@ -76,6 +76,8 @@
.card-item-figure { .card-item-figure {
margin: 0 $spacer $spacer 0; margin: 0 $spacer $spacer 0;
height: 6rem;
img { img {
width: 6rem; width: 6rem;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment