diff --git a/hits.go b/hits.go index fdef97b1..e4e6535e 100644 --- a/hits.go +++ b/hits.go @@ -11,7 +11,7 @@ type Hit struct { func SelectAllHits(id int64) []Hit { var tks []Hit - rows, err := db.Query("SELECT * FROM hits WHERE service=$1 ORDER BY id ASC", id) + rows, err := db.Query("SELECT * FROM hits WHERE service=$1 ORDER BY id DESC LIMIT 256", id) if err != nil { panic(err) } diff --git a/html/css/base.css b/html/css/base.css index 9e045f0d..08251b15 100644 --- a/html/css/base.css +++ b/html/css/base.css @@ -25,4 +25,8 @@ HTML,BODY { .stats_area { text-align: center; +} + +.offline_bg { + background-color: #c5c5c578 !important; } \ No newline at end of file diff --git a/html/tmpl/index.html b/html/tmpl/index.html index 1a8e6dd8..2e578c05 100644 --- a/html/tmpl/index.html +++ b/html/tmpl/index.html @@ -12,6 +12,7 @@ +

{{.Project}}

@@ -19,13 +20,11 @@ {{ range .Services }}
-
+

{{ .Name }} {{if .Online}} ONLINE {{ else }} OFFLINE {{end}}

- {{.Online}} -
{{.Online24Hours}}% Online last 24 Hours @@ -90,11 +89,17 @@ var chartdata = new Chart(ctx, { yAxes: [{ ticks: { beginAtZero: true + }, + gridLines: { + display:false } }], xAxes: [{ type: 'time', - distribution: 'series' + distribution: 'series', + gridLines: { + display:false + } }] }, elements: { diff --git a/services.go b/services.go index 7dc06dc0..c618de9f 100644 --- a/services.go +++ b/services.go @@ -9,7 +9,7 @@ import ( ) var ( - services []Service + services []*Service ) type Service struct { @@ -45,8 +45,8 @@ func SelectService(id string) Service { return tk } -func SelectAllServices() []Service { - var tks []Service +func SelectAllServices() []*Service { + var tks []*Service rows, err := db.Query("SELECT * FROM services ORDER BY id ASC") if err != nil { panic(err) @@ -58,7 +58,7 @@ func SelectAllServices() []Service { panic(err) } tk.FormatData() - tks = append(tks, tk) + tks = append(tks, &tk) } return tks } @@ -130,6 +130,7 @@ func (u *Service) Create() int { if err != nil { panic(err) } + services = SelectAllServices() return lastInsertId } diff --git a/web.go b/web.go index 9ce5fe22..715c35a5 100644 --- a/web.go +++ b/web.go @@ -8,7 +8,7 @@ import ( ) type dashboard struct { - Services []Service + Services []*Service Users []User Core *Core } @@ -125,7 +125,8 @@ func SetupHandler(w http.ResponseWriter, r *http.Request) { } type index struct { - Services []Service + Project string + Services []*Service } func IndexHandler(w http.ResponseWriter, r *http.Request) { @@ -144,7 +145,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { return template.JS(html) }, }).Parse(indexFile) - out := index{services} + out := index{core.Name, services} indexTmpl.Execute(w, out) } @@ -169,7 +170,7 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) { if err != nil { panic(err) } - out := dashboard{SelectAllServices(), SelectAllUsers(), core} + out := dashboard{services, SelectAllUsers(), core} dashboardTmpl.Execute(w, out) } @@ -189,7 +190,7 @@ func ServicesHandler(w http.ResponseWriter, r *http.Request) { if err != nil { panic(err) } - tokensTmpl.Execute(w, SelectAllServices()) + tokensTmpl.Execute(w, services) } func UsersHandler(w http.ResponseWriter, r *http.Request) {