rename backend to pkg

This commit is contained in:
Torkel Ödegaard
2014-08-12 20:45:41 +02:00
parent e7ce371ee8
commit 9e30599f1f
16 changed files with 10 additions and 10 deletions

53
pkg/models/dashboards.go Normal file
View File

@@ -0,0 +1,53 @@
package models
import (
"encoding/json"
"io"
)
type Dashboard struct {
Data map[string]interface{}
}
type SearchResult struct {
Type string `json:"title"`
Id string `json:"id"`
Title string `json:"title"`
}
func NewDashboard(title string) *Dashboard {
dash := &Dashboard{}
dash.Data = make(map[string]interface{})
dash.Data["title"] = title
return dash
}
func NewFromJson(reader io.Reader) (*Dashboard, error) {
dash := NewDashboard("temp")
jsonParser := json.NewDecoder(reader)
if err := jsonParser.Decode(&dash.Data); err != nil {
return nil, err
}
return dash, nil
}
/*type DashboardServices struct {
}
type DashboardServicesFilter struct {
}
type DashboardServicesFilterTime struct {
From string To string
}*/
func (dash *Dashboard) GetString(prop string) string {
return dash.Data[prop].(string)
}
func (dash *Dashboard) Title() string {
return dash.GetString("title")
}