Skip to content

Commit

Permalink
notifier issue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Dec 19, 2018
1 parent e87f7ca commit 36f8b62
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion core/notifier/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
24 changes: 13 additions & 11 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion source/tmpl/form_notifier.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@

<div class="col-3 col-sm-2 mt-1">
<span class="switch">
<input type="checkbox" name="enabled" class="switch" id="switch-{{ $n.Method }}" {{if $n.Enabled.Bool}}checked{{end}}>
<input type="checkbox" name="enabled-option" class="switch" id="switch-{{ $n.Method }}" {{if $n.Enabled.Bool}}checked{{end}}>
<label for="switch-{{ $n.Method }}"></label>
<input type="hidden" name="enabled" id="switch-{{ $n.Method }}-value" value="{{if $n.Enabled.Bool}}true{{else}}false{{end}}">
</span>
</div>

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.80.31
0.80.32

0 comments on commit 36f8b62

Please sign in to comment.