Browse Source

Checks have a "Description" field. Fixes #182

pull/193/head
Pēteris Caune 6 years ago
parent
commit
7046e2410c
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
10 changed files with 61 additions and 7 deletions
  1. +2
    -1
      CHANGELOG.md
  2. +18
    -0
      hc/api/migrations/0041_check_desc.py
  3. +1
    -0
      hc/api/models.py
  4. +1
    -0
      hc/front/forms.py
  5. +1
    -0
      hc/front/views.py
  6. +10
    -2
      static/css/my_checks.css
  7. +1
    -0
      static/js/checks.js
  8. +9
    -0
      templates/front/details.html
  9. +3
    -2
      templates/front/my_checks_desktop.html
  10. +15
    -2
      templates/front/update_name_modal.html

+ 2
- 1
CHANGELOG.md View File

@ -6,4 +6,5 @@ All notable changes to this project will be documented in this file.
### Improvements
- A new "Check Details" page.
- Updated django-compressor, psycopg2, pytz, requests package versions.
- C# usage example.
- C# usage example.
- Checks have a "Description" field.

+ 18
- 0
hc/api/migrations/0041_check_desc.py View File

@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2018-08-20 14:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0040_auto_20180517_1336'),
]
operations = [
migrations.AddField(
model_name='check',
name='desc',
field=models.TextField(blank=True),
),
]

+ 1
- 0
hc/api/models.py View File

@ -60,6 +60,7 @@ class Check(models.Model):
name = models.CharField(max_length=100, blank=True)
tags = models.CharField(max_length=500, blank=True)
code = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True)
desc = models.TextField(blank=True)
user = models.ForeignKey(User, models.CASCADE, blank=True, null=True)
created = models.DateTimeField(auto_now_add=True)
kind = models.CharField(max_length=10, default="simple",


+ 1
- 0
hc/front/forms.py View File

@ -11,6 +11,7 @@ from hc.front.validators import (CronExpressionValidator, TimezoneValidator,
class NameTagsForm(forms.Form):
name = forms.CharField(max_length=100, required=False)
tags = forms.CharField(max_length=500, required=False)
desc = forms.CharField(required=False)
def clean_tags(self):
result = []


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

@ -209,6 +209,7 @@ def update_name(request, code):
if form.is_valid():
check.name = form.cleaned_data["name"]
check.tags = form.cleaned_data["tags"]
check.desc = form.cleaned_data["desc"]
check.save()
if "/details/" in request.META.get("HTTP_REFERER", ""):


+ 10
- 2
static/css/my_checks.css View File

@ -28,11 +28,15 @@
}
@media (min-width: 992px) {
#update-timeout-modal .modal-dialog, #ping-details-modal .modal-dialog {
#update-timeout-modal .modal-dialog, #ping-details-modal .modal-dialog {
width: 800px;
}
#update-name-modal .modal-dialog {
width: 650px;
}
}
#update-timeout-form .modal-body {
padding-top: 35px;
}
@ -182,4 +186,8 @@
text-align: center;
margin-top: 10px;
font-size: 12px;
}
}
#update-name-modal .modal-body {
padding: 15px 40px;
}

+ 1
- 0
static/js/checks.js View File

@ -7,6 +7,7 @@ $(function () {
$("#update-name-form").attr("action", url);
$("#update-name-input").val(this.dataset.name);
$("#update-tags-input").val(this.dataset.tags);
$("#update-desc-input").val(this.dataset.desc);
$('#update-name-modal').modal("show");
$("#update-name-input").focus();


+ 9
- 0
templates/front/details.html View File

@ -19,6 +19,15 @@
<div class="col-sm-5">
{% if check.desc %}
<div class="details-block">
<h2>Description</h2>
{{ check.desc|linebreaks|urlize }}
</div>
{% endif %}
<div class="details-block">
<h2>How To Ping</h2>
<div>


+ 3
- 2
templates/front/my_checks_desktop.html View File

@ -52,8 +52,9 @@
</td>
<td>
<div data-name="{{ check.name }}"
data-tags="{{ check.tags }}"
class="my-checks-name {% if not check.name %}unnamed{% endif %}">
data-tags="{{ check.tags }}"
data-desc="{{ check.desc }}"
class="my-checks-name {% if not check.name %}unnamed{% endif %}">
<div>{{ check.name|default:"unnamed"|break_underscore }}</div>
{% for tag in check.tags_list %}
<span class="label label-tag">{{ tag }}</span>


+ 15
- 2
templates/front/update_name_modal.html View File

@ -16,7 +16,7 @@
<label for="update-name-input" class="col-sm-2 control-label">
Name
</label>
<div class="col-sm-9">
<div class="col-sm-10">
<input
id="update-name-input"
name="name"
@ -36,7 +36,7 @@
<label for="update-tags-input" class="col-sm-2 control-label">
Tags
</label>
<div class="col-sm-9">
<div class="col-sm-10">
<input
id="update-tags-input"
name="tags"
@ -51,6 +51,19 @@
</span>
</div>
</div>
<div class="form-group">
<label for="update-desc-input" class="col-sm-2 control-label">
Description
</label>
<div class="col-sm-10">
<textarea
id="update-desc-input"
class="form-control"
rows="5"
name="desc">{{ check.desc }}</textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>


Loading…
Cancel
Save