Commit e4c0c39f by Torkel Ödegaard

ux(): began work on updating data source list to cards view

parent 1abdd170
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/plugins"
//"github.com/grafana/grafana/pkg/log" //"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
m "github.com/grafana/grafana/pkg/models" m "github.com/grafana/grafana/pkg/models"
...@@ -17,9 +20,10 @@ func GetDataSources(c *middleware.Context) { ...@@ -17,9 +20,10 @@ func GetDataSources(c *middleware.Context) {
return return
} }
result := make([]*dtos.DataSource, len(query.Result)) result := make(dtos.DataSourceList, 0)
for i, ds := range query.Result { for _, ds := range query.Result {
result[i] = &dtos.DataSource{
dsItem := dtos.DataSource{
Id: ds.Id, Id: ds.Id,
OrgId: ds.OrgId, OrgId: ds.OrgId,
Name: ds.Name, Name: ds.Name,
...@@ -32,8 +36,17 @@ func GetDataSources(c *middleware.Context) { ...@@ -32,8 +36,17 @@ func GetDataSources(c *middleware.Context) {
BasicAuth: ds.BasicAuth, BasicAuth: ds.BasicAuth,
IsDefault: ds.IsDefault, 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) c.JSON(200, result)
} }
......
...@@ -62,6 +62,7 @@ type DataSource struct { ...@@ -62,6 +62,7 @@ type DataSource struct {
OrgId int64 `json:"orgId"` OrgId int64 `json:"orgId"`
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
TypeLogoUrl string `json:"typeLogoUrl"`
Access m.DsAccess `json:"access"` Access m.DsAccess `json:"access"`
Url string `json:"url"` Url string `json:"url"`
Password string `json:"password"` Password string `json:"password"`
...@@ -75,6 +76,20 @@ type DataSource struct { ...@@ -75,6 +76,20 @@ type DataSource struct {
JsonData *simplejson.Json `json:"jsonData,omitempty"` 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 { type MetricQueryResultDto struct {
Data []MetricQueryResultDataDto `json:"data"` Data []MetricQueryResultDataDto `json:"data"`
} }
......
...@@ -13,7 +13,31 @@ ...@@ -13,7 +13,31 @@
</a> </a>
</div> </div>
<br> <section class="card-section" layout-mode>
<layout-selector></layout-selector>
<ol class="card-list" >
<li class="card-item-wrapper" ng-repeat="ds in ctrl.datasources">
<div class="card-item" >
<div class="card-item-header">
<i class="icon-gf icon-gf-{{ds.type}}"></i>
{{ds.type}}
</div>
<div class="card-item-body">
<a href="datasources/edit/{{ds.id}}">
<figure class="card-item-figure">
<img ng-src="{{ds.typeLogoUrl}}">
</figure>
</a>
<div class="card-item-details">
<a class="card-item-name" href="datasources/edit/{{ds.id}}/">{{ds.name}}</a>
<div class="card-item-sub-name">{{ds.url}}</div>
</div>
</div>
</div>
</li>
</ol>
</section>
<div ng-if="ctrl.datasources.length === 0"> <div ng-if="ctrl.datasources.length === 0">
<em>No data sources defined</em> <em>No data sources defined</em>
...@@ -63,5 +87,5 @@ ...@@ -63,5 +87,5 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<img ng-src="{{plugin.info.logos.small}}"> <img ng-src="{{plugin.info.logos.small}}">
</figure> </figure>
<div class="card-item-details"> <div class="card-item-details">
<div class="card-item-name" href="plugins/{{plugin.id}}/edit">{{plugin.name}}</div> <div class="card-item-name">{{plugin.name}}</div>
<div class="card-item-sub-name">By {{plugin.info.author.name}}</div> <div class="card-item-sub-name">By {{plugin.info.author.name}}</div>
</div> </div>
</div> </div>
......
...@@ -56,7 +56,10 @@ ...@@ -56,7 +56,10 @@
.card-item-header { .card-item-header {
color: $text-color-weak; color: $text-color-weak;
text-transform: uppercase;
margin-bottom: $spacer; margin-bottom: $spacer;
font-size: $font-size-sm;
font-weight: bold;
} }
.card-item-name { .card-item-name {
......
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