Checks have a "Description" field. Fixes #182

This commit is contained in:
Pēteris Caune 2018-08-20 18:16:00 +03:00
parent 0a50962f2b
commit 7046e2410c
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
10 changed files with 61 additions and 7 deletions

View File

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

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),
),
]

View File

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

View File

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

View File

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

View File

@ -31,7 +31,11 @@
#update-timeout-modal .modal-dialog, #ping-details-modal .modal-dialog { #update-timeout-modal .modal-dialog, #ping-details-modal .modal-dialog {
width: 800px; width: 800px;
} }
#update-name-modal .modal-dialog {
width: 650px;
} }
}
#update-timeout-form .modal-body { #update-timeout-form .modal-body {
padding-top: 35px; padding-top: 35px;
@ -183,3 +187,7 @@
margin-top: 10px; margin-top: 10px;
font-size: 12px; font-size: 12px;
} }
#update-name-modal .modal-body {
padding: 15px 40px;
}

View File

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

View File

@ -19,6 +19,15 @@
<div class="col-sm-5"> <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"> <div class="details-block">
<h2>How To Ping</h2> <h2>How To Ping</h2>
<div> <div>

View File

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

View File

@ -16,7 +16,7 @@
<label for="update-name-input" class="col-sm-2 control-label"> <label for="update-name-input" class="col-sm-2 control-label">
Name Name
</label> </label>
<div class="col-sm-9"> <div class="col-sm-10">
<input <input
id="update-name-input" id="update-name-input"
name="name" name="name"
@ -36,7 +36,7 @@
<label for="update-tags-input" class="col-sm-2 control-label"> <label for="update-tags-input" class="col-sm-2 control-label">
Tags Tags
</label> </label>
<div class="col-sm-9"> <div class="col-sm-10">
<input <input
id="update-tags-input" id="update-tags-input"
name="tags" name="tags"
@ -51,6 +51,19 @@
</span> </span>
</div> </div>
</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>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>