From 36f8b6214adb7c470e482393e50afae8117d0193 Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Wed, 19 Dec 2018 10:19:14 -0800 Subject: [PATCH] notifier issue fixes --- .travis.yml | 3 --- Makefile | 4 ++-- core/notifier/notifiers.go | 6 +++++- source/js/main.js | 24 +++++++++++++----------- source/tmpl/form_notifier.gohtml | 3 ++- version.txt | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b831dd0..585d8b5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,6 @@ before_deploy: - git config --local user.email "info@socialeck.com" - make tag -after_deploy: - - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then make publish-homebrew; fi - matrix: allow_failures: - go: master diff --git a/Makefile b/Makefile index 4353f8bc..a0aceaad 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,12 @@ BUILDVERSION=-ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT RICE=$(GOPATH)/bin/rice PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH) PUBLISH_BODY='{ "request": { "branch": "master", "config": { "env": { "VERSION": "${VERSION}", "COMMIT": "$(TRAVIS_COMMIT)" } } } }' -TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "os": [ "linux" ], "language": "go", "go": [ "1.10.x" ], "go_import_path": "github.com/hunterlong/statping", "install": true, "sudo": "required", "services": [ "docker" ], "env": { "VERSION": "${VERSION}" }, "matrix": { "allow_failures": [ { "go": "master" } ], "fast_finish": true }, "before_deploy": [ "git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [ { "provider": "releases", "api_key": "$(GH_TOKEN)", "file_glob": true, "file": "build/*", "skip_cleanup": true } ], "notifications": { "email": false }, "before_script": ["gem install sass"], "script": [ "wget -O statping.gpg $(SIGN_URL)", "gpg --import statping.gpg", "travis_wait 30 docker pull karalabe/xgo-latest", "make release" ], "after_success": [], "after_deploy": [ "make publish-dev" ] } } }' +TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "os": [ "linux" ], "language": "go", "go": [ "1.10.x" ], "go_import_path": "github.com/hunterlong/statping", "install": true, "sudo": "required", "services": [ "docker" ], "env": { "VERSION": "${VERSION}" }, "matrix": { "allow_failures": [ { "go": "master" } ], "fast_finish": true }, "before_deploy": [ "git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [ { "provider": "releases", "api_key": "$(GH_TOKEN)", "file_glob": true, "file": "build/*", "skip_cleanup": true } ], "notifications": { "email": false }, "before_script": ["gem install sass"], "script": [ "wget -O statping.gpg $(SIGN_URL)", "gpg --import statping.gpg", "travis_wait 30 docker pull karalabe/xgo-latest", "make release" ], "after_success": [], "after_deploy": [ "make publish-homebrew" ] } } }' TEST_DIR=$(GOPATH)/src/github.com/hunterlong/statping PATH:=$(PATH) # build all arch's and release Statping -release: dev-deps build-all travis-build +release: dev-deps build-all # build and push the images to docker hub docker: docker-build-all docker-publish-all diff --git a/core/notifier/notifiers.go b/core/notifier/notifiers.go index bb2027bc..a5bb0eb4 100644 --- a/core/notifier/notifiers.go +++ b/core/notifier/notifiers.go @@ -300,7 +300,11 @@ CheckNotifier: utils.Log(2, fmt.Sprintf("notifier %v had an error: %v", notification.Method, err)) } notification.makeLog(msg.Data) - notification.Queue = notification.Queue[1:] + if len(notification.Queue) > 1 { + notification.Queue = notification.Queue[1:] + } else { + notification.Queue = nil + } rateLimit = notification.Delay } } diff --git a/source/js/main.js b/source/js/main.js index 07505c49..2d1df812 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -27,7 +27,7 @@ $('.test_notifier').on('click', function(e) { var btn = $(this); var form = $(this).parents('form:first'); var values = form.serialize(); - var notifier = form.find('input[name=notifier]').val(); + var notifier = form.find('input[name=method]').val(); var success = $('#'+notifier+'-success'); var error = $('#'+notifier+'-error'); Spinner(btn); @@ -72,7 +72,6 @@ function Spinner(btn, off = false) { } function SaveNotifier(data) { - console.log(data) let button = data.element.find('button[type=submit]'); button.text('Saved!') button.removeClass('btn-primary') @@ -124,6 +123,11 @@ function AjaxChart(chart, service, start=0, end=9999999999, group="hour") { }); } +$('input[type=checkbox]').on('change', function() { + var element = $(this).attr('id'); + $("#"+element+"-value").val(this.checked ? "true" : "false") +}); + function PingAjaxChart(chart, service, start=0, end=9999999999, group="hour") { $.ajax({ url: "/api/services/"+service+"/ping?start="+start+"&end="+end+"&group="+group, @@ -190,37 +194,35 @@ $('form.ajax_form').on('submit', function() { let alerter = form.find('#alerter'); var arrayData = []; let newArr = {}; - console.log(values); Spinner(button); values.forEach(function(k, v) { - if (k.name === "password_confirm" || k.value === "") { + if (k.name === "password_confirm" || k.value === "" || k.name === "enabled-option") { return } if (k.value === "on") { k.value = (k.value === "on") } - if (k.value === "false") { - k.value = false - } - if (k.value === "true") { - k.value = true + if (k.value === "false" || k.value === "true") { + k.value = (k.value === "true") } if($.isNumeric(k.value)){ if (k.name !== "password") { k.value = parseInt(k.value) } } + if (k.name === "var1" || k.name === "var2" || k.name === "host" || k.name === "username" || k.name === "password" || k.name === "api_key" || k.name === "api_secret") { + k.value = k.value.toString() + } newArr[k.name] = k.value; arrayData.push(newArr) }); let sendData = JSON.stringify(newArr); - console.log('sending '+method.toUpperCase()+' '+action+':', newArr); + // console.log('sending '+method.toUpperCase()+' '+action+':', sendData); $.ajax({ url: action, type: method, data: sendData, success: function (data) { - console.log(data) setTimeout(function () { if (data.status === 'error') { let alerter = form.find('#alerter'); diff --git a/source/tmpl/form_notifier.gohtml b/source/tmpl/form_notifier.gohtml index a9d4c336..33631e5d 100644 --- a/source/tmpl/form_notifier.gohtml +++ b/source/tmpl/form_notifier.gohtml @@ -33,8 +33,9 @@
- + +
diff --git a/version.txt b/version.txt index b515dcd8..8342a762 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.80.31 \ No newline at end of file +0.80.32 \ No newline at end of file