mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
c7cabdfd6f
* AccessControl: Provide scope to frontend * Covering datasources with accesscontrol metadata * Write benchmark tests for GetResourcesMetadata * Add accesscontrol util and interface * Add the hasPermissionInMetadata function in the frontend access control code * Use IsDisabled rather that performing a feature toggle check Co-authored-by: Karl Persson <kalle.persson@grafana.com>
67 lines
2.6 KiB
Go
67 lines
2.6 KiB
Go
package dtos
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
)
|
|
|
|
type DataSource struct {
|
|
Id int64 `json:"id"`
|
|
UID string `json:"uid"`
|
|
OrgId int64 `json:"orgId"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
TypeLogoUrl string `json:"typeLogoUrl"`
|
|
Access models.DsAccess `json:"access"`
|
|
Url string `json:"url"`
|
|
Password string `json:"password"`
|
|
User string `json:"user"`
|
|
Database string `json:"database"`
|
|
BasicAuth bool `json:"basicAuth"`
|
|
BasicAuthUser string `json:"basicAuthUser"`
|
|
BasicAuthPassword string `json:"basicAuthPassword"`
|
|
WithCredentials bool `json:"withCredentials"`
|
|
IsDefault bool `json:"isDefault"`
|
|
JsonData *simplejson.Json `json:"jsonData,omitempty"`
|
|
SecureJsonFields map[string]bool `json:"secureJsonFields"`
|
|
Version int `json:"version"`
|
|
ReadOnly bool `json:"readOnly"`
|
|
AccessControl accesscontrol.Metadata `json:"accessControl,omitempty"`
|
|
}
|
|
|
|
type DataSourceListItemDTO struct {
|
|
Id int64 `json:"id"`
|
|
UID string `json:"uid"`
|
|
OrgId int64 `json:"orgId"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
TypeName string `json:"typeName"`
|
|
TypeLogoUrl string `json:"typeLogoUrl"`
|
|
Access models.DsAccess `json:"access"`
|
|
Url string `json:"url"`
|
|
Password string `json:"password"`
|
|
User string `json:"user"`
|
|
Database string `json:"database"`
|
|
BasicAuth bool `json:"basicAuth"`
|
|
IsDefault bool `json:"isDefault"`
|
|
JsonData *simplejson.Json `json:"jsonData,omitempty"`
|
|
ReadOnly bool `json:"readOnly"`
|
|
}
|
|
|
|
type DataSourceList []DataSourceListItemDTO
|
|
|
|
func (slice DataSourceList) Len() int {
|
|
return len(slice)
|
|
}
|
|
|
|
func (slice DataSourceList) Less(i, j int) bool {
|
|
return strings.ToLower(slice[i].Name) < strings.ToLower(slice[j].Name)
|
|
}
|
|
|
|
func (slice DataSourceList) Swap(i, j int) {
|
|
slice[i], slice[j] = slice[j], slice[i]
|
|
}
|