go templates - service chart data API

pull/78/head
Hunter Long 2018-10-01 23:21:14 -07:00
parent b24f939541
commit ed6fb12423
23 changed files with 829 additions and 1298 deletions

View File

@ -534,7 +534,7 @@ func RunServiceHandler(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
rr := httptest.NewRecorder() rr := httptest.NewRecorder()
route.ServeHTTP(rr, req) route.ServeHTTP(rr, req)
assert.True(t, strings.Contains(rr.Body.String(), "<title>Statup | Google Service</title>")) assert.True(t, strings.Contains(rr.Body.String(), "<title>Google Status</title>"))
assert.True(t, strings.Contains(rr.Body.String(), "footer")) assert.True(t, strings.Contains(rr.Body.String(), "footer"))
} }
@ -596,7 +596,7 @@ func RunUserViewHandler(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
rr := httptest.NewRecorder() rr := httptest.NewRecorder()
route.ServeHTTP(rr, req) route.ServeHTTP(rr, req)
assert.True(t, strings.Contains(rr.Body.String(), "<title>Statup | Users</title>")) assert.True(t, strings.Contains(rr.Body.String(), "<title>Statup | testadmin</title>"))
assert.True(t, strings.Contains(rr.Body.String(), "footer")) assert.True(t, strings.Contains(rr.Body.String(), "footer"))
assert.True(t, handlers.IsAuthenticated(req)) assert.True(t, handlers.IsAuthenticated(req))
} }

View File

@ -241,7 +241,7 @@ func TestApiServiceDataHandler(t *testing.T) {
grouping := []string{"minute", "hour", "day"} grouping := []string{"minute", "hour", "day"}
for _, g := range grouping { for _, g := range grouping {
params := "?start=0&end=999999999999&group=" + g params := "?start=0&end=999999999999&group=" + g
rr, err := httpRequestAPI(t, "GET", "/api/services/1/data"+params, nil) rr, err := httpRequestAPI(t, "GET", "/api/services/5/data"+params, nil)
assert.Nil(t, err) assert.Nil(t, err)
body := rr.Body.String() body := rr.Body.String()
var obj core.DateScanObj var obj core.DateScanObj

View File

@ -143,9 +143,17 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap
"FromUnix": func(t int64) string { "FromUnix": func(t int64) string {
return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).Format("Monday, January 02") return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).Format("Monday, January 02")
}, },
"NewService": func() *types.Service {
return new(types.Service)
},
"NewUser": func() *types.User {
return new(types.User)
},
} }
} }
var mainTmpl = `{{define "main" }} {{ template "base" . }} {{ end }}`
// executeResponse will render a HTTP response for the front end user // executeResponse will render a HTTP response for the front end user
func executeResponse(w http.ResponseWriter, r *http.Request, file string, data interface{}, redirect interface{}) { func executeResponse(w http.ResponseWriter, r *http.Request, file string, data interface{}, redirect interface{}) {
utils.Http(r) utils.Http(r)
@ -153,36 +161,49 @@ func executeResponse(w http.ResponseWriter, r *http.Request, file string, data i
http.Redirect(w, r, url, http.StatusSeeOther) http.Redirect(w, r, url, http.StatusSeeOther)
return return
} }
nav, _ := source.TmplBox.String("nav.html")
footer, _ := source.TmplBox.String("footer.html") templates := []string{"base.html", "head.html", "nav.html", "footer.html", "scripts.html", "form_service.html", "form_notifier.html", "form_user.html"}
chartIndex, _ := source.JsBox.String("chart_index.js")
javascripts := []string{"chart_index.js"}
render, err := source.TmplBox.String(file) render, err := source.TmplBox.String(file)
if err != nil { if err != nil {
utils.Log(4, err) utils.Log(4, err)
} }
t := template.New("message")
// setup the main template and handler funcs
t := template.New("main")
t.Funcs(handlerFuncs(w, r)) t.Funcs(handlerFuncs(w, r))
t, err = t.Parse(nav) t, err = t.Parse(mainTmpl)
if err != nil { if err != nil {
utils.Log(4, err) utils.Log(4, err)
} }
t, err = t.Parse(footer)
// render all templates
for _, temp := range templates {
tmp, _ := source.TmplBox.String(temp)
t, err = t.Parse(tmp)
if err != nil { if err != nil {
utils.Log(4, err) utils.Log(4, err)
} }
}
// render all javascript files
for _, temp := range javascripts {
tmp, _ := source.JsBox.String(temp)
t, err = t.Parse(tmp)
if err != nil {
utils.Log(4, err)
}
}
// render the page requested
_, err = t.Parse(render) _, err = t.Parse(render)
if err != nil { if err != nil {
utils.Log(4, err) utils.Log(4, err)
} }
_, err = t.Parse(chartIndex)
if err != nil {
utils.Log(4, err)
}
fmt.Println(t.Templates())
fmt.Println(t.DefinedTemplates())
t.Lookup("chartIndex").Funcs(handlerFuncs(w, r))
// execute the template
err = t.Execute(w, data) err = t.Execute(w, data)
if err != nil { if err != nil {
utils.Log(4, err) utils.Log(4, err)

View File

@ -108,7 +108,7 @@ func TestServicesViewHandler(t *testing.T) {
Router().ServeHTTP(rr, req) Router().ServeHTTP(rr, req)
body := rr.Body.String() body := rr.Body.String()
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | Google Service</title>") assert.Contains(t, body, "<title>Google Status</title>")
assert.Contains(t, body, "Statup made with ❤️") assert.Contains(t, body, "Statup made with ❤️")
} }
@ -252,7 +252,7 @@ func TestUsersEditHandler(t *testing.T) {
Router().ServeHTTP(rr, req) Router().ServeHTTP(rr, req)
body := rr.Body.String() body := rr.Body.String()
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | Users</title>") assert.Contains(t, body, "<title>Statup | admin</title>")
assert.Contains(t, body, "<h3>User admin</h3>") assert.Contains(t, body, "<h3>User admin</h3>")
assert.Contains(t, body, "value=\"info@statup.io\"") assert.Contains(t, body, "value=\"info@statup.io\"")
assert.Contains(t, body, "value=\"##########\"") assert.Contains(t, body, "value=\"##########\"")
@ -347,7 +347,7 @@ func TestViewHTTPServicesHandler(t *testing.T) {
Router().ServeHTTP(rr, req) Router().ServeHTTP(rr, req)
body := rr.Body.String() body := rr.Body.String()
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | Crystal Castles - Kept Service</title>") assert.Contains(t, body, "<title>Crystal Castles - Kept Status</title>")
assert.Contains(t, body, "Statup made with ❤️") assert.Contains(t, body, "Statup made with ❤️")
} }
@ -358,7 +358,7 @@ func TestViewTCPServicesHandler(t *testing.T) {
Router().ServeHTTP(rr, req) Router().ServeHTTP(rr, req)
body := rr.Body.String() body := rr.Body.String()
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | Local Postgres Service</title>") assert.Contains(t, body, "<title>Local Postgres Status</title>")
assert.Contains(t, body, "Statup made with ❤️") assert.Contains(t, body, "Statup made with ❤️")
} }
@ -403,7 +403,7 @@ func TestServicesUpdateHandler(t *testing.T) {
Router().ServeHTTP(rr, req) Router().ServeHTTP(rr, req)
body := rr.Body.String() body := rr.Body.String()
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | The Bravery - An Honest Mistake Service</title>") assert.Contains(t, body, "<title>The Bravery - An Honest Mistake Status</title>")
assert.Contains(t, body, "Statup made with ❤️") assert.Contains(t, body, "Statup made with ❤️")
} }

View File

@ -1,21 +1,11 @@
{{ define "base" }}
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> {{block "head" .}} {{end}}
<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">
{{if USE_CDN}}
<link rel="shortcut icon" type="image/x-icon" href="https://assets.statup.io/favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>{{.Name}} Status</title>
</head>
<body> <body>
{{template "content" .}}
</body> </body>
<footer>{{template "footer" .}}</footer>
{{template "scripts" .}}
</html> </html>
{{end}}

View File

@ -1,51 +1,25 @@
<!doctype html> {{define "title"}}Statup | Dashboard{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Dashboard</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav" }} {{template "nav" }}
<div class="col-12 mt-3"> <div class="col-12 mt-3">
<div class="row stats_area mb-5"> <div class="row stats_area mb-5">
<div class="col-4"> <div class="col-4">
<span class="lg_number">{{ CoreApp.ServicesCount }}</span> <span class="lg_number">{{ CoreApp.ServicesCount }}</span>
Total Services Total Services
</div> </div>
<div class="col-4"> <div class="col-4">
<span class="lg_number">{{ CoreApp.Count24HFailures }}</span> <span class="lg_number">{{ CoreApp.Count24HFailures }}</span>
Failures last 24 Hours Failures last 24 Hours
</div> </div>
<div class="col-4"> <div class="col-4">
<span class="lg_number">{{ CoreApp.CountOnline }}</span> <span class="lg_number">{{ CoreApp.CountOnline }}</span>
Online Services Online Services
</div> </div>
</div> </div>
<div class="row mt-4"> <div class="row mt-4">
<div class="col-12"> <div class="col-12">
<h3>Services</h3> <h3>Services</h3>
<div class="list-group mb-5 mt-3"> <div class="list-group mb-5 mt-3">
{{ range Services }} {{ range Services }}
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start"> <a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
@ -80,18 +54,4 @@
</div> </div>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,44 +1,10 @@
<!doctype html> {{define "title"}}Statup Page Not Found{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Page Not Found</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
<div class="col-12 mt-3"> <div class="col-12 mt-3">
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
Sorry, this page doesn't seem to exist. Sorry, this page doesn't seem to exist.
</div> </div>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,7 +1,7 @@
{{ define "footer"}} {{ define "footer"}}
<div class="footer text-center mb-4"> <div class="footer text-center mb-4">
{{ if ne CoreApp.Footer "" }} {{ if CoreApp.Footer}}
{{ safe CoreApp.Footer }} {{ CoreApp.Footer }}
{{ else }} {{ else }}
<a href="https://github.com/hunterlong/statup" target="_blank">Statup {{VERSION}} made with ❤️</a> | <a href="/dashboard">Dashboard</a> <a href="https://github.com/hunterlong/statup" target="_blank">Statup {{VERSION}} made with ❤️</a> | <a href="/dashboard">Dashboard</a>
{{ end }} {{ end }}

View File

@ -0,0 +1,65 @@
{{define "form_notifier"}}
{{$n := .Select}}
<form method="POST" class="{{underscore $n.Method }}" action="/settings/notifier/{{ $n.Method }}">
{{if $n.Title}}<h4>{{$n.Title}}</h4>{{end}}
{{if $n.Description}}<p class="small text-muted">{{safe $n.Description}}</p>{{end}}
{{range .Form}}
<div class="form-group">
<label class="text-capitalize" for="{{underscore .Title}}">{{.Title}}</label>
<input type="{{.Type}}" name="{{underscore .DbField}}" class="form-control" value="{{ $n.GetValue .DbField }}" id="{{underscore .Title}}" placeholder="{{.Placeholder}}" {{if .Required}}required{{end}}>
{{if .SmallText}}<small class="form-text text-muted">{{safe .SmallText}}</small>{{end}}
</div>
{{end}}
<div class="row">
<div class="col-9 col-sm-6">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">Limit</div>
</div>
<input type="text" class="form-control" name="limits" min="1" max="60" id="limits_per_hour_{{underscore $n.Method }}" value="{{$n.Limits}}" placeholder="7">
<div class="input-group-append">
<div class="input-group-text">Per Minute</div>
</div>
</div>
</div>
<div class="col-3 col-sm-2 mt-1">
<span class="switch">
<input type="checkbox" name="enable" class="switch" id="switch-{{ $n.Method }}" {{if $n.Enabled}}checked{{end}}>
<label for="switch-{{ $n.Method }}"></label>
</span>
</div>
<input type="hidden" name="notifier" value="{{underscore $n.Method }}">
<div class="col-12 col-sm-4 mb-2 mb-sm-0 mt-2 mt-sm-0">
<button type="submit" class="btn btn-primary btn-block text-capitalize">Save</button>
</div>
{{if $n.CanTest}}
<div class="col-12 col-sm-12">
<button class="test_notifier btn btn-secondary btn-block text-capitalize col-12 float-right">Test</button>
</div>
<div class="col-12 col-sm-12 mt-2">
<div class="alert alert-danger d-none" id="{{underscore $n.Method}}-error" role="alert">
{{$n.Method}} has an error!
</div>
<div class="alert alert-success d-none" id="{{underscore $n.Method}}-success" role="alert">
The {{$n.Method}} notifier is working correctly!
</div>
</div>
{{end}}
</div>
{{if $n.Author}}
<span class="d-block small text-center mt-3 mb-5">
{{$n.Title}} Notifier created by <a href="{{$n.AuthorUrl}}" target="_blank">{{$n.Author}}</a>
</span>
{{ end }}
</form>
{{end}}

View File

@ -0,0 +1,93 @@
{{define "form_service"}}
{{$url := "/service"}}
{{if .}}
{{$url = "/service/{{.Id}}"}}
{{end}}
<form action="{{$url}}" method="POST">
<div class="form-group row">
<label for="service_name" class="col-sm-4 col-form-label">Service Name</label>
<div class="col-sm-8">
<input type="text" name="name" class="form-control" id="service_name" value="{{.Name}}" placeholder="Name" required spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="service_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="check_type" class="form-control" id="service_type" value="{{.Type}}">
<option value="http" {{if eq .Type "http"}}selected{{end}}>HTTP Service</option>
<option value="tcp" {{if eq .Type "tcp"}}selected{{end}}>TCP Service</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="service_url" class="col-sm-4 col-form-label">Application Endpoint (URL)</label>
<div class="col-sm-8">
<input type="text" name="domain" class="form-control" id="service_url" value="{{.Domain}}" placeholder="https://google.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row{{if eq .Type "tcp"}} d-none{{end}}">
<label for="service_check_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="method" class="form-control" id="service_check_type" value="{{.Method}}">
<option value="GET" {{if eq .Method "GET"}}selected{{end}}>GET</option>
<option value="POST" {{if eq .Method "POST"}}selected{{end}}>POST</option>
<option value="DELETE" {{if eq .Method "DELETE"}}selected{{end}}>DELETE</option>
<option value="PATCH" {{if eq .Method "PATCH"}}selected{{end}}>PATCH</option>
<option value="PUT" {{if eq .Method "PUT"}}selected{{end}}>PUT</option>
</select>
</div>
</div>
<div class="form-group row{{if ne .Method "POST"}} d-none{{end}}">
<label for="post_data" class="col-sm-4 col-form-label">Optional Post Data (JSON)</label>
<div class="col-sm-8">
<textarea name="post_data" class="form-control" id="post_data" rows="3" autocapitalize="false" spellcheck="false">{{.PostData}}</textarea>
<small id="emailHelp" class="form-text text-muted">You can insert <a target="_blank" href="https://regex101.com/r/I5bbj9/1">Regex</a> to validate the response</small>
</div>
</div>
<div class="form-group row{{if eq .Type "tcp"}} d-none{{end}}">
<label for="service_response" class="col-sm-4 col-form-label">Expected Response (Regex)</label>
<div class="col-sm-8">
<textarea name="expected" class="form-control" id="service_response" rows="3" autocapitalize="false" spellcheck="false">{{.Expected}}</textarea>
</div>
</div>
<div class="form-group row{{if eq .Type "tcp"}} d-none{{end}}">
<label for="service_response_code" class="col-sm-4 col-form-label">Expected Status Code</label>
<div class="col-sm-8">
<input type="number" name="expected_status" class="form-control" value="{{.ExpectedStatus}}" id="service_response_code">
</div>
</div>
<div class="form-group row{{if eq .Type "http"}} d-none{{end}}">
<label for="service_port" class="col-sm-4 col-form-label">TCP Port</label>
<div class="col-sm-8">
<input type="number" name="port" class="form-control" value="{{.Port}}" id="service_port" placeholder="8080">
</div>
</div>
<div class="form-group row">
<label for="service_interval" class="col-sm-4 col-form-label">Check Interval (Seconds)</label>
<div class="col-sm-8">
<input type="number" name="interval" class="form-control" value="{{.Interval}}" min="1" id="service_interval" required>
<small id="emailHelp" class="form-text text-muted">10,000+ will be checked in Microseconds (1 millisecond = 1000 microseconds).</small>
</div>
</div>
<div class="form-group row">
<label for="service_timeout" class="col-sm-4 col-form-label">Timeout in Seconds</label>
<div class="col-sm-8">
<input type="number" name="timeout" class="form-control" value="{{.Timeout}}" id="service_timeout" min="1">
</div>
</div>
<div class="form-group row">
<label for="order" class="col-sm-4 col-form-label">List Order</label>
<div class="col-sm-8">
<input type="number" name="order" class="form-control" min="0" value="{{.Order}}" id="order">
</div>
</div>
<div class="form-group row">
<div class="col-6">
<button type="submit" class="btn btn-success btn-block">Update Service</button>
</div>
<div class="col-6">
<a href="/service/{{ .Id }}/delete_failures" class="btn btn-danger btn-block confirm-btn">Delete All Failures</a>
</div>
</div>
</form>
{{end}}

View File

@ -0,0 +1,43 @@
{{define "form_user"}}
{{$url := "/user"}}
{{if .}}
{{$url = "/user/{{.Id}}"}}
{{end}}
<form action="{{$url}}" method="POST">
<div class="form-group row">
<label for="username" class="col-sm-4 col-form-label">Username</label>
<div class="col-6 col-md-4">
<input type="text" name="username" class="form-control" value="{{.Username}}" id="username" placeholder="Username" required>
</div>
<div class="col-6 col-md-4">
<span class="switch">
<input type="checkbox" name="admin" class="switch" id="switch-normal"{{if .Admin}} checked{{end}}>
<label for="switch-normal">Administrator</label>
</span>
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label">Email Address</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="email" value="{{.Email}}" placeholder="user@domain.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-4 col-form-label">Password</label>
<div class="col-sm-8">
<input type="password" name="password" class="form-control" id="password" value="##########" placeholder="Password" required>
</div>
</div>
<div class="form-group row">
<label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label>
<div class="col-sm-8">
<input type="password" name="password_confirm" class="form-control" id="password_confirm" value="##########" placeholder="Confirm Password" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-block">Update User</button>
</div>
</div>
</form>
{{end}}

17
source/tmpl/head.html Normal file
View File

@ -0,0 +1,17 @@
{{ define "head"}}
<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">
{{if USE_CDN}}
<link rel="shortcut icon" type="image/x-icon" href="https://assets.statup.io/favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
{{block "extra_css" .}} {{end}}
<title>{{block "title" .}} {{end}}</title>
</head>
{{end}}

View File

@ -1,31 +1,15 @@
<!doctype html> {{define "title"}}Statup | Help{{end}}
<html lang="en"> {{define "content"}}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Help</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{if Auth}} {{if Auth}}
{{template "nav"}} {{template "nav"}}
{{end}} {{end}}
<div class="col-12"> <div class="col-12">
{{ safe . }} {{ safe . }}
</div> </div>
</div> </div>
{{end}}
{{define "extra_css"}}
<style> <style>
pre { pre {
background-color: white; background-color: white;
@ -37,18 +21,4 @@
color: #d87e1a; color: #d87e1a;
} }
</style> </style>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,24 +1,6 @@
<!doctype html> {{define "title"}}{{CoreApp.Name}} Status{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="shortcut icon" type="image/x-icon" href="https://assets.statup.io/favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>{{.Name}} Status</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-2 sm-container"> <div class="container col-md-7 col-sm-12 mt-2 sm-container">
<h1 class="col-12 text-center mb-4 mt-sm-3 header-title">{{.Name}}</h1> <h1 class="col-12 text-center mb-4 mt-sm-3 header-title">{{.Name}}</h1>
{{ if .Description }} {{ if .Description }}
@ -40,7 +22,6 @@
</div> </div>
</div> </div>
<div class="col-12 full-col-12"> <div class="col-12 full-col-12">
{{ if not Services }} {{ if not Services }}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
@ -97,32 +78,11 @@
{{ end }} {{ end }}
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/Chart.bundle.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
{{define "extra_scripts"}}
{{ if .Style }}
<style>
{{ safe .Style }}
</style>
{{ end }}
<script> <script>
{{ range Services }} {{ range Services }}
{{template "chartIndex" .}} {{template "chartIndex" .}}
{{end}} {{end}}
</script> </script>
{{end}}
</body>
</html>

View File

@ -1,34 +1,15 @@
<!doctype html> {{define "title"}}Statup Login{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Login</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
<div class="col-10 offset-1 col-md-8 offset-md-2 mt-md-2"> <div class="col-10 offset-1 col-md-8 offset-md-2 mt-md-2">
<div class="col-12 col-md-8 offset-md-2 mb-4"> <div class="col-12 col-md-8 offset-md-2 mb-4">
<img class="col-12 mt-5 mt-md-0" src="/statup.png"> <img class="col-12 mt-5 mt-md-0" src="/statup.png">
</div> </div>
{{ if .Error }} {{ if .Error }}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
Incorrect login information submitted, try again. Incorrect login information submitted, try again.
</div> </div>
{{ end }} {{ end }}
<form action="/dashboard" method="POST"> <form action="/dashboard" method="POST">
<div class="form-group row"> <div class="form-group row">
<label for="username" class="col-sm-2 col-form-label">Username</label> <label for="username" class="col-sm-2 col-form-label">Username</label>
@ -48,22 +29,6 @@
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,45 +1,15 @@
<!doctype html> {{define "title"}}Statup | Logs{{end}}
<html lang="en"> {{define "content"}}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Logs</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{if Auth}} {{if Auth}}
{{template "nav"}} {{template "nav"}}
{{end}} {{end}}
<div class="col-12"> <div class="col-12">
<textarea id="live_logs" class="form-control" rows="40" readonly>{{range .}}{{.}}{{end}}</textarea> <textarea id="live_logs" class="form-control" rows="40" readonly>{{range .}}{{.}}{{end}}</textarea>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
{{define "extra_css"}}
<style> <style>
@media (max-width: 767px) { @media (max-width: 767px) {
#live_logs { #live_logs {
@ -47,6 +17,4 @@
} }
} }
</style> </style>
{{end}}
</body>
</html>

14
source/tmpl/scripts.html Normal file
View File

@ -0,0 +1,14 @@
{{define "scripts"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/Chart.bundle.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
{{block "extra_scripts" .}} {{end}}
{{end}}

View File

@ -1,22 +1,6 @@
{{define "title"}}{{.Service.Name}} Status{{end}}
{{ define "content" }}
{{$s := .Service}} {{$s := .Service}}
<!doctype html>
<html lang="en">
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
<script src="/js/Chart.bundle.min.js"></script>
{{end}}
<title>Statup | {{$s.Name}} Service</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
@ -91,100 +75,13 @@
</div> </div>
{{if Auth}} {{if Auth}}
<div class="col-12 mt-4"> <div class="col-12 mt-4">
<h3>Edit Service</h3> <h3>Edit Service</h3>
<form action="/service/{{$s.Id}}" method="POST"> {{template "form_service" $s}}
<div class="form-group row">
<label for="service_name" class="col-sm-4 col-form-label">Service Name</label>
<div class="col-sm-8">
<input type="text" name="name" class="form-control" id="service_name" value="{{$s.Name}}" placeholder="Name" required spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="service_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="check_type" class="form-control" id="service_type" value="{{$s.Type}}">
<option value="http" {{if eq $s.Type "http"}}selected{{end}}>HTTP Service</option>
<option value="tcp" {{if eq $s.Type "tcp"}}selected{{end}}>TCP Service</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="service_url" class="col-sm-4 col-form-label">Application Endpoint (URL)</label>
<div class="col-sm-8">
<input type="text" name="domain" class="form-control" id="service_url" value="{{$s.Domain}}" placeholder="https://google.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row{{if eq $s.Type "tcp"}} d-none{{end}}">
<label for="service_check_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="method" class="form-control" id="service_check_type" value="{{$s.Method}}">
<option value="GET" {{if eq $s.Method "GET"}}selected{{end}}>GET</option>
<option value="POST" {{if eq $s.Method "POST"}}selected{{end}}>POST</option>
<option value="DELETE" {{if eq $s.Method "DELETE"}}selected{{end}}>DELETE</option>
<option value="PATCH" {{if eq $s.Method "PATCH"}}selected{{end}}>PATCH</option>
<option value="PUT" {{if eq $s.Method "PUT"}}selected{{end}}>PUT</option>
</select>
</div>
</div>
<div class="form-group row{{if ne $s.Method "POST"}} d-none{{end}}">
<label for="post_data" class="col-sm-4 col-form-label">Optional Post Data (JSON)</label>
<div class="col-sm-8">
<textarea name="post_data" class="form-control" id="post_data" rows="3" autocapitalize="false" spellcheck="false">{{$s.PostData}}</textarea>
<small id="emailHelp" class="form-text text-muted">You can insert <a target="_blank" href="https://regex101.com/r/I5bbj9/1">Regex</a> to validate the response</small>
</div>
</div>
<div class="form-group row{{if eq $s.Type "tcp"}} d-none{{end}}">
<label for="service_response" class="col-sm-4 col-form-label">Expected Response (Regex)</label>
<div class="col-sm-8">
<textarea name="expected" class="form-control" id="service_response" rows="3" autocapitalize="false" spellcheck="false">{{$s.Expected}}</textarea>
</div>
</div>
<div class="form-group row{{if eq $s.Type "tcp"}} d-none{{end}}">
<label for="service_response_code" class="col-sm-4 col-form-label">Expected Status Code</label>
<div class="col-sm-8">
<input type="number" name="expected_status" class="form-control" value="{{$s.ExpectedStatus}}" id="service_response_code">
</div>
</div>
<div class="form-group row{{if eq $s.Type "http"}} d-none{{end}}">
<label for="service_port" class="col-sm-4 col-form-label">TCP Port</label>
<div class="col-sm-8">
<input type="number" name="port" class="form-control" value="{{$s.Port}}" id="service_port" placeholder="8080">
</div>
</div>
<div class="form-group row">
<label for="service_interval" class="col-sm-4 col-form-label">Check Interval (Seconds)</label>
<div class="col-sm-8">
<input type="number" name="interval" class="form-control" value="{{$s.Interval}}" min="1" id="service_interval" required>
<small id="emailHelp" class="form-text text-muted">10,000+ will be checked in Microseconds (1 millisecond = 1000 microseconds).</small>
</div>
</div>
<div class="form-group row">
<label for="service_timeout" class="col-sm-4 col-form-label">Timeout in Seconds</label>
<div class="col-sm-8">
<input type="number" name="timeout" class="form-control" value="{{$s.Timeout}}" id="service_timeout" min="1">
</div>
</div>
<div class="form-group row">
<label for="order" class="col-sm-4 col-form-label">List Order</label>
<div class="col-sm-8">
<input type="number" name="order" class="form-control" min="0" value="{{$s.Order}}" id="order">
</div>
</div>
<div class="form-group row">
<div class="col-6">
<button type="submit" class="btn btn-success btn-block">Update Service</button>
</div>
<div class="col-6">
<a href="/service/{{ $s.Id }}/delete_failures" class="btn btn-danger btn-block confirm-btn">Delete All Failures</a>
</div>
</div>
</form>
</div> </div>
@ -226,26 +123,15 @@
</div> </div>
{{end}} {{end}}
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<script src="https://assets.statup.io/pikaday.js"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/Chart.bundle.min.js"></script>
<script src="/js/pikaday.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
{{define "extra_scripts"}}
{{if USE_CDN}}
<script src="https://assets.statup.io/pikaday.js"></script>
{{ else }}
<script src="/js/pikaday.js"></script>
{{end}}
{{$s := .Service}}
<script> <script>
var ctx = document.getElementById("service").getContext('2d'); var ctx = document.getElementById("service").getContext('2d');
@ -352,6 +238,4 @@
AjaxChart(chartdata,{{$s.Id}},{{.Start}},{{.End}},"hour"); AjaxChart(chartdata,{{$s.Id}},{{.Start}},{{.End}},"hour");
</script> </script>
{{end}}
</body>
</html>

View File

@ -1,22 +1,6 @@
<!doctype html> {{define "title"}}Statup | Services{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Services</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav"}} {{template "nav"}}
<div class="col-12"> <div class="col-12">
@ -49,109 +33,17 @@
<h3>Create Service</h3> <h3>Create Service</h3>
<form action="/services" method="POST"> {{template "form_service" NewService}}
<div class="form-group row">
<label for="service_name" class="col-sm-4 col-form-label">Service Name</label>
<div class="col-sm-8">
<input type="text" name="name" class="form-control" id="service_name" placeholder="Name" required spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="service_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="check_type" class="form-control" id="service_type">
<option value="http" selected>HTTP Service</option>
<option value="tcp">TCP Service</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="service_url" class="col-sm-4 col-form-label">Application Endpoint (URL)</label>
<div class="col-sm-8">
<input type="text" name="domain" class="form-control" id="service_url" placeholder="https://google.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="service_check_type" class="col-sm-4 col-form-label">Service Check Type</label>
<div class="col-sm-8">
<select name="method" class="form-control" id="service_check_type">
<option value="GET" selected>GET</option>
<option value="POST">POST</option>
<option value="DELETE">DELETE</option>
<option value="PATCH">PATCH</option>
<option value="PUT">PUT</option>
</select>
</div>
</div>
<div class="form-group row d-none">
<label for="post_data" class="col-sm-4 col-form-label">Post Data (JSON)</label>
<div class="col-sm-8">
<textarea name="post_data" class="form-control" id="post_data" rows="3" autocapitalize="false" spellcheck="false"></textarea>
</div>
</div>
<div class="form-group row">
<label for="service_response" class="col-sm-4 col-form-label">Expected Response (Regex)</label>
<div class="col-sm-8">
<textarea name="expected" class="form-control" id="service_response" rows="3" autocapitalize="false" spellcheck="false"></textarea>
<small id="emailHelp" class="form-text text-muted">You can insert <a target="_blank" href="https://regex101.com/r/I5bbj9/1">Regex</a> to validate the response</small>
</div>
</div>
<div class="form-group row">
<label for="service_response_code" class="col-sm-4 col-form-label">Expected Status Code</label>
<div class="col-sm-8">
<input type="number" name="expected_status" class="form-control" id="service_response_code" value="200">
</div>
</div>
<div class="form-group row d-none">
<label for="service_port" class="col-sm-4 col-form-label">TCP Port</label>
<div class="col-sm-8">
<input type="number" name="port" class="form-control" id="service_port" placeholder="8080">
</div>
</div>
<div class="form-group row">
<label for="service_interval" class="col-sm-4 col-form-label">Check Interval (Seconds)</label>
<div class="col-sm-8">
<input type="number" name="interval" class="form-control" id="service_interval" min="1" value="60" required>
<small id="emailHelp" class="form-text text-muted">10,000+ will be checked in Microseconds (1 millisecond = 1000 microseconds).</small>
</div>
</div>
<div class="form-group row">
<label for="service_timeout" class="col-sm-4 col-form-label">Timeout in Seconds</label>
<div class="col-sm-8">
<input type="number" name="timeout" class="form-control" id="service_timeout" min="1" value="30">
</div>
</div>
<div class="form-group row">
<label for="order" class="col-sm-4 col-form-label">List Order</label>
<div class="col-sm-8">
<input type="number" name="order" class="form-control" min="0" value="0" id="order">
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-success btn-block">Create Service</button>
</div>
</div>
</form>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://assets.statup.io/sortable.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/sortable.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
{{define "extra_scripts"}}
{{if USE_CDN}}
<script src="https://assets.statup.io/sortable.min.js"></script>
{{ else }}
<script src="/js/sortable.min.js"></script>
{{end}}
<script> <script>
sortable('.sortable', { sortable('.sortable', {
forcePlaceholderSize: true, forcePlaceholderSize: true,
@ -171,6 +63,4 @@
}); });
}); });
</script> </script>
{{end}}
</body>
</html>

View File

@ -1,33 +1,10 @@
<!doctype html> {{define "title"}}Statup | Settings{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<link rel="stylesheet" href="https://assets.statup.io/codemirror.css">
<link rel="stylesheet" href="https://assets.statup.io/codemirror-colorpicker.css"/>
<title>Statup | Settings</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav"}} {{template "nav"}}
<div class="col-12"> <div class="col-12">
<div class="row"> <div class="row">
<div class="col-md-3 col-sm-12 mb-4 mb-md-0"> <div class="col-md-3 col-sm-12 mb-4 mb-md-0">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical"> <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Settings</a> <a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Settings</a>
<a class="nav-link" id="v-pills-style-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false">Theme Editor</a> <a class="nav-link" id="v-pills-style-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false">Theme Editor</a>
@ -181,68 +158,8 @@
{{ range .Notifications }} {{ range .Notifications }}
{{$n := .Select}} {{$n := .Select}}
<div class="tab-pane" id="v-pills-{{underscore $n.Method}}" role="tabpanel" aria-labelledby="v-pills-{{underscore $n.Method }}-tab"> <div class="tab-pane" id="v-pills-{{underscore $n.Method}}" role="tabpanel" aria-labelledby="v-pills-{{underscore $n.Method }}-tab">
<form method="POST" class="{{underscore $n.Method }}" action="/settings/notifier/{{ $n.Method }}">
{{if $n.Title}}<h4>{{$n.Title}}</h4>{{end}}
{{if $n.Description}}<p class="small text-muted">{{safe $n.Description}}</p>{{end}}
{{range .Form}} {{template "form_notifier" .}}
<div class="form-group">
<label class="text-capitalize" for="{{underscore .Title}}">{{.Title}}</label>
<input type="{{.Type}}" name="{{underscore .DbField}}" class="form-control" value="{{ $n.GetValue .DbField }}" id="{{underscore .Title}}" placeholder="{{.Placeholder}}" {{if .Required}}required{{end}}>
{{if .SmallText}}<small class="form-text text-muted">{{safe .SmallText}}</small>{{end}}
</div>
{{end}}
<div class="row">
<div class="col-9 col-sm-6">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">Limit</div>
</div>
<input type="text" class="form-control" name="limits" min="1" max="60" id="limits_per_hour_{{underscore $n.Method }}" value="{{$n.Limits}}" placeholder="7">
<div class="input-group-append">
<div class="input-group-text">Per Minute</div>
</div>
</div>
</div>
<div class="col-3 col-sm-2 mt-1">
<span class="switch">
<input type="checkbox" name="enable" class="switch" id="switch-{{ $n.Method }}" {{if $n.Enabled}}checked{{end}}>
<label for="switch-{{ $n.Method }}"></label>
</span>
</div>
<input type="hidden" name="notifier" value="{{underscore $n.Method }}">
<div class="col-12 col-sm-4 mb-2 mb-sm-0 mt-2 mt-sm-0">
<button type="submit" class="btn btn-primary btn-block text-capitalize">Save</button>
</div>
{{if $n.CanTest}}
<div class="col-12 col-sm-12">
<button class="test_notifier btn btn-secondary btn-block text-capitalize col-12 float-right">Test</button>
</div>
<div class="col-12 col-sm-12 mt-2">
<div class="alert alert-danger d-none" id="{{underscore $n.Method}}-error" role="alert">
{{$n.Method}} has an error!
</div>
<div class="alert alert-success d-none" id="{{underscore $n.Method}}-success" role="alert">
The {{$n.Method}} notifier is working correctly!
</div>
</div>
{{end}}
</div>
{{if $n.Author}}
<span class="d-block small text-center mt-3 mb-5">
{{$n.Title}} Notifier created by <a href="{{$n.AuthorUrl}}" target="_blank">{{$n.Author}}</a>
</span>
{{ end }}
</form>
{{ if $n.Logs }} {{ if $n.Logs }}
Sent {{$n.SentLastHour}} in the last hour<br> Sent {{$n.SentLastHour}} in the last hour<br>
@ -295,26 +212,13 @@
</div> </div>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
{{end}} {{end}}
{{define "extra_css"}}
<link rel="stylesheet" href="https://assets.statup.io/codemirror.css">
<link rel="stylesheet" href="https://assets.statup.io/codemirror-colorpicker.css"/>
{{end}}
{{define "extra_scripts"}}
<script src="https://assets.statup.io/codemirror.js"></script> <script src="https://assets.statup.io/codemirror.js"></script>
<script src="https://assets.statup.io/css.js"></script> <script src="https://assets.statup.io/css.js"></script>
<script src="https://assets.statup.io/codemirror-colorpicker.min.js"></script> <script src="https://assets.statup.io/codemirror-colorpicker.min.js"></script>
{{if USE_CDN}}
<script src="https://assets.statup.io/main.js"></script>
{{else}}
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,37 +1,15 @@
<!doctype html> {{define "title"}}Statup | Setup{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Setup</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
<div class="col-4 offset-4 mt-2 mb-5"><img width="100%" src="/statup.png"></div> <div class="col-4 offset-4 mt-2 mb-5"><img width="100%" src="/statup.png"></div>
<div class="col-12"> <div class="col-12">
{{ if .Error }} {{ if .Error }}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
{{ .Error }} {{ .Error }}
</div> </div>
{{ end }} {{ end }}
<form method="POST" id="setup_form" action="/setup"> <form method="POST" id="setup_form" action="/setup">
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<div class="form-group"> <div class="form-group">
<label for="inputState">Database Connection</label> <label for="inputState">Database Connection</label>
@ -104,28 +82,12 @@
</div> </div>
</div> </div>
<button id="setup_button" type="submit" class="btn btn-primary btn-block disable_click">Save Settings</button> <button id="setup_button" type="submit" class="btn btn-primary btn-block disable_click">Save Settings</button>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
{{end}}
{{template "footer"}} {{define "extra_scripts"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/setup.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/setup.js"></script> <script src="/js/setup.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,81 +1,10 @@
<!doctype html> {{define "title"}}Statup | {{.Username}}{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Users</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav"}} {{template "nav"}}
<div class="col-12"> <div class="col-12">
<h3>User {{.Username}}</h3> <h3>User {{.Username}}</h3>
<form action="/user/{{.Id}}" method="POST"> {{template "form_user" .}}
<div class="form-group row">
<label for="username" class="col-sm-4 col-form-label">Username</label>
<div class="col-6 col-md-4">
<input type="text" name="username" class="form-control" value="{{.Username}}" id="username" placeholder="Username" required>
</div>
<div class="col-6 col-md-4">
<span class="switch">
<input type="checkbox" name="admin" class="switch" id="switch-normal"{{if .Admin}} checked{{end}}>
<label for="switch-normal">Administrator</label>
</span>
</div> </div>
</div> </div>
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label">Email Address</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="email" value="{{.Email}}" placeholder="user@domain.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-4 col-form-label">Password</label>
<div class="col-sm-8">
<input type="password" name="password" class="form-control" id="password" value="##########" placeholder="Password" required>
</div>
</div>
<div class="form-group row">
<label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label>
<div class="col-sm-8">
<input type="password" name="password_confirm" class="form-control" id="password_confirm" value="##########" placeholder="Confirm Password" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-block">Update User</button>
</div>
</div>
</form>
</div>
</div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>

View File

@ -1,29 +1,9 @@
<!doctype html> {{define "title"}}Statup | Users{{end}}
<html lang="en"> {{define "content"}}
<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">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Users</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light"> <div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav"}} {{template "nav"}}
<div class="col-12"> <div class="col-12">
<h3>Users</h3> <h3>Users</h3>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@ -47,59 +27,9 @@
</table> </table>
<h3>Create User</h3> <h3>Create User</h3>
<form action="/users" method="POST">
<div class="form-group row"> {{template "form_user" NewUser}}
<label for="username" class="col-sm-4 col-form-label">Username</label>
<div class="col-6 col-md-4">
<input type="text" name="username" class="form-control" id="username" placeholder="Username" required autocapitalize="false" spellcheck="false">
</div>
<div class="col-6 col-md-4">
<span class="switch">
<input type="checkbox" name="admin" class="switch" id="switch-normal">
<label for="switch-normal">Administrator</label>
</span>
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label">Email Address</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="email" placeholder="user@domain.com" required autocapitalize="false" spellcheck="false">
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-4 col-form-label">Password</label>
<div class="col-sm-8">
<input type="password" name="password" class="form-control" id="password" placeholder="Password" required>
</div>
</div>
<div class="form-group row">
<label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label>
<div class="col-sm-8">
<input type="password" name="password_confirm" class="form-control" id="password_confirm" placeholder="Confirm Password" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-block">Create User</button>
</div>
</div>
</form>
</div> </div>
</div> </div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}} {{end}}
</body>
</html>