Browse Source

After adding a new check redirect to the "Check Details" page.

pull/287/head
Pēteris Caune 5 years ago
parent
commit
339ac5e9d9
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
8 changed files with 54 additions and 12 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +8
    -2
      hc/front/tests/test_add_check.py
  3. +5
    -0
      hc/front/tests/test_details.py
  4. +3
    -1
      hc/front/views.py
  5. +8
    -0
      static/css/details.css
  6. +5
    -0
      static/js/details.js
  7. +20
    -8
      templates/front/details.html
  8. +4
    -1
      templates/front/details_events.html

+ 1
- 0
CHANGELOG.md View File

@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- Add the `pruneflips` management command
- Add Mattermost integration (#276)
- Three choices in timezone switcher (UTC / check's timezone / browser's timezone) (#278)
- After adding a new check redirect to the "Check Details" page
## Bug Fixes
- Fix javascript code to construct correct URLs when running from a subdirectory (#273)


+ 8
- 2
hc/front/tests/test_add_check.py View File

@ -12,20 +12,26 @@ class AddCheckTestCase(BaseTestCase):
def test_it_works(self):
self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url)
self.assertRedirects(r, self.redirect_url)
check = Check.objects.get()
self.assertEqual(check.project, self.project)
redirect_url = "/checks/%s/details/?new" % check.code
self.assertRedirects(r, redirect_url)
def test_it_handles_unset_current_project(self):
self.profile.current_project = None
self.profile.save()
self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url)
self.assertRedirects(r, self.redirect_url)
check = Check.objects.get()
self.assertEqual(check.project, self.project)
redirect_url = "/checks/%s/details/?new" % check.code
self.assertRedirects(r, redirect_url)
def test_team_access_works(self):
self.client.login(username="[email protected]", password="password")
self.client.post(self.url)


+ 5
- 0
hc/front/tests/test_details.py View File

@ -43,3 +43,8 @@ class DetailsTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertEqual(r.status_code, 200)
def test_it_shows_new_check_notice(self):
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url + "?new")
self.assertContains(r, "Your new check is ready!", status_code=200)

+ 3
- 1
hc/front/views.py View File

@ -292,7 +292,8 @@ def add_check(request, code):
check.assign_all_channels()
return redirect("hc-checks", code)
url = reverse("hc-details", args=[check.code])
return redirect(url + "?new")
@require_POST
@ -478,6 +479,7 @@ def details(request, code):
"channels": channels,
"timezones": pytz.all_timezones,
"downtimes": check.downtimes(months=3),
"is_new": "new" in request.GET,
}
return render(request, "front/details.html", ctx)


+ 8
- 0
static/css/details.css View File

@ -95,3 +95,11 @@
font-weight: normal;
color: #888;
}
.alert.no-events {
border: #ddd;
background: #F5F5F5;
color: #444;
text-align: center;
padding: 32px;
}

+ 5
- 0
static/js/details.js View File

@ -6,6 +6,11 @@ $(function () {
return false;
});
$("#new-check-alert a").click(function() {
$("#" + this.dataset.target).click();
return false;
});
$("#edit-desc").click(function() {
$('#update-name-modal').modal("show");
$("#update-desc-input").focus();


+ 20
- 8
templates/front/details.html View File

@ -7,6 +7,26 @@
{% block content %}
<div class="row">
{% if is_new %}
<div class="col-sm-12">
<p id="new-check-alert" class="alert alert-success">
<strong>Your new check is ready!</strong>
You can now
<a data-target="edit-name" href="#" >give it a name</a>
or
<a data-target="edit-timeout" href="#" >set its schedule</a>.
</p>
</div>
{% endif %}
{% if messages %}
<div class="col-sm-12">
{% for message in messages %}
<p class="alert alert-{{ message.tags }}">{{ message }}</p>
{% endfor %}
</div>
{% endif %}
<div id="details-head" class="col-sm-12">
<h1>
{{ check.name_then_code }}
@ -18,14 +38,6 @@
{% endfor %}
</div>
{% if messages %}
<div class="col-sm-12">
{% for message in messages %}
<p class="alert alert-{{ message.tags }}">{{ message }}</p>
{% endfor %}
</div>
{% endif %}
<div class="col-sm-5">
<div class="details-block">
<h2>Description</h2>


+ 4
- 1
templates/front/details_events.html View File

@ -91,5 +91,8 @@
<a href="{% url 'hc-log' check.code %}">Show More&hellip;</a>
</p>
{% else %}
<div class="alert alert-info">This check has not received any pings yet.</div>
<div class="alert no-events">
You will see a live-updating log of received pings here. <br />
This check has not received any pings yet.
</div>
{% endif %}

Loading…
Cancel
Save