From 09bc158e5e5919ad82ead8d26e8f66025779879d Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sun, 10 Jun 2018 17:20:42 -0700 Subject: [PATCH] changes n upgrades --- failures.go | 29 ++++++++++++++++++------- html/css/base.css | 46 +++++++++++++++++++++++++++++++++++++++- html/tmpl/dashboard.html | 12 +++++------ html/tmpl/index.html | 30 ++++++++++++++++++++------ html/tmpl/services.html | 19 ++++++++++------- main_test.go | 4 ++-- services.go | 42 +++++++++++++++++++++++++++--------- web.go | 16 ++++++++------ 8 files changed, 150 insertions(+), 48 deletions(-) diff --git a/failures.go b/failures.go index 78abd0b3..8261a1e5 100644 --- a/failures.go +++ b/failures.go @@ -1,31 +1,44 @@ package main -import "time" +import ( + "github.com/ararog/timeago" + "time" +) type Failure struct { Id int Issue string Service int CreatedAt time.Time + Ago string } -func SelectAllFailures(id int64) []float64 { - var tks []float64 - rows, err := db.Query("SELECT * FROM failures WHERE service=$1 ORDER BY id ASC", id) +func (s *Service) SelectAllFailures() []*Failure { + var tks []*Failure + rows, err := db.Query("SELECT * FROM failures WHERE service=$1 ORDER BY id DESC LIMIT 10", s.Id) if err != nil { panic(err) } for rows.Next() { - var tk Hit - err = rows.Scan(&tk.Id, &tk.Metric, &tk.Value, &tk.CreatedAt) + var tk Failure + err = rows.Scan(&tk.Id, &tk.Issue, &tk.Service, &tk.CreatedAt) if err != nil { panic(err) } - tks = append(tks, tk.Value) + + tk.Ago, _ = timeago.TimeAgoWithTime(time.Now(), tk.CreatedAt) + + tks = append(tks, &tk) } return tks } +func CountFailures() int { + var amount int + db.QueryRow("SELECT COUNT(id) FROM failures;").Scan(&amount) + return amount +} + func (s *Service) TotalFailures() int { var amount int db.QueryRow("SELECT COUNT(id) FROM failures WHERE service=$1;", s.Id).Scan(&amount) @@ -36,6 +49,6 @@ func (s *Service) TotalFailures24Hours() int { var amount int t := time.Now() x := t.AddDate(0, 0, -1) - db.QueryRow("SELECT COUNT(id) FROM failures WHERE service=$1 AND created_at>=$2 AND created_at<$3;", s.Id, t, x).Scan(&amount) + db.QueryRow("SELECT COUNT(id) FROM failures WHERE service=$1 AND created_at>=$2 AND created_at<$3;", s.Id, x, t).Scan(&amount) return amount } diff --git a/html/css/base.css b/html/css/base.css index f0b6057b..324b6264 100644 --- a/html/css/base.css +++ b/html/css/base.css @@ -21,14 +21,36 @@ HTML,BODY { font-size: 26pt; font-weight: bold; display: block; + color: #3e3e3e; +} + +.text_perfect { + color: #33b418; + text-shadow: 0px 1px 0 #0e6702; +} + +.text_good { + color: #33b418; + text-shadow: 0px 1px 0 #0e6702; +} + +.text_ok { + color: #33b418; + text-shadow: 0px 1px 0 #0e6702; +} + +.text_bad { + color: #33b418; + text-shadow: 0px 1px 0 #0e6702; } .stats_area { text-align: center; + color: #a5a5a5; } .offline_bg { - background-color: #c5c5c578 !important; + background-color: white !important; } .footer { @@ -41,6 +63,28 @@ HTML,BODY { } +.online_badge { + color: #fff; + background-color: #35b317; +} + +.offline_badge { + color: #fff; + background-color: #c51919; +} + +.progress { + margin-top: -20px; + margin-left: -20px; + margin-bottom: 15px; + width: calc(100% + 40px); + height: 3px; + border-radius: 0; +} + +.card-body { + overflow: hidden; +} @media (max-width: 767px) { diff --git a/html/tmpl/dashboard.html b/html/tmpl/dashboard.html index 2ff5d8ad..9bf98e9f 100644 --- a/html/tmpl/dashboard.html +++ b/html/tmpl/dashboard.html @@ -43,18 +43,18 @@
- 69 - 24 Hour Hits + {{ .CountServices }} + Total Services
- 3921 - 24 Hour Hits + {{ .Count24Failures }} + Failures last 24 Hours
- 453 - Total Tokens + {{ .CountOnline }} + Online Services
diff --git a/html/tmpl/index.html b/html/tmpl/index.html index 940364a2..8b413e5d 100644 --- a/html/tmpl/index.html +++ b/html/tmpl/index.html @@ -8,22 +8,33 @@ - Statup | Dashboard + {{.Project}} Status -

{{.Project}}

+

{{.Project}}

+ {{ range .Services }}
-

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

-
+
+
+
+ +

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

+ +
{{.Online24Hours}}% @@ -39,10 +50,17 @@ {{.TotalUptime}}% Total Uptime
-
+ + {{ range .Failures }} +
+

{{.Issue}}

+
Reported {{.Ago}}
+
+ {{ end }} +
@@ -53,7 +71,7 @@