From 218d0c6873e9a7094768ed7e61ab5700c7174853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sun, 18 Mar 2018 15:54:57 +0200 Subject: [PATCH] Remove Check.last_ping_body field. CSS tweaks for the "Ping Details" modal. --- .../0039_remove_check_last_ping_body.py | 19 +++++++++ hc/api/models.py | 1 - hc/front/tests/test_ping_details.py | 3 +- static/css/log.css | 4 ++ static/css/my_checks.css | 2 +- templates/front/log.html | 4 +- templates/front/ping_details.html | 40 +++++++++++++++---- 7 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 hc/api/migrations/0039_remove_check_last_ping_body.py diff --git a/hc/api/migrations/0039_remove_check_last_ping_body.py b/hc/api/migrations/0039_remove_check_last_ping_body.py new file mode 100644 index 00000000..2a019462 --- /dev/null +++ b/hc/api/migrations/0039_remove_check_last_ping_body.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2018-03-18 13:33 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0038_auto_20180318_1306'), + ] + + operations = [ + migrations.RemoveField( + model_name='check', + name='last_ping_body', + ), + ] diff --git a/hc/api/models.py b/hc/api/models.py index 6ee99d6e..8cb7fde1 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -70,7 +70,6 @@ class Check(models.Model): tz = models.CharField(max_length=36, default="UTC") n_pings = models.IntegerField(default=0) last_ping = models.DateTimeField(null=True, blank=True) - last_ping_body = models.CharField(max_length=10000, blank=True) has_confirmation_link = models.BooleanField(default=False) alert_after = models.DateTimeField(null=True, blank=True, editable=False) status = models.CharField(max_length=6, choices=STATUSES, default="new") diff --git a/hc/front/tests/test_ping_details.py b/hc/front/tests/test_ping_details.py index 52e8c990..9d372499 100644 --- a/hc/front/tests/test_ping_details.py +++ b/hc/front/tests/test_ping_details.py @@ -21,10 +21,9 @@ class LastPingTestCase(BaseTestCase): def test_it_accepts_n(self): check = Check(user=self.alice) - check.last_ping_body = "this is body" check.save() - # remote_addr, scheme, method, ua, body): + # remote_addr, scheme, method, ua, body: check.ping("1.2.3.4", "http", "post", "tester", "foo-123") check.ping("1.2.3.4", "http", "post", "tester", "bar-456") diff --git a/static/css/log.css b/static/css/log.css index c157e40f..211bd758 100644 --- a/static/css/log.css +++ b/static/css/log.css @@ -43,6 +43,10 @@ font-size: 11px; } +#log td.actions { + white-space: nowrap; +} + #log .ok { color: #5cb85c; } diff --git a/static/css/my_checks.css b/static/css/my_checks.css index 861acc8a..06795d9a 100644 --- a/static/css/my_checks.css +++ b/static/css/my_checks.css @@ -18,7 +18,7 @@ } @media (min-width: 992px) { - #update-timeout-modal .modal-dialog, #last-ping-modal .modal-dialog { + #update-timeout-modal .modal-dialog, #ping-details-modal .modal-dialog { width: 800px; } } diff --git a/templates/front/log.html b/templates/front/log.html index b3f83927..df14e275 100644 --- a/templates/front/log.html +++ b/templates/front/log.html @@ -68,7 +68,7 @@ {{ event.ua }} - + {% if event.body %} show body {% endif %} @@ -86,7 +86,7 @@ - + {% if event.channel.kind == "email" %} Sent email alert to {{ event.channel.value }} {% elif event.channel.kind == "slack" %} diff --git a/templates/front/ping_details.html b/templates/front/ping_details.html index 1dc8fc90..811884b4 100644 --- a/templates/front/ping_details.html +++ b/templates/front/ping_details.html @@ -7,23 +7,49 @@ Time Received {{ ping.created.isoformat }}

+ + {% if ping.remote_addr %} +

- Source - {% if ping.scheme == "email" %} - {{ ping.ua }} - {% else %} - {{ ping.scheme|upper }} {{ ping.method }} from {{ ping.remote_addr }} - {% endif %} + Client IP + {{ ping.remote_addr }}

+
+ {% endif %} + {% if ping.scheme %} +
+

+ Protocol + {{ ping.scheme }} +

- {% if ping.scheme != "email" %} + {% endif %} + + {% if ping.method %}
+

+ Method + {{ ping.method }} +

+
+ {% endif %} + + {% if ping.scheme == "email" %} +
+

+ From + {{ ping.ua }} +

+
+ {% else %} +

User Agent {{ ping.ua }}

+ {% endif %} {% if ping.body %}