mirror of https://github.com/statping/statping
temp
parent
db025e87d7
commit
05ff5c5e2e
12
Makefile
12
Makefile
|
@ -71,10 +71,20 @@ install: build
|
||||||
run: build
|
run: build
|
||||||
./$(BINARY_NAME) --ip 0.0.0.0 --port 8080
|
./$(BINARY_NAME) --ip 0.0.0.0 --port 8080
|
||||||
|
|
||||||
|
# run Statping with Delve for debugging
|
||||||
|
rundlv:
|
||||||
|
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./$(BINARY_NAME)
|
||||||
|
|
||||||
|
builddlv:
|
||||||
|
$(GOBUILD) -gcflags "all=-N -l" -o ./$(BINARY_NAME) -v ./cmd
|
||||||
|
|
||||||
|
watch:
|
||||||
|
reflex -v -r '\.go' -s -- sh -c 'make builddlv && make rundlv'
|
||||||
|
|
||||||
# compile assets using SASS and Rice. compiles scss -> css, and run rice embed-go
|
# compile assets using SASS and Rice. compiles scss -> css, and run rice embed-go
|
||||||
compile: generate
|
compile: generate
|
||||||
sass source/scss/base.scss source/css/base.css
|
sass source/scss/base.scss source/css/base.css
|
||||||
cd source && $(GOPATH)/bin/rice embed-go
|
cd source && rice embed-go
|
||||||
rm -rf .sass-cache
|
rm -rf .sass-cache
|
||||||
|
|
||||||
# benchmark testing
|
# benchmark testing
|
||||||
|
|
|
@ -461,3 +461,19 @@ func (n *Notification) IsRunning() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExampleService can be used for the OnTest() method for notifiers
|
||||||
|
var ExampleService = &types.Service{
|
||||||
|
Id: 1,
|
||||||
|
Name: "Interpol - All The Rage Back Home",
|
||||||
|
Domain: "https://www.youtube.com/watch?v=-u6DvRyyKGU",
|
||||||
|
ExpectedStatus: 200,
|
||||||
|
Interval: 30,
|
||||||
|
Type: "http",
|
||||||
|
Method: "GET",
|
||||||
|
Timeout: 20,
|
||||||
|
LastStatusCode: 404,
|
||||||
|
Expected: types.NewNullString("test example"),
|
||||||
|
LastResponse: "<html>this is an example response</html>",
|
||||||
|
CreatedAt: time.Now().Add(-24 * time.Hour),
|
||||||
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ func Router() *mux.Router {
|
||||||
r.Handle("/service/{id}", http.HandlerFunc(servicesViewHandler)).Methods("GET")
|
r.Handle("/service/{id}", http.HandlerFunc(servicesViewHandler)).Methods("GET")
|
||||||
r.Handle("/service/{id}/edit", authenticated(servicesViewHandler, true)).Methods("GET")
|
r.Handle("/service/{id}/edit", authenticated(servicesViewHandler, true)).Methods("GET")
|
||||||
r.Handle("/service/{id}/delete_failures", authenticated(servicesDeleteFailuresHandler, true)).Methods("GET")
|
r.Handle("/service/{id}/delete_failures", authenticated(servicesDeleteFailuresHandler, true)).Methods("GET")
|
||||||
|
r.Handle("/service/create", authenticated(createServiceHandler, true)).Methods("GET")
|
||||||
|
|
||||||
r.Handle("/group/{id}", http.HandlerFunc(groupViewHandler)).Methods("GET")
|
r.Handle("/group/{id}", http.HandlerFunc(groupViewHandler)).Methods("GET")
|
||||||
|
|
||||||
|
|
|
@ -335,3 +335,7 @@ func apiServiceHitsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
returnJson(hits, w, r)
|
returnJson(hits, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createServiceHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
ExecuteResponse(w, r, "service_create.gohtml", core.CoreApp, nil)
|
||||||
|
}
|
||||||
|
|
|
@ -129,21 +129,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *webhooker) OnTest() error {
|
func (w *webhooker) OnTest() error {
|
||||||
service := &types.Service{
|
body := replaceBodyText(w.Var2, notifier.ExampleService, nil)
|
||||||
Id: 1,
|
|
||||||
Name: "Interpol - All The Rage Back Home",
|
|
||||||
Domain: "https://www.youtube.com/watch?v=-u6DvRyyKGU",
|
|
||||||
ExpectedStatus: 200,
|
|
||||||
Interval: 30,
|
|
||||||
Type: "http",
|
|
||||||
Method: "GET",
|
|
||||||
Timeout: 20,
|
|
||||||
LastStatusCode: 404,
|
|
||||||
Expected: types.NewNullString("test example"),
|
|
||||||
LastResponse: "<html>this is an example response</html>",
|
|
||||||
CreatedAt: time.Now().Add(-24 * time.Hour),
|
|
||||||
}
|
|
||||||
body := replaceBodyText(w.Var2, service, nil)
|
|
||||||
resp, err := w.sendHttpWebhook(body)
|
resp, err := w.sendHttpWebhook(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -7,10 +7,12 @@
|
||||||
<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"><i class="fa fa-cogs"></i> 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"><i class="fa fa-cogs"></i> Settings</a>
|
||||||
|
<a class="nav-link" id="v-pills-notifications-tab" data-toggle="pill" href="#v-pills-notifications" role="tab" aria-controls="v-pills-notifications" aria-selected="true"><i class="fa fa-cogs"></i> Notifications</a>
|
||||||
|
<h6>Notifiers</h6>
|
||||||
<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"><i class="fa fa-image"></i> 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"><i class="fa fa-image"></i> Theme Editor</a>
|
||||||
<a class="nav-link" id="v-pills-cache-tab" data-toggle="pill" href="#v-pills-cache" role="tab" aria-controls="v-pills-cache" aria-selected="false"><i class="fa fa-paperclip"></i> Cache</a>
|
<a class="nav-link" id="v-pills-cache-tab" data-toggle="pill" href="#v-pills-cache" role="tab" aria-controls="v-pills-cache" aria-selected="false"><i class="fa fa-paperclip"></i> Cache</a>
|
||||||
{{ range .Notifications }}
|
{{ range .Notifications }}
|
||||||
<a class="nav-link text-capitalize" id="v-pills-{{underscore .Select.Method}}-tab" data-toggle="pill" href="#v-pills-{{underscore .Select.Method}}" role="tab" aria-controls="v-pills-{{underscore .Select.Method}}" aria-selected="false"><i class="{{.Select.Icon}}"></i> {{.Select.Method}}</a>
|
<a class="nav-link text-capitalize" id="v-pills-{{underscore .Select.Method}}-tab" data-toggle="pill" href="#v-pills-{{underscore .Select.Method}}" role="tab" aria-controls="v-pills-{{underscore .Select.Method}}" aria-selected="false"><i class="{{.Select.Icon}}"></i> {{.Select.Method}}<span class="badge badge-success float-right">4</span></a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a class="nav-link d-none" id="v-pills-backups-tab" data-toggle="pill" href="#v-pills-backups" role="tab" aria-controls="v-pills-backups" aria-selected="false">Backups</a>
|
<a class="nav-link d-none" id="v-pills-backups-tab" data-toggle="pill" href="#v-pills-backups" role="tab" aria-controls="v-pills-backups" aria-selected="false">Backups</a>
|
||||||
{{ range .Plugins }}
|
{{ range .Plugins }}
|
||||||
|
@ -37,21 +39,6 @@
|
||||||
<input type="text" name="description" class="form-control" value="{{ .Description }}" id="description" placeholder="Great Uptime">
|
<input type="text" name="description" class="form-control" value="{{ .Description }}" id="description" placeholder="Great Uptime">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-4 col-sm-4 mt-sm-1 mt-0">
|
|
||||||
<label for="update_notify" class="d-inline d-sm-none">Send Updates only</label>
|
|
||||||
<label for="update_notify" class="d-none d-sm-block">Send Updates only</label>
|
|
||||||
|
|
||||||
<span class="switch">
|
|
||||||
<input type="checkbox" name="update_notify-option" class="switch" id="switch-update_notify"{{if UPDATENOTIFY}} checked{{end}}>
|
|
||||||
<label for="switch-update_notify" class="mt-2 mt-sm-0"></label>
|
|
||||||
<small class="form-text text-muted">Enabling this will send only notifications when the status of a services changes.</small>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<input type="hidden" name="update_notify" id="switch-update_notify-value" value="{{if UPDATENOTIFY}}true{{else}}false{{end}}">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-8 col-sm-9">
|
<div class="col-8 col-sm-9">
|
||||||
<label for="domain">Domain</label>
|
<label for="domain">Domain</label>
|
||||||
|
@ -172,6 +159,30 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="v-pills-notifications" role="tabpanel" aria-labelledby="v-pills-notifications-tab">
|
||||||
|
<h3>Notifications</h3>
|
||||||
|
|
||||||
|
<form method="POST" action="/settings">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="update_notify" class="d-inline d-sm-none">Send Updates only</label>
|
||||||
|
<label for="update_notify" class="d-none d-sm-block">Send Updates only</label>
|
||||||
|
|
||||||
|
<span class="switch">
|
||||||
|
<input type="checkbox" name="update_notify-option" class="switch" id="switch-update_notify"{{if UPDATENOTIFY}} checked{{end}}>
|
||||||
|
<label for="switch-update_notify" class="mt-2 mt-sm-0"></label>
|
||||||
|
<small class="form-text text-muted">Enabling this will send only notifications when the status of a services changes.</small>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<input type="hidden" name="update_notify" id="switch-update_notify-value" value="{{if UPDATENOTIFY}}true{{else}}false{{end}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-block">Save Settings</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane" id="v-pills-style" role="tabpanel" aria-labelledby="v-pills-style-tab">
|
<div class="tab-pane" id="v-pills-style" role="tabpanel" aria-labelledby="v-pills-style-tab">
|
||||||
|
|
||||||
{{if not .UsingAssets }}
|
{{if not .UsingAssets }}
|
||||||
|
|
Loading…
Reference in New Issue