pull/10/head
Hunter Long 2018-06-29 22:08:08 -07:00
parent 81bcdb2f98
commit ae95aa1745
11 changed files with 66 additions and 14 deletions

View File

@ -18,7 +18,7 @@ services:
env:
global:
- VERSION=0.27.81
- VERSION=0.27.82
- DB_HOST=localhost
- DB_USER=travis
- DB_PASS=

View File

@ -1,6 +1,6 @@
FROM alpine:latest
ENV VERSION=v0.27.81
ENV VERSION=v0.27.82
RUN apk --no-cache add libstdc++ ca-certificates
RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \

View File

@ -98,7 +98,10 @@ func CreateAllAssets() {
CopyToPublic(JsBox, "js", "setup.js")
utils.Log(1, "Compiling CSS from SCSS style...")
err := CompileSASS()
if err == nil {
utils.Log(1, "Statup assets have been inserted")
if err != nil {
CopyToPublic(CssBox, "css", "base.css")
utils.Log(2, "Default 'base.css' was insert because SASS did not work.")
return
}
utils.Log(1, "Statup assets have been inserted")
}

View File

@ -2,6 +2,7 @@ package handlers
import (
"github.com/hunterlong/statup/core"
"github.com/hunterlong/statup/utils"
"net/http"
)
@ -15,3 +16,13 @@ Host: ` + core.CoreApp.Domain)
w.WriteHeader(http.StatusOK)
w.Write([]byte(robots))
}
func FavIconHandler(w http.ResponseWriter, r *http.Request) {
data, err := core.TmplBox.String("favicon.ico")
if err != nil {
utils.Log(2, err)
}
w.Header().Set("Content-Type", "image/x-icon")
w.WriteHeader(http.StatusOK)
w.Write([]byte(data))
}

View File

@ -20,6 +20,7 @@ func Router() *mux.Router {
r.PathPrefix("/js/").Handler(http.StripPrefix("/js/", http.FileServer(core.JsBox.HTTPBox())))
}
r.Handle("/robots.txt", http.HandlerFunc(RobotsTxtHandler)).Methods("GET")
r.Handle("/favicon.ico", http.HandlerFunc(FavIconHandler)).Methods("GET")
r.Handle("/setup", http.HandlerFunc(SetupHandler)).Methods("GET")
r.Handle("/setup", http.HandlerFunc(ProcessSetupHandler)).Methods("POST")
r.Handle("/dashboard", http.HandlerFunc(DashboardHandler)).Methods("GET")

View File

@ -279,6 +279,7 @@ func TestServiceHandler(t *testing.T) {
func TestPrometheusHandler(t *testing.T) {
req, err := http.NewRequest("GET", "/metrics", nil)
req.Header.Set("Authorization", core.CoreApp.ApiSecret)
assert.Nil(t, err)
rr := httptest.NewRecorder()
route.ServeHTTP(rr, req)
@ -286,6 +287,14 @@ func TestPrometheusHandler(t *testing.T) {
assert.True(t, strings.Contains(rr.Body.String(), "statup_total_services 6"))
}
func TestFailingPrometheusHandler(t *testing.T) {
req, err := http.NewRequest("GET", "/metrics", nil)
assert.Nil(t, err)
rr := httptest.NewRecorder()
route.ServeHTTP(rr, req)
assert.Equal(t, 55, rr.Result().StatusCode)
}
func TestLoginHandler(t *testing.T) {
form := url.Values{}
form.Add("username", "admin")

View File

@ -11,6 +11,14 @@ HTML,BODY {
max-width: $max-width;
}
H1 {
color: $title-color;
}
H5 {
color: $description-color;
}
.online_list .badge {
margin-top: 0.2rem;
}
@ -67,7 +75,7 @@ HTML,BODY {
}
.footer A {
color: #aaaaaa;
color: $footer-text-color;
text-decoration: none;
}
@ -95,7 +103,8 @@ HTML,BODY {
}
.card {
background-color: $card-background;
background-color: $service-background;
border: $service-border;
}
.card-body {
@ -103,7 +112,7 @@ HTML,BODY {
}
.card-body H4 A {
color: #239e07;
color: $service-title;
text-decoration: none;
}
@ -119,6 +128,15 @@ HTML,BODY {
.btn-success {
background-color: $success-color;
}
.btn-danger {
background-color: $danger-color;
}
.CodeMirror {
/* Bootstrap Settings */
box-sizing: border-box;
@ -198,6 +216,7 @@ HTML,BODY {
.lower_canvas SPAN {
font-size: 0.9rem;
float: left;
color: $service-description-color;
}
.btn-sm {

View File

@ -1,8 +1,17 @@
$background-color: #fcfcfc;
$max-width: 860px;
$online-color: #47d337;
$offline-color: #dd3545;
$card-background: #fff;
$card-stats-color: #474747;
$card-stats-size: 26pt;
$title-color: #000;
$description-color: #000;
$service-background: #bababa;
$service-border: 1px solid rgba(0,0,0,.125);
$service-title: #bababa;
$success-color: #47d337;
$danger-color: #dd3545;
$footer-text-color: #000;
$service-stats-color: #47d337;
$service-description-color: #47d337;
$service-stats-size: 12pt;

View File

@ -48,7 +48,7 @@
<h5 class="mb-1">{{.Name}}</h5>
<small>{{if .Online}} <span class="badge badge-success">ONLINE</span> {{else}} <span class="badge badge-danger">OFFLINE</span> {{end}}</small>
</div>
<p class="mb-1">Created {{.CreatedAt}}</p>
<p class="mb-1">{{.SmallText}}</p>
</a>
{{ end }}
</div>

BIN
source/tmpl/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
{{if .Core.OfflineAssets}}
<link rel="stylesheet" href="https://assets.statup.io/bootstrap.min.css">
{{ else }}