2014-11-21 09:43:04 -06:00
|
|
|
package dtos
|
2014-10-05 14:13:01 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2015-01-16 07:32:18 -06:00
|
|
|
m "github.com/torkelo/grafana-pro/pkg/models"
|
2014-10-05 14:13:01 -05:00
|
|
|
)
|
|
|
|
|
2015-01-21 02:52:40 -06:00
|
|
|
type LoginCommand struct {
|
|
|
|
User string `json:"user" binding:"Required"`
|
|
|
|
Password string `json:"password" binding:"Required"`
|
|
|
|
Remember bool `json:"remember"`
|
2014-10-05 14:13:01 -05:00
|
|
|
}
|
|
|
|
|
2014-11-21 09:43:04 -06:00
|
|
|
type CurrentUser struct {
|
2015-01-28 04:33:50 -06: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-05 14:13:01 -05:00
|
|
|
}
|
|
|
|
|
2015-02-02 04:32:32 -06:00
|
|
|
type DashboardMeta struct {
|
|
|
|
IsStarred bool `json:"isStarred"`
|
2015-02-03 08:04:35 -06:00
|
|
|
IsHome bool `json:"isHome"`
|
2015-02-02 04:32:32 -06:00
|
|
|
}
|
|
|
|
|
2015-01-29 05:10:34 -06:00
|
|
|
type Dashboard struct {
|
2015-02-02 04:32:32 -06:00
|
|
|
Meta DashboardMeta `json:"meta"`
|
|
|
|
Model map[string]interface{} `json:"model"`
|
2015-01-29 05:10:34 -06:00
|
|
|
}
|
|
|
|
|
2014-12-16 20:09:54 -06:00
|
|
|
type DataSource struct {
|
2015-01-16 07:32:18 -06: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-16 20:09:54 -06:00
|
|
|
}
|
|
|
|
|
2015-01-06 02:11:00 -06:00
|
|
|
type MetricQueryResultDto struct {
|
|
|
|
Data []MetricQueryResultDataDto `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MetricQueryResultDataDto struct {
|
|
|
|
Target string `json:"target"`
|
|
|
|
DataPoints [][2]float64 `json:"datapoints"`
|
|
|
|
}
|
|
|
|
|
2015-02-02 10:17:57 -06:00
|
|
|
type UserStars struct {
|
|
|
|
DashboardIds map[string]bool `json:"dashboardIds"`
|
|
|
|
}
|
|
|
|
|
2015-01-16 07:32:18 -06:00
|
|
|
func GetGravatarUrl(text string) string {
|
|
|
|
if text == "" {
|
|
|
|
return ""
|
2014-10-05 14:13:01 -05: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))
|
|
|
|
}
|