grafana/pkg/api/dtos/models.go

95 lines
3.0 KiB
Go
Raw Normal View History

package dtos
2014-10-06 03:13:01 +08:00
import (
"crypto/md5"
"fmt"
"strings"
"time"
2014-10-06 03:13:01 +08:00
2015-02-05 17:37:13 +08:00
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
2014-10-06 03:13:01 +08:00
)
2015-01-21 16:52:40 +08:00
type LoginCommand struct {
User string `json:"user" binding:"Required"`
Password string `json:"password" binding:"Required"`
Remember bool `json:"remember"`
2014-10-06 03:13:01 +08:00
}
type CurrentUser struct {
IsSignedIn bool `json:"isSignedIn"`
Id int64 `json:"id"`
Login string `json:"login"`
Email string `json:"email"`
Name string `json:"name"`
LightTheme bool `json:"lightTheme"`
OrgId int64 `json:"orgId"`
OrgName string `json:"orgName"`
OrgRole m.RoleType `json:"orgRole"`
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
GravatarUrl string `json:"gravatarUrl"`
2014-10-06 03:13:01 +08:00
}
type DashboardMeta struct {
IsStarred bool `json:"isStarred,omitempty"`
IsHome bool `json:"isHome,omitempty"`
IsSnapshot bool `json:"isSnapshot,omitempty"`
Type string `json:"type,omitempty"`
CanSave bool `json:"canSave"`
CanEdit bool `json:"canEdit"`
CanStar bool `json:"canStar"`
Slug string `json:"slug"`
Expires time.Time `json:"expires"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
UpdatedBy string `json:"updatedBy"`
CreatedBy string `json:"createdBy"`
Version int `json:"version"`
}
type DashboardFullWithMeta struct {
Meta DashboardMeta `json:"meta"`
Dashboard map[string]interface{} `json:"dashboard"`
}
type DataSource struct {
Id int64 `json:"id"`
OrgId int64 `json:"orgId"`
Name string `json:"name"`
Type string `json:"type"`
Access m.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"`
2015-12-18 16:20:23 +08:00
WithCredentials bool `json:"withCredentials"`
IsDefault bool `json:"isDefault"`
JsonData map[string]interface{} `json:"jsonData,omitempty"`
}
type MetricQueryResultDto struct {
Data []MetricQueryResultDataDto `json:"data"`
}
type MetricQueryResultDataDto struct {
Target string `json:"target"`
DataPoints [][2]float64 `json:"datapoints"`
}
2015-02-03 00:17:57 +08:00
type UserStars struct {
DashboardIds map[string]bool `json:"dashboardIds"`
}
func GetGravatarUrl(text string) string {
if text == "" {
return ""
2014-10-06 03:13:01 +08:00
}
hasher := md5.New()
hasher.Write([]byte(strings.ToLower(text)))
return fmt.Sprintf(setting.AppSubUrl+"/avatar/%x", hasher.Sum(nil))
2014-10-06 03:13:01 +08:00
}