diff --git a/core/checker.go b/core/checker.go index f23bfae8..3e4b8b7b 100644 --- a/core/checker.go +++ b/core/checker.go @@ -164,9 +164,11 @@ func (s *Service) checkHttp(record bool) *Service { return s } defer response.Body.Close() + contents, err := ioutil.ReadAll(response.Body) + s.LastResponse = string(contents) + s.LastStatusCode = response.StatusCode if s.Expected != "" { - contents, err := ioutil.ReadAll(response.Body) if err != nil { utils.Log(2, err) } @@ -175,8 +177,6 @@ func (s *Service) checkHttp(record bool) *Service { utils.Log(2, err) } if !match { - s.LastResponse = string(contents) - s.LastStatusCode = response.StatusCode if record { recordFailure(s, fmt.Sprintf("HTTP Response Body did not match '%v'", s.Expected)) } @@ -184,14 +184,11 @@ func (s *Service) checkHttp(record bool) *Service { } } if s.ExpectedStatus != response.StatusCode { - //s.LastResponse = string(contents) - s.LastStatusCode = response.StatusCode if record { recordFailure(s, fmt.Sprintf("HTTP Status Code %v did not match %v", response.StatusCode, s.ExpectedStatus)) } return s } - s.LastStatusCode = response.StatusCode s.Online = true if record { recordSuccess(s) diff --git a/core/notifier/notifiers.go b/core/notifier/notifiers.go index e96c7610..50d3ebe7 100644 --- a/core/notifier/notifiers.go +++ b/core/notifier/notifiers.go @@ -358,11 +358,6 @@ func (n *Notification) GetValue(dbField string) string { return "" } -// Testable returns true if it includes the CoreEvents interface -func (n *Notification) Testable() bool { - return isType(n, new(Tester)) -} - // isType will return true if a variable can implement an interface func isType(n interface{}, obj interface{}) bool { one := reflect.TypeOf(n) diff --git a/notifiers/slack.go b/notifiers/slack.go index 7671a1a4..18e40b59 100644 --- a/notifiers/slack.go +++ b/notifiers/slack.go @@ -52,6 +52,7 @@ var slacker = &Slack{¬ifier.Notification{ Placeholder: "Insert your Slack webhook URL here.", SmallText: "Incoming Webhook URL from Slack Apps", DbField: "Host", + Required: true, }}}, } diff --git a/notifiers/slack_test.go b/notifiers/slack_test.go index 8e5cb3fb..ae366232 100644 --- a/notifiers/slack_test.go +++ b/notifiers/slack_test.go @@ -108,7 +108,7 @@ func TestSlackNotifier(t *testing.T) { t.Run("Slack Queue", func(t *testing.T) { go notifier.Queue(slacker) - time.Sleep(2 * time.Second) + time.Sleep(4 * time.Second) assert.Equal(t, SLACK_URL, slacker.Host) assert.Equal(t, 0, len(slacker.Queue)) }) diff --git a/notifiers/twilio.go b/notifiers/twilio.go index 625955a2..5d7df52f 100644 --- a/notifiers/twilio.go +++ b/notifiers/twilio.go @@ -45,21 +45,25 @@ var twilioNotifier = &twilio{¬ifier.Notification{ Title: "Account Sid", Placeholder: "Insert your Twilio Account Sid", DbField: "api_key", + Required: true, }, { Type: "text", Title: "Account Token", Placeholder: "Insert your Twilio Account Token", DbField: "api_secret", + Required: true, }, { Type: "text", Title: "SMS to Phone Number", Placeholder: "18555555555", DbField: "Var1", + Required: true, }, { Type: "text", Title: "From Phone Number", Placeholder: "18555555555", DbField: "Var2", + Required: true, }}}, } @@ -95,9 +99,11 @@ func (u *twilio) Send(msg interface{}) error { } defer res.Body.Close() contents, _ := ioutil.ReadAll(res.Body) - success, twilioRes := twilioSuccess(contents) + success, _ := twilioSuccess(contents) if !success { - return errors.New(fmt.Sprintf("Twilio didn't receive the expected status of 'enque' from API got: %v", twilioRes)) + errorOut := twilioError(contents) + out := fmt.Sprintf("Error code %v - %v", errorOut.Code, errorOut.Message) + return errors.New(out) } return nil } @@ -127,6 +133,12 @@ func (u *twilio) OnSave() error { return nil } +// OnTest will test the Twilio SMS messaging +func (u *twilio) OnTest() error { + msg := fmt.Sprintf("Testing the Twilio SMS Notifier") + return u.Send(msg) +} + func twilioSuccess(res []byte) (bool, TwilioResponse) { var obj TwilioResponse json.Unmarshal(res, &obj) @@ -136,6 +148,19 @@ func twilioSuccess(res []byte) (bool, TwilioResponse) { return false, obj } +func twilioError(res []byte) TwilioError { + var obj TwilioError + json.Unmarshal(res, &obj) + return obj +} + +type TwilioError struct { + Code int `json:"code"` + Message string `json:"message"` + MoreInfo string `json:"more_info"` + Status int `json:"status"` +} + type TwilioResponse struct { Sid string `json:"sid"` DateCreated string `json:"date_created"` diff --git a/notifiers/twilio_test.go b/notifiers/twilio_test.go index 452e16db..3e0b7990 100644 --- a/notifiers/twilio_test.go +++ b/notifiers/twilio_test.go @@ -44,7 +44,6 @@ func init() { } func TestTwilioNotifier(t *testing.T) { - t.SkipNow() t.Parallel() if TWILIO_SID == "" || TWILIO_SECRET == "" || TWILIO_FROM == "" { t.Log("twilio notifier testing skipped, missing TWILIO_SID environment variable") @@ -73,7 +72,7 @@ func TestTwilioNotifier(t *testing.T) { t.Run("Twilio OnFailure", func(t *testing.T) { twilioNotifier.OnFailure(TestService, TestFailure) - assert.Len(t, twilioNotifier.Queue, 2) + assert.Len(t, twilioNotifier.Queue, 1) }) t.Run("Twilio Check Offline", func(t *testing.T) { @@ -82,7 +81,7 @@ func TestTwilioNotifier(t *testing.T) { t.Run("Twilio OnSuccess", func(t *testing.T) { twilioNotifier.OnSuccess(TestService) - assert.Len(t, twilioNotifier.Queue, 3) + assert.Len(t, twilioNotifier.Queue, 2) }) t.Run("Twilio Check Back Online", func(t *testing.T) { @@ -91,7 +90,7 @@ func TestTwilioNotifier(t *testing.T) { t.Run("Twilio OnSuccess Again", func(t *testing.T) { twilioNotifier.OnSuccess(TestService) - assert.Len(t, twilioNotifier.Queue, 3) + assert.Len(t, twilioNotifier.Queue, 2) }) t.Run("Twilio Send", func(t *testing.T) { diff --git a/source/css/base.css b/source/css/base.css index 39c640f1..993b63ec 100644 --- a/source/css/base.css +++ b/source/css/base.css @@ -145,6 +145,11 @@ HTML, BODY { height: 170px; width: 100%; } +.service-chart-container { + position: relative; + height: 400px; + width: 100%; } + .btn-primary { background-color: #3e9bff; border-color: #006fe6; @@ -688,6 +693,9 @@ HTML, BODY { border-bottom-left-radius: 0; } .list-group-item P { - font-size: 0.7rem; } } + font-size: 0.7rem; } + + .service-chart-container { + height: 200px; } } /*# sourceMappingURL=base.css.map */ diff --git a/source/scss/base.scss b/source/scss/base.scss index c098579e..583fa975 100644 --- a/source/scss/base.scss +++ b/source/scss/base.scss @@ -148,9 +148,15 @@ HTML,BODY { } .chart-container { - position: relative; - height: 170px; - width: 100%; + position: relative; + height: 170px; + width: 100%; +} + +.service-chart-container { + position: relative; + height: 400px; + width: 100%; } @mixin dynamic-color-hov($color) { diff --git a/source/scss/mobile.scss b/source/scss/mobile.scss index 83ff146a..29c4dad0 100644 --- a/source/scss/mobile.scss +++ b/source/scss/mobile.scss @@ -96,4 +96,8 @@ .list-group-item P { font-size: 0.7rem; } + + .service-chart-container { + height: 200px; + } } diff --git a/source/tmpl/login.html b/source/tmpl/login.html index 57e1a098..5fea4b59 100644 --- a/source/tmpl/login.html +++ b/source/tmpl/login.html @@ -19,7 +19,9 @@