2014-11-21 23:43:04 +08:00
|
|
|
package dtos
|
2014-10-06 03:13:01 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2015-01-16 21:32:18 +08:00
|
|
|
m "github.com/torkelo/grafana-pro/pkg/models"
|
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
|
|
|
}
|
|
|
|
|
2014-11-21 23:43:04 +08:00
|
|
|
type CurrentUser struct {
|
2015-01-28 18:33:50 +08:00
|
|
|
IsSignedIn bool `json:"isSignedIn"`
|
|
|
|
Login string `json:"login"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
AccountRole m.RoleType `json:"accountRole"`
|
|
|
|
AccountName string `json:"acountName"`
|
|
|
|
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
|
|
|
|
GravatarUrl string `json:"gravatarUrl"`
|
2014-10-06 03:13:01 +08:00
|
|
|
}
|
|
|
|
|
2014-12-17 10:09:54 +08:00
|
|
|
type DataSource struct {
|
2015-01-16 21:32:18 +08:00
|
|
|
Id int64 `json:"id"`
|
|
|
|
AccountId int64 `json:"accountId"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Type m.DsType `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"`
|
|
|
|
IsDefault bool `json:"isDefault"`
|
2014-12-17 10:09:54 +08:00
|
|
|
}
|
|
|
|
|
2015-01-06 16:11:00 +08:00
|
|
|
type MetricQueryResultDto struct {
|
|
|
|
Data []MetricQueryResultDataDto `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MetricQueryResultDataDto struct {
|
|
|
|
Target string `json:"target"`
|
|
|
|
DataPoints [][2]float64 `json:"datapoints"`
|
|
|
|
}
|
|
|
|
|
2015-01-16 21:32:18 +08:00
|
|
|
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("https://secure.gravatar.com/avatar/%x?s=90&default=mm", hasher.Sum(nil))
|
|
|
|
}
|