mirror of https://github.com/statping/statping
changes
parent
6441b325ff
commit
8f9e96c365
2
hits.go
2
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)
|
||||
}
|
||||
|
|
|
@ -26,3 +26,7 @@ HTML,BODY {
|
|||
.stats_area {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.offline_bg {
|
||||
background-color: #c5c5c578 !important;
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<h1 class="text-center">{{.Project}}</h1>
|
||||
|
||||
<div class="container">
|
||||
|
||||
|
@ -19,13 +20,11 @@
|
|||
{{ range .Services }}
|
||||
<div class="col-12 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-body{{if .Online}}{{else}} offline_bg{{end}}">
|
||||
<h3>{{ .Name }} <span class="badge badge-secondary float-right">{{if .Online}} ONLINE {{ else }} OFFLINE {{end}}</span></h3>
|
||||
|
||||
<div class="row stats_area mt-3 mb-3">
|
||||
|
||||
{{.Online}}
|
||||
|
||||
<div class="col-4">
|
||||
<span class="lg_number">{{.Online24Hours}}%</span>
|
||||
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: {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
11
web.go
11
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) {
|
||||
|
|
Loading…
Reference in New Issue