2014-11-21 23:43:04 +08:00
|
|
|
package dtos
|
2014-10-06 03:13:01 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2015-03-29 00:53:52 +08:00
|
|
|
"time"
|
2014-10-06 03:13:01 +08:00
|
|
|
|
2015-02-05 17:37:13 +08:00
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
2016-02-21 06:51:22 +08:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2014-11-21 23:43:04 +08:00
|
|
|
type CurrentUser struct {
|
2015-01-28 18:33:50 +08:00
|
|
|
IsSignedIn bool `json:"isSignedIn"`
|
2015-08-21 15:30:39 +08:00
|
|
|
Id int64 `json:"id"`
|
2015-01-28 18:33:50 +08:00
|
|
|
Login string `json:"login"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Name string `json:"name"`
|
2015-02-28 21:30:08 +08:00
|
|
|
LightTheme bool `json:"lightTheme"`
|
2015-04-29 15:26:12 +08:00
|
|
|
OrgId int64 `json:"orgId"`
|
2015-02-24 03:07:49 +08:00
|
|
|
OrgName string `json:"orgName"`
|
2015-04-29 15:26:12 +08:00
|
|
|
OrgRole m.RoleType `json:"orgRole"`
|
2015-01-28 18:33:50 +08:00
|
|
|
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
|
|
|
|
GravatarUrl string `json:"gravatarUrl"`
|
2014-10-06 03:13:01 +08:00
|
|
|
}
|
|
|
|
|
2015-02-02 18:32:32 +08:00
|
|
|
type DashboardMeta struct {
|
2016-02-02 15:26:11 +08:00
|
|
|
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"`
|
2015-02-02 18:32:32 +08:00
|
|
|
}
|
|
|
|
|
2015-05-04 14:36:44 +08:00
|
|
|
type DashboardFullWithMeta struct {
|
|
|
|
Meta DashboardMeta `json:"meta"`
|
|
|
|
Dashboard map[string]interface{} `json:"dashboard"`
|
2015-01-29 19:10:34 +08:00
|
|
|
}
|
|
|
|
|
2014-12-17 10:09:54 +08:00
|
|
|
type DataSource struct {
|
2015-03-02 16:58:35 +08:00
|
|
|
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"`
|
2015-03-02 16:58:35 +08:00
|
|
|
IsDefault bool `json:"isDefault"`
|
2016-01-15 22:56:54 +08:00
|
|
|
JsonData map[string]interface{} `json:"jsonData,omitempty"`
|
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-02-03 00:17:57 +08:00
|
|
|
type UserStars struct {
|
|
|
|
DashboardIds map[string]bool `json:"dashboardIds"`
|
|
|
|
}
|
|
|
|
|
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)))
|
2016-02-21 06:51:22 +08:00
|
|
|
return fmt.Sprintf(setting.AppSubUrl+"/avatar/%x", hasher.Sum(nil))
|
2014-10-06 03:13:01 +08:00
|
|
|
}
|