diff --git a/Makefile b/Makefile index 8f560f62..5a7a26b1 100644 --- a/Makefile +++ b/Makefile @@ -71,10 +71,20 @@ install: build run: build ./$(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: generate 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 # benchmark testing diff --git a/core/notifier/notifiers.go b/core/notifier/notifiers.go index 1de0e1b6..0e3d86ac 100644 --- a/core/notifier/notifiers.go +++ b/core/notifier/notifiers.go @@ -461,3 +461,19 @@ func (n *Notification) IsRunning() bool { 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: "this is an example response", + CreatedAt: time.Now().Add(-24 * time.Hour), +} diff --git a/handlers/routes.go b/handlers/routes.go index bd1ca48e..2c3bce0d 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -92,6 +92,7 @@ func Router() *mux.Router { r.Handle("/service/{id}", http.HandlerFunc(servicesViewHandler)).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/create", authenticated(createServiceHandler, true)).Methods("GET") r.Handle("/group/{id}", http.HandlerFunc(groupViewHandler)).Methods("GET") diff --git a/handlers/services.go b/handlers/services.go index 8873926b..453b9050 100644 --- a/handlers/services.go +++ b/handlers/services.go @@ -335,3 +335,7 @@ func apiServiceHitsHandler(w http.ResponseWriter, r *http.Request) { returnJson(hits, w, r) } + +func createServiceHandler(w http.ResponseWriter, r *http.Request) { + ExecuteResponse(w, r, "service_create.gohtml", core.CoreApp, nil) +} diff --git a/notifiers/webhook.go b/notifiers/webhook.go index c76b69a9..41b1e03a 100644 --- a/notifiers/webhook.go +++ b/notifiers/webhook.go @@ -129,21 +129,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) { } func (w *webhooker) OnTest() error { - service := &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: "this is an example response", - CreatedAt: time.Now().Add(-24 * time.Hour), - } - body := replaceBodyText(w.Var2, service, nil) + body := replaceBodyText(w.Var2, notifier.ExampleService, nil) resp, err := w.sendHttpWebhook(body) if err != nil { return err diff --git a/source/tmpl/settings.gohtml b/source/tmpl/settings.gohtml index 11954288..664789a3 100644 --- a/source/tmpl/settings.gohtml +++ b/source/tmpl/settings.gohtml @@ -7,10 +7,12 @@
-
-
- - - - - - - Enabling this will send only notifications when the status of a services changes. - - - -
-
-
@@ -172,6 +159,30 @@
+
+

Notifications

+ +
+ +
+
+ + + + + + + Enabling this will send only notifications when the status of a services changes. + + + +
+
+ + +
+
+
{{if not .UsingAssets }}