Skip to content

Commit

Permalink
Merge a1b29b9 into cd93db4
Browse files Browse the repository at this point in the history
  • Loading branch information
ProberI committed Apr 4, 2017
2 parents cd93db4 + a1b29b9 commit 54933ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 39 deletions.
6 changes: 1 addition & 5 deletions hc/front/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ class NameTagsForm(forms.Form):

def clean_tags(self):
l = []

for part in self.cleaned_data["tags"].split(" "):
part = part.strip()
if part != "":
l.append(part)

return " ".join(l)


class TimeoutForm(forms.Form):
timeout = forms.IntegerField(min_value=60, max_value=2592000)
grace = forms.IntegerField(min_value=60, max_value=2592000)
grace = forms.IntegerField(min_value=60, max_value=7776000)


class AddChannelForm(forms.ModelForm):

class Meta:
model = Channel
fields = ['kind', 'value']
Expand All @@ -35,7 +32,6 @@ def clean_value(self):

class AddWebhookForm(forms.Form):
error_css_class = "has-error"

value_down = forms.URLField(max_length=1000, required=False)
value_up = forms.URLField(max_length=1000, required=False)

Expand Down
8 changes: 5 additions & 3 deletions hc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import dj_database_url
import django
import os
import warnings
import sendgrid
Expand Down Expand Up @@ -80,6 +81,7 @@
WSGI_APPLICATION = 'hc.wsgi.application'
TEST_RUNNER = 'hc.api.tests.CustomRunner'


# Default database engine is SQLite. So one can just check out code,
# install requirements.txt and do manage.py runserver and it works
DATABASES = {
Expand Down Expand Up @@ -149,15 +151,15 @@
PUSHBULLET_CLIENT_ID = None
PUSHBULLET_CLIENT_SECRET = None

# # Allow all host hosts/domain names for this site
# Allow all host hosts/domain names for this site
ALLOWED_HOSTS = ['healthchecks-bau.herokuapp.com']

# Parse database configuration from $DATABASE_URL
# # Parse database configuration from $DATABASE_URL
DATABASE_URL = 'postgresql:///postgresql'
DATABASES = {'default': dj_database_url.config(default=DATABASE_URL)}

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

EMAIL_BACKEND = "sgbackend.SendGridBackend"
SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dj-database-url==0.4.2
dj-static==0.0.6
Django==1.10
django-appconf==1.0.1
django-calm-cache==0.9.2
django-compressor==2.1
django-ses-backend==0.1.1
django-toolbelt==0.0.1
Expand Down
43 changes: 12 additions & 31 deletions static/js/checks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
$(function () {

var MINUTE = {name: "minute", nsecs: 60};
var HOUR = {name: "hour", nsecs: MINUTE.nsecs * 60};
var DAY = {name: "day", nsecs: HOUR.nsecs * 24};
var WEEK = {name: "week", nsecs: DAY.nsecs * 7};
var UNITS = [WEEK, DAY, HOUR, MINUTE];
var MONTH = {name: "month", nsecs: DAY.nsecs * 30};
var UNITS = [MONTH, WEEK, DAY, HOUR, MINUTE];

var secsToText = function(total) {
var remainingSeconds = Math.floor(total);
Expand All @@ -14,19 +15,15 @@ $(function () {
// Say "8 days" instead of "1 week 1 day"
continue
}

var count = Math.floor(remainingSeconds / unit.nsecs);
remainingSeconds = remainingSeconds % unit.nsecs;

if (count == 1) {
result += "1 " + unit.name + " ";
}

if (count > 1) {
result += count + " " + unit.name + "s ";
}
}

return result;
}

Expand Down Expand Up @@ -58,21 +55,24 @@ $(function () {
$("#update-timeout-timeout").val(rounded);
});


var graceSlider = document.getElementById("grace-slider");
noUiSlider.create(graceSlider, {
start: [20],
connect: "lower",
range: {
'min': [60, 60],
'33%': [3600, 3600],
'66%': [86400, 86400],
'83%': [604800, 604800],
'max': 2592000,
'14%': [3600, 3600],
'28%': [43200, 43200],
'42%': [86400, 86400],
'56%': [604800, 604800],
'70%': [2592000, 2592000],
'84%': [5184000, 5184000],
'max': 7776000,
},

pips: {
mode: 'values',
values: [60, 1800, 3600, 43200, 86400, 604800, 2592000],
values: [60, 3600, 43200, 86400, 604800, 2592000, 5184000, 7776000],
density: 4,
format: {
to: secsToText,
Expand All @@ -86,55 +86,43 @@ $(function () {
$("#grace-slider-value").text(secsToText(rounded));
$("#update-timeout-grace").val(rounded);
});


$('[data-toggle="tooltip"]').tooltip();

$(".my-checks-name").click(function() {
var $this = $(this);

$("#update-name-form").attr("action", $this.data("url"));
$("#update-name-input").val($this.data("name"));
$("#update-tags-input").val($this.data("tags"));
$('#update-name-modal').modal("show");
$("#update-name-input").focus();

return false;
});

$(".timeout-grace").click(function() {
var $this = $(this);

$("#update-timeout-form").attr("action", $this.data("url"));
periodSlider.noUiSlider.set($this.data("timeout"))
graceSlider.noUiSlider.set($this.data("grace"))
$('#update-timeout-modal').modal({"show":true, "backdrop":"static"});

return false;
});

$(".check-menu-remove").click(function() {
var $this = $(this);

$("#remove-check-form").attr("action", $this.data("url"));
$(".remove-check-name").text($this.data("name"));
$('#remove-check-modal').modal("show");

return false;
});


$("#my-checks-tags button").click(function() {
// .active has not been updated yet by bootstrap code,
// so cannot use it
$(this).toggleClass('checked');

// Make a list of currently checked tags:
var checked = [];
$("#my-checks-tags button.checked").each(function(index, el) {
checked.push(el.textContent);
});

// No checked tags: show all
if (checked.length == 0) {
$("#checks-table tr.checks-row").show();
Expand All @@ -150,15 +138,13 @@ $(function () {
return;
}
}

$(element).show();
}

// Desktop: for each row, see if it needs to be shown or hidden
$("#checks-table tr.checks-row").each(applyFilters);
// Mobile: for each list item, see if it needs to be shown or hidden
$("#checks-list > li").each(applyFilters);

});

$(".pause-check").click(function(e) {
Expand All @@ -167,20 +153,16 @@ $(function () {
return false;
});


$(".usage-examples").click(function(e) {
var a = e.target;
var url = a.getAttribute("data-url");
var email = a.getAttribute("data-email");

$(".ex", "#show-usage-modal").text(url);
$(".em", "#show-usage-modal").text(email);

$("#show-usage-modal").modal("show");
return false;
});


var clipboard = new Clipboard('button.copy-link');
$("button.copy-link").mouseout(function(e) {
setTimeout(function() {
Expand All @@ -198,5 +180,4 @@ $(function () {
prompt("Press Ctrl+C to select:", text)
});


});

0 comments on commit 54933ec

Please sign in to comment.