mirror of https://github.com/statping/statping
upgrades
parent
68b42dcb8b
commit
f474d56ebe
|
@ -48,7 +48,9 @@ func Create(c *types.Communication) (int64, error) {
|
|||
return 0, err
|
||||
}
|
||||
c.Id = uuid.(int64)
|
||||
core.Communications = append(core.Communications, c)
|
||||
if core != nil {
|
||||
core.Communications = append(core.Communications, c)
|
||||
}
|
||||
return uuid.(int64), err
|
||||
}
|
||||
|
||||
|
|
7
core.go
7
core.go
|
@ -39,11 +39,12 @@ func (c Core) AllOnline() bool {
|
|||
}
|
||||
|
||||
func SelectCore() (*Core, error) {
|
||||
var core Core
|
||||
err := dbSession.Collection("core").Find().One(&core)
|
||||
var c *Core
|
||||
err := dbSession.Collection("core").Find().One(&c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
core = c
|
||||
store = sessions.NewCookieStore([]byte(core.ApiSecret))
|
||||
return &core, err
|
||||
return core, err
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
)
|
||||
|
||||
var httpFunctions template.FuncMap
|
||||
|
||||
func init() {
|
||||
|
||||
httpFunctions = template.FuncMap{
|
||||
"js": func(html string) template.JS {
|
||||
return template.JS(html)
|
||||
},
|
||||
"safe": func(html string) template.HTML {
|
||||
return template.HTML(html)
|
||||
},
|
||||
"VERSION": func() string {
|
||||
return VERSION
|
||||
},
|
||||
"underscore": func(html string) string {
|
||||
return UnderScoreString(html)
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func ExportIndexHTML() string {
|
||||
out := index{*core, services}
|
||||
nav, _ := tmplBox.String("nav.html")
|
||||
footer, _ := tmplBox.String("footer.html")
|
||||
render, err := tmplBox.String("index.html")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
t := template.New("message")
|
||||
t.Funcs(httpFunctions)
|
||||
t, _ = t.Parse(nav)
|
||||
t, _ = t.Parse(footer)
|
||||
t.Parse(render)
|
||||
|
||||
var tpl bytes.Buffer
|
||||
if err := t.Execute(&tpl, out); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
result := tpl.String()
|
||||
|
||||
fmt.Println(result)
|
||||
return result
|
||||
}
|
|
@ -220,7 +220,7 @@ func TestService_Hits(t *testing.T) {
|
|||
assert.NotNil(t, service)
|
||||
hits, err := service.Hits()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 26, len(hits))
|
||||
assert.Equal(t, 23, len(hits))
|
||||
}
|
||||
|
||||
func TestService_LimitedHits(t *testing.T) {
|
||||
|
@ -228,7 +228,7 @@ func TestService_LimitedHits(t *testing.T) {
|
|||
assert.NotNil(t, service)
|
||||
hits, err := service.LimitedHits()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 26, len(hits))
|
||||
assert.Equal(t, 23, len(hits))
|
||||
}
|
||||
|
||||
func Test(t *testing.T) {
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE users (
|
|||
email text,
|
||||
api_key VARCHAR(50),
|
||||
api_secret VARCHAR(50),
|
||||
admin bool,
|
||||
administrator BOOL NOT NULL DEFAULT '0',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX (id)
|
||||
);
|
||||
|
@ -72,8 +72,8 @@ CREATE TABLE communication (
|
|||
var2 text,
|
||||
api_key text,
|
||||
api_secret text,
|
||||
enabled boolean,
|
||||
removable boolean,
|
||||
enabled BOOL NOT NULL DEFAULT '0',
|
||||
removable BOOL NOT NULL DEFAULT '0',
|
||||
limits integer,
|
||||
created_at TIMESTAMP
|
||||
);
|
|
@ -17,7 +17,7 @@ CREATE TABLE users (
|
|||
email text,
|
||||
api_key text,
|
||||
api_secret text,
|
||||
admin bool,
|
||||
administrator bool,
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE users (
|
|||
email text,
|
||||
api_key text,
|
||||
api_secret text,
|
||||
admin bool,
|
||||
administrator bool,
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
|
||||
|
|
2
users.go
2
users.go
|
@ -12,7 +12,7 @@ type User struct {
|
|||
Email string `db:"email" json:"-"`
|
||||
ApiKey string `db:"api_key" json:"api_key"`
|
||||
ApiSecret string `db:"api_secret" json:"-"`
|
||||
Admin bool `db:"admin" json:"admin"`
|
||||
Admin bool `db:"administrator" json:"admin"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue