From 639249a3950ff443ad894b8f78f04cf68b796172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 11 Jun 2018 12:02:00 +0300 Subject: [PATCH] /checks/status/ sends smaller payload. --- static/css/my_checks_desktop.css | 3 +-- static/js/checks.js | 26 ++++++++++++++++++-------- templates/front/last_ping_cell.html | 12 +++++------- templates/front/my_checks_desktop.html | 21 +++++++++++---------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/static/css/my_checks_desktop.css b/static/css/my_checks_desktop.css index 58ff8031..710a86d2 100644 --- a/static/css/my_checks_desktop.css +++ b/static/css/my_checks_desktop.css @@ -35,8 +35,7 @@ #checks-table .my-checks-name, #checks-table .integrations, #checks-table .timeout-grace, -#checks-table .last-ping, -#checks-table .last-ping-never { +#checks-table .last-ping { border: 1px solid rgba(0, 0, 0, 0); padding: 6px; } diff --git a/static/js/checks.js b/static/js/checks.js index 39612c58..f9237fe8 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -188,13 +188,21 @@ $(function () { return false; }); - $(".last-ping-cell").on("click", ".last-ping", function() { + $(".last-ping").on("click", function() { + if (this.innerText == "Never") { + showUsage(this); + return false; + } + $("#ping-details-body").text("Updating..."); $('#ping-details-modal').modal("show"); + var code = $(this).closest("tr").data("code"); + var url = "/checks/" + code + "/last_ping/"; + var token = $('input[name=csrfmiddlewaretoken]').val(); $.ajax({ - url: this.dataset.url, + url: url, type: "post", headers: {"X-CSRFToken": token}, success: function(data) { @@ -270,15 +278,17 @@ $(function () { } }); - $(".usage-examples").click(function(e) { - var a = e.target; - var url = a.getAttribute("data-url"); - var email = a.getAttribute("data-email"); + function showUsage(el) { + var tr = $(el).closest("tr"); - $(".ex", "#show-usage-modal").text(url); - $(".em", "#show-usage-modal").text(email); + $(".ex", "#show-usage-modal").text(tr.data("url")); + $(".em", "#show-usage-modal").text(tr.data("email")); $("#show-usage-modal").modal("show"); + } + + $(".usage-examples").click(function(e) { + showUsage(e.target); return false; }); diff --git a/templates/front/last_ping_cell.html b/templates/front/last_ping_cell.html index e712098f..88453940 100644 --- a/templates/front/last_ping_cell.html +++ b/templates/front/last_ping_cell.html @@ -1,12 +1,10 @@ {% load humanize %} {% if check.last_ping %} -
- {{ check.last_ping|naturaltime }} - {% if check.has_confirmation_link %} -
confirmation link - {% endif %} -
+ {{ check.last_ping|naturaltime }} + {% if check.has_confirmation_link %} +
confirmation link + {% endif %} {% else %} -
Never
+ Never {% endif %} \ No newline at end of file diff --git a/templates/front/my_checks_desktop.html b/templates/front/my_checks_desktop.html index 09a287ea..500577a6 100644 --- a/templates/front/my_checks_desktop.html +++ b/templates/front/my_checks_desktop.html @@ -41,7 +41,12 @@ {% for check in checks %} - + + {% if check.in_grace_period %} @@ -108,8 +113,10 @@ - - {% include "front/last_ping_cell.html" with check=check %} + +
+ {% include "front/last_ping_cell.html" with check=check %} +