The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/api/api_models.go

52 lines
1.1 KiB

package api
import (
"crypto/md5"
"fmt"
"strings"
"github.com/torkelo/grafana-pro/pkg/models"
)
type saveDashboardCommand struct {
Id string `json:"id"`
Title string `json:"title"`
Dashboard map[string]interface{}
}
type errorResponse struct {
Message string `json:"message"`
}
type IndexDto struct {
User CurrentUserDto
}
type CurrentUserDto struct {
Login string `json:"login"`
Email string `json:"email"`
GravatarUrl string `json:"gravatarUrl"`
}
type LoginResultDto struct {
Status string `json:"status"`
User CurrentUserDto `json:"user"`
}
func newErrorResponse(message string) *errorResponse {
return &errorResponse{Message: message}
}
func initCurrentUserDto(userDto *CurrentUserDto, account *models.Account) {
if account != nil {
userDto.Login = account.Login
userDto.Email = account.Email
userDto.GravatarUrl = getGravatarUrl(account.Email)
}
}
func getGravatarUrl(text string) string {
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))
}