mirror of
https://github.com/MOIS3Y/logs-collector.git
synced 2025-02-01 01:10:52 +01:00
Add: token field to template, forms
This commit is contained in:
parent
cc7043f013
commit
02906554dd
@ -10,7 +10,7 @@ class TicketForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Ticket
|
||||
fields = ['number', 'platform', 'note']
|
||||
fields = ['number', 'attempts', 'platform', 'note']
|
||||
widgets = {
|
||||
'platform': forms.RadioSelect()
|
||||
}
|
||||
@ -21,7 +21,11 @@ class TicketForm(forms.ModelForm):
|
||||
# self.helper.attrs = {"novalidate": ''}
|
||||
|
||||
self.helper.layout = Layout(
|
||||
Div(FloatingField('number'), 'platform', css_class='col-lg-2'),
|
||||
Div(
|
||||
FloatingField('number', 'attempts'),
|
||||
'platform',
|
||||
css_class='col-lg-2'
|
||||
),
|
||||
Div('note', css_class='col-lg-6'),
|
||||
Submit('submit', 'Save', css_class='btn btn-primary'),
|
||||
)
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2 on 2023-08-08 17:08
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('collector', '0006_remove_archive_token_remove_archive_user_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='ticket',
|
||||
old_name='upload',
|
||||
new_name='attempts',
|
||||
),
|
||||
]
|
@ -75,7 +75,7 @@ class Ticket(models.Model):
|
||||
token = models.UUIDField(default=uuid.uuid4, editable=False)
|
||||
attempts = models.IntegerField(default=5, validators=[
|
||||
MaxValueValidator(10),
|
||||
MinValueValidator(1)
|
||||
MinValueValidator(0)
|
||||
])
|
||||
time_create = models.DateTimeField(auto_now_add=True)
|
||||
time_update = models.DateTimeField(auto_now=True)
|
||||
|
@ -93,4 +93,18 @@ $(function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
// copy token to clipboard:
|
||||
// -- -- -- -- -- -- -- --
|
||||
$(".token-clipboard").click(function (e) {
|
||||
e.preventDefault();
|
||||
const btn = $(this)
|
||||
const tokenInput = btn.siblings("input[name=ticket-token]").val();
|
||||
const icon = btn.children(":first").get(0)
|
||||
navigator.clipboard.writeText(tokenInput);
|
||||
btn.html('<i class="bi bi-check-lg"></i>')
|
||||
// Revert button label after 500 milliseconds
|
||||
setTimeout(function(){
|
||||
btn.html(icon);
|
||||
}, 500)
|
||||
});
|
||||
});
|
||||
|
@ -16,4 +16,34 @@
|
||||
<div class="col-xl-6 mb-2">
|
||||
<h6 class="card-title mb-1">Platform: {{ ticket.platform.pretty_name }}</h6>
|
||||
<h6 class="card-title mb-3">Owner: {{ ticket.user.username }}</h6>
|
||||
<!-- Token -->
|
||||
<div class="input-group input-group mb-3">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm"><i class="bi bi-key"></i></span>
|
||||
<!--Token attempts-->
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">
|
||||
<span
|
||||
class="badge
|
||||
{% if ticket.attempts <= 0 %}
|
||||
bg-danger
|
||||
{% elif ticket.attempts < 5 %}
|
||||
text-dark bg-warning
|
||||
{% else %}
|
||||
bg-primary
|
||||
{% endif %} rounded-pill">{{ ticket.attempts }}
|
||||
</span>
|
||||
</span>
|
||||
<input
|
||||
name="ticket-token"
|
||||
class="form-control"
|
||||
type="text"
|
||||
value="{{ ticket.token }}"
|
||||
aria-label="Disabled input example"
|
||||
aria-describedby="inputGroup-sizing-sm"
|
||||
disabled
|
||||
readonly>
|
||||
<button
|
||||
class="input-group-text token-clipboard"
|
||||
id="inputGroup-sizing-sm"><i class="bi bi-clipboard"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,8 +7,8 @@
|
||||
{% csrf_token %}
|
||||
<!-- Ticket -->
|
||||
{% for ticket in tickets %}
|
||||
<div id="div-ticket-{{ ticket.number }}" class="list-group mb-2">
|
||||
<div class="list-group-item list-group-item-action disable" aria-current="true">
|
||||
<ul id="div-ticket-{{ ticket.number }}" class="list-group mb-2">
|
||||
<li class="list-group-item list-group-item-action disable" aria-current="true">
|
||||
{% include 'collector/includes/ticket_info.html' %}
|
||||
<div class="col-xl-6 mt-1 mb-2">
|
||||
<div class="accordion" id="#archive_{{ ticket.number }}">
|
||||
@ -61,12 +61,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<a
|
||||
href="{{ ticket.get_absolute_url }}"
|
||||
class="btn btn-outline-primary mb-1 mt-1"
|
||||
>Open</a>
|
||||
><i class="bi bi-arrow-return-right"></i> Open</a>
|
||||
<button
|
||||
class="btn btn-outline-danger mb-1 mt-1"
|
||||
data-bs-toggle="modal"
|
||||
@ -74,8 +74,8 @@
|
||||
><i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Modal ticket -->
|
||||
{% include 'collector/includes/modal_ticket.html' %}
|
||||
<!-- Modal archive -->
|
||||
|
Loading…
Reference in New Issue
Block a user