models.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package dtos
  2. import (
  3. "crypto/md5"
  4. "fmt"
  5. "strings"
  6. "time"
  7. m "github.com/grafana/grafana/pkg/models"
  8. )
  9. type LoginCommand struct {
  10. User string `json:"user" binding:"Required"`
  11. Password string `json:"password" binding:"Required"`
  12. Remember bool `json:"remember"`
  13. }
  14. type CurrentUser struct {
  15. IsSignedIn bool `json:"isSignedIn"`
  16. Login string `json:"login"`
  17. Email string `json:"email"`
  18. Name string `json:"name"`
  19. LightTheme bool `json:"lightTheme"`
  20. OrgId int64 `json:"orgId"`
  21. OrgName string `json:"orgName"`
  22. OrgRole m.RoleType `json:"orgRole"`
  23. IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
  24. GravatarUrl string `json:"gravatarUrl"`
  25. }
  26. type DashboardMeta struct {
  27. IsStarred bool `json:"isStarred,omitempty"`
  28. IsHome bool `json:"isHome,omitempty"`
  29. IsSnapshot bool `json:"isSnapshot,omitempty"`
  30. Slug string `json:"slug"`
  31. Expires time.Time `json:"expires"`
  32. Created time.Time `json:"created"`
  33. }
  34. type DashboardFullWithMeta struct {
  35. Meta DashboardMeta `json:"meta"`
  36. Dashboard map[string]interface{} `json:"dashboard"`
  37. }
  38. type DataSource struct {
  39. Id int64 `json:"id"`
  40. OrgId int64 `json:"orgId"`
  41. Name string `json:"name"`
  42. Type string `json:"type"`
  43. Access m.DsAccess `json:"access"`
  44. Url string `json:"url"`
  45. Password string `json:"password"`
  46. User string `json:"user"`
  47. Database string `json:"database"`
  48. BasicAuth bool `json:"basicAuth"`
  49. BasicAuthUser string `json:"basicAuthUser"`
  50. BasicAuthPassword string `json:"basicAuthPassword"`
  51. IsDefault bool `json:"isDefault"`
  52. JsonData map[string]interface{} `json:"jsonData"`
  53. }
  54. type MetricQueryResultDto struct {
  55. Data []MetricQueryResultDataDto `json:"data"`
  56. }
  57. type MetricQueryResultDataDto struct {
  58. Target string `json:"target"`
  59. DataPoints [][2]float64 `json:"datapoints"`
  60. }
  61. type UserStars struct {
  62. DashboardIds map[string]bool `json:"dashboardIds"`
  63. }
  64. func GetGravatarUrl(text string) string {
  65. if text == "" {
  66. return ""
  67. }
  68. hasher := md5.New()
  69. hasher.Write([]byte(strings.ToLower(text)))
  70. return fmt.Sprintf("https://secure.gravatar.com/avatar/%x?s=90&default=mm", hasher.Sum(nil))
  71. }