From 0666ce247a55e7d6c824cbb0c52caa5081225f9c Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sun, 24 Jun 2018 04:51:07 -0700 Subject: [PATCH] building --- .travis.yml | 2 +- Dockerfile | 2 +- checker.go | 4 ++- failures.go | 9 ++++- hits.go | 15 ++++++--- html/css/base.css | 22 ++++++++++++- html/tmpl/dashboard.html | 2 +- html/tmpl/footer.html | 2 +- html/tmpl/help.html | 2 +- html/tmpl/index.html | 9 +++-- html/tmpl/login.html | 2 +- html/tmpl/plugins.html | 2 +- html/tmpl/service.html | 10 +++--- html/tmpl/services.html | 6 ++-- html/tmpl/setup.html | 2 +- html/tmpl/users.html | 2 +- services.go | 71 +++++++++++++++++++++++++++++++++++----- web.go | 5 +++ 18 files changed, 134 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a0b8825..8ad48277 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ services: env: global: - - VERSION=0.21 + - VERSION=0.22 matrix: allow_failures: diff --git a/Dockerfile b/Dockerfile index 8621104e..b793a2b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest -ENV VERSION=v0.21 +ENV VERSION=v0.22 RUN apk --no-cache add ca-certificates RUN wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-alpine && \ diff --git a/checker.go b/checker.go index 645ddb13..a91951f5 100644 --- a/checker.go +++ b/checker.go @@ -10,10 +10,12 @@ import ( func CheckServices() { services, _ = SelectAllServices() + time.Sleep(3 * time.Second) for _, v := range services { obj := v go obj.StartCheckins() go obj.CheckQueue() + time.Sleep(1 * time.Second) } } @@ -23,7 +25,7 @@ func (s *Service) CheckQueue() { if s.Interval < 1 { s.Interval = 1 } - fmt.Printf(" Service: %v | Online: %v | Latency: %0.0fms\n", s.Name, s.Online, (s.Latency * 100)) + fmt.Printf(" Service: %v | Online: %v | Latency: %0.0fms\n", s.Name, s.Online, (s.Latency * 1000)) time.Sleep(time.Duration(s.Interval) * time.Second) } diff --git a/failures.go b/failures.go index b1ad457d..a37a2290 100644 --- a/failures.go +++ b/failures.go @@ -47,10 +47,17 @@ func (u *Service) DeleteFailures() { func (s *Service) LimitedFailures() []*Failure { var fails []*Failure col := dbSession.Collection("failures").Find("service", s.Id) - col.OrderBy("-id").Limit(10).All(&fails) + col.OrderBy("create_at").All(&fails) return fails } +func reverseFailures(input []*Failure) []*Failure { + if len(input) == 0 { + return input + } + return append(reverseFailures(input[1:]), input[0]) +} + func (f *Failure) Ago() string { got, _ := timeago.TimeAgoWithTime(time.Now(), f.CreatedAt) return got diff --git a/hits.go b/hits.go index 4b1bd1d6..fc475f7b 100644 --- a/hits.go +++ b/hits.go @@ -36,11 +36,18 @@ func (s *Service) Hits() ([]Hit, error) { return hits, err } -func (s *Service) LimitedHits() ([]Hit, error) { - var hits []Hit - col := hitCol().Find("service", s.Id).Limit(1056).OrderBy("-id") +func (s *Service) LimitedHits() ([]*Hit, error) { + var hits []*Hit + col := hitCol().Find("service", s.Id).OrderBy("-id").Limit(1024) err := col.All(&hits) - return hits, err + return reverseHits(hits), err +} + +func reverseHits(input []*Hit) []*Hit { + if len(input) == 0 { + return input + } + return append(reverseHits(input[1:]), input[0]) } func (s *Service) SelectHitsGroupBy(group string) ([]Hit, error) { diff --git a/html/css/base.css b/html/css/base.css index 78b83a45..95bba3ec 100644 --- a/html/css/base.css +++ b/html/css/base.css @@ -90,10 +90,30 @@ HTML,BODY { text-decoration: none; } +.chart-container { + position: relative; + height: 20vh; + width: 60vh; +} + @media (max-width: 767px) { + .sm-container { + margin-top: 40px !important; + padding: 0 !important; + } + + .list-group-item H5 { + font-size: 0.9rem; + } + + .chart-container { + position: relative; + height:17vh; + width:80vw; + } + .container { - margin-top: 0 !important; padding: 0 !important; } diff --git a/html/tmpl/dashboard.html b/html/tmpl/dashboard.html index a2daccdc..41b17ac4 100644 --- a/html/tmpl/dashboard.html +++ b/html/tmpl/dashboard.html @@ -12,7 +12,7 @@ -
+
{{template "nav"}} diff --git a/html/tmpl/footer.html b/html/tmpl/footer.html index eb6566f5..12d5c1f1 100644 --- a/html/tmpl/footer.html +++ b/html/tmpl/footer.html @@ -3,6 +3,6 @@ {{ if .Core.Footer }} {{ safe .Core.Footer }} {{ end }} - Statup made with ❤️ {{ VERSION }} | Dashboard + Statup {{ VERSION }} made with ❤️ | Dashboard
{{ end }} \ No newline at end of file diff --git a/html/tmpl/help.html b/html/tmpl/help.html index 8b60697f..afeaf9d5 100644 --- a/html/tmpl/help.html +++ b/html/tmpl/help.html @@ -11,7 +11,7 @@ -
+
{{if Auth}} {{template "nav"}} diff --git a/html/tmpl/index.html b/html/tmpl/index.html index 3eb8ecff..43c59949 100644 --- a/html/tmpl/index.html +++ b/html/tmpl/index.html @@ -18,7 +18,7 @@ -
+

{{.Core.Name}}

@@ -46,7 +46,7 @@
{{ range .Services }} -
+
@@ -79,7 +79,9 @@
- +
+ +
{{ if .LimitedFailures }}
@@ -130,6 +132,7 @@ var chartdata = new Chart(ctx, { }] }, options: { + maintainAspectRatio: false, legend: { display: false }, diff --git a/html/tmpl/login.html b/html/tmpl/login.html index 1f57ccdf..686cad28 100644 --- a/html/tmpl/login.html +++ b/html/tmpl/login.html @@ -12,7 +12,7 @@ -
+
diff --git a/html/tmpl/plugins.html b/html/tmpl/plugins.html index 42c979ec..6855dcf6 100644 --- a/html/tmpl/plugins.html +++ b/html/tmpl/plugins.html @@ -12,7 +12,7 @@ -
+
{{template "nav"}} diff --git a/html/tmpl/service.html b/html/tmpl/service.html index 0b989a71..7e5573c9 100644 --- a/html/tmpl/service.html +++ b/html/tmpl/service.html @@ -12,7 +12,7 @@ -
+
{{if Auth}} {{template "nav"}} @@ -155,9 +155,11 @@
-
- - Delete All Failures +
+ +
+
diff --git a/html/tmpl/services.html b/html/tmpl/services.html index 32e8023d..2851e85b 100644 --- a/html/tmpl/services.html +++ b/html/tmpl/services.html @@ -12,7 +12,7 @@ -
+
{{template "nav"}} @@ -103,8 +103,8 @@
-
- +
+
diff --git a/html/tmpl/setup.html b/html/tmpl/setup.html index 28b31474..74011ba9 100644 --- a/html/tmpl/setup.html +++ b/html/tmpl/setup.html @@ -13,7 +13,7 @@ -
+
{{ if .Error }}