From 7cf324872c7f01b1812302badf7c46d9fd5c87fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 21 Jan 2020 11:57:17 +0200 Subject: [PATCH] Replace the gear icon with three horizontal dots icon. Fixes #322. Add a Pause button in the checks list. Fixes #312 --- CHANGELOG.md | 2 ++ hc/front/tests/test_pause.py | 5 +++++ hc/front/views.py | 4 ++++ static/css/icomoon.css | 10 +++++----- static/css/my_checks_desktop.css | 26 +++++++++++++++++++++++++ static/fonts/icomoon.eot | Bin 12012 -> 12012 bytes static/fonts/icomoon.ttf | Bin 11848 -> 11848 bytes static/fonts/icomoon.woff | Bin 11924 -> 11924 bytes static/js/checks.js | 16 ++++++++++++++- templates/front/my_checks_desktop.html | 10 +++++++--- 10 files changed, 64 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f3d414..545140f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file. - For superusers, show "Site Administration" in top navigation, note in README (#317) - Make Ping.body size limit configurable (#301) - Show sub-second durations with higher precision, 2 digits after decimal point (#321) +- Replace the gear icon with three horizontal dots icon (#322) +- Add a Pause button in the checks list (#312) ### Bug Fixes - Increase the allowable length of Matrix room alias to 100 (#320) diff --git a/hc/front/tests/test_pause.py b/hc/front/tests/test_pause.py index 35176ae1..081d6266 100644 --- a/hc/front/tests/test_pause.py +++ b/hc/front/tests/test_pause.py @@ -44,3 +44,8 @@ class PauseTestCase(BaseTestCase): self.check.refresh_from_db() self.assertEqual(self.check.last_start, None) self.assertEqual(self.check.alert_after, None) + + def test_it_does_not_redirect_ajax(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, HTTP_X_REQUESTED_WITH="XMLHttpRequest") + self.assertEqual(r.status_code, 200) diff --git a/hc/front/views.py b/hc/front/views.py index 3b314f39..93474128 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -428,6 +428,10 @@ def pause(request, code): if "/details/" in request.META.get("HTTP_REFERER", ""): return redirect("hc-details", code) + # Don't redirect after an AJAX request: + if request.META.get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest": + return HttpResponse() + return redirect("hc-checks", check.project.code) diff --git a/static/css/icomoon.css b/static/css/icomoon.css index 992fb4d1..57b353b3 100644 --- a/static/css/icomoon.css +++ b/static/css/icomoon.css @@ -1,10 +1,10 @@ @font-face { font-family: 'icomoon'; - src: url('../fonts/icomoon.eot?jvwv9j'); - src: url('../fonts/icomoon.eot?jvwv9j#iefix') format('embedded-opentype'), - url('../fonts/icomoon.ttf?jvwv9j') format('truetype'), - url('../fonts/icomoon.woff?jvwv9j') format('woff'), - url('../fonts/icomoon.svg?jvwv9j#icomoon') format('svg'); + src: url('../fonts/icomoon.eot?pl16ut'); + src: url('../fonts/icomoon.eot?pl16ut#iefix') format('embedded-opentype'), + url('../fonts/icomoon.ttf?pl16ut') format('truetype'), + url('../fonts/icomoon.woff?pl16ut') format('woff'), + url('../fonts/icomoon.svg?pl16ut#icomoon') format('svg'); font-weight: normal; font-style: normal; } diff --git a/static/css/my_checks_desktop.css b/static/css/my_checks_desktop.css index e507ef4a..cafff8db 100644 --- a/static/css/my_checks_desktop.css +++ b/static/css/my_checks_desktop.css @@ -132,3 +132,29 @@ tr:hover .copy-link { color: #888; white-space: nowrap; } + +#checks-table .actions { + white-space: nowrap; +} + +#checks-table .btn { + border-color: transparent; + font-size: 20px; + color: #999; +} + +#checks-table tr:hover .btn { + color: #666; + background: transparent; + opacity: 1; +} + +#checks-table tr:hover .btn:hover { + background: #DDD; + color: #000; +} + +#checks-table .pause { + opacity: 0; +} + diff --git a/static/fonts/icomoon.eot b/static/fonts/icomoon.eot index ddebca8097762b3f321bbff9c27cbc6ae88ed36d..b5de171af61ff02d4a38bf5d38c0e305b53b0d3d 100644 GIT binary patch delta 56 zcmaD8`zCgR4U2NHGWSG>Ei4iY(n=eDywQ^328zV<+k9oRb0TI!0E+~Jw9>|qH(D~>%E8L<{5D@1xLFuL;FeEzER5b9qy2^n0BIo(4*&oF delta 49 wcmX>Rb0TI!0E>8R5X;7pH(D}08BgQm`E9;3aI-Lgz|G%m=V0{a80|Mq0Ikgt3;+NC diff --git a/static/fonts/icomoon.woff b/static/fonts/icomoon.woff index b3dc9785f9e6c03ba90fbe60349fa625ad48a250..8fb5cbe8299bd7e987eb8f32562ab35c50a2805a 100644 GIT binary patch delta 49 wcmbOdJ0*5P4~qnYw9>{2f3#${m4lVz`E9;3aI-Lgz%8HbSQx!|h4vdJ0BmaxeEiA^V@u7;AUX}ft$bC&cW!-E41G*0RXWV5qbas diff --git a/static/js/checks.js b/static/js/checks.js index ad77a96d..a8c71741 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -138,6 +138,21 @@ $(function () { return false; }); + $(".pause").click(function(e) { + var code = $(this).closest("tr.checks-row").attr("id"); + $("#" + code + " span.status").attr("class", "status icon-paused"); + + var url = base + "/checks/" + code + "/pause/"; + var token = $('input[name=csrfmiddlewaretoken]').val(); + $.ajax({ + url: url, + type: "post", + headers: {"X-CSRFToken": token} + }); + + return false; + }); + $('[data-toggle="tooltip"]').tooltip({ html: true, container: "body", @@ -171,7 +186,6 @@ $(function () { if (lastStatus[el.code] != el.status) { lastStatus[el.code] = el.status; $("#" + el.code + " span.status").attr("class", "status icon-" + el.status); - $("#" + el.code + " .pause-li").toggleClass("disabled", el.status == "paused"); } if (lastPing[el.code] != el.last_ping) { diff --git a/templates/front/my_checks_desktop.html b/templates/front/my_checks_desktop.html index 25e8327a..b2a1d35f 100644 --- a/templates/front/my_checks_desktop.html +++ b/templates/front/my_checks_desktop.html @@ -120,9 +120,13 @@ {% include "front/last_ping_cell.html" with check=check %} - - + +