mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-02-19 19:26:17 +00:00
Add debug table for linked peers in ScheduleProfile form
This commit is contained in:
@@ -7,7 +7,7 @@ from django.utils.translation import gettext as _
|
|||||||
|
|
||||||
from scheduler.forms import ScheduleProfileForm
|
from scheduler.forms import ScheduleProfileForm
|
||||||
from scheduler.forms import ScheduleSlotForm
|
from scheduler.forms import ScheduleSlotForm
|
||||||
from scheduler.models import ScheduleProfile, ScheduleSlot
|
from scheduler.models import ScheduleProfile, ScheduleSlot, PeerScheduling
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@@ -31,6 +31,12 @@ def view_manage_scheduler_profile(request):
|
|||||||
title = _('Create Schedule Profile')
|
title = _('Create Schedule Profile')
|
||||||
slots = None
|
slots = None
|
||||||
|
|
||||||
|
show_peers = request.GET.get('show_peers') == 'true'
|
||||||
|
peers_scheduling = None
|
||||||
|
|
||||||
|
if show_peers and profile:
|
||||||
|
peers_scheduling = PeerScheduling.objects.filter(profile=profile).select_related('peer').order_by('peer__name')
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = ScheduleProfileForm(request.POST, instance=profile)
|
form = ScheduleProfileForm(request.POST, instance=profile)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
@@ -46,6 +52,8 @@ def view_manage_scheduler_profile(request):
|
|||||||
'profile': profile,
|
'profile': profile,
|
||||||
'slots': slots,
|
'slots': slots,
|
||||||
'now': timezone.now(),
|
'now': timezone.now(),
|
||||||
|
'show_peers': show_peers,
|
||||||
|
'peers_scheduling': peers_scheduling,
|
||||||
}
|
}
|
||||||
return render(request, 'scheduler/scheduleprofile_form.html', context)
|
return render(request, 'scheduler/scheduleprofile_form.html', context)
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex-grow-1">Sat
|
<div class="flex-grow-1">Sat
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow-1" >Sun
|
<div class="flex-grow-1">Sun
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="schedule-grid-body">
|
<div class="schedule-grid-body">
|
||||||
@@ -143,14 +143,70 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Peers List Debug Table -->
|
||||||
|
{% if show_peers %}
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card card-outline card-info">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-title">{% trans "Linked Peers (Debug)" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-striped mb-0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans "Peer" %}</th>
|
||||||
|
<th>{% trans "Disabled by Schedule" %}</th>
|
||||||
|
<th>{% trans "Next Enable" %}</th>
|
||||||
|
<th>{% trans "Next Disable" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in peers_scheduling %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'wireguard_peer_manage' %}?peer={{ item.peer.uuid }}">
|
||||||
|
{{ item.peer }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if item.peer.disabled_by_schedule %}
|
||||||
|
<span class="badge bg-danger">{% trans "Yes" %}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="badge bg-success">{% trans "No" %}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{{ item.next_scheduled_enable_at|default:"-" }}</td>
|
||||||
|
<td>{{ item.next_scheduled_disable_at|default:"-" }}</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="text-center text-muted">{% trans "No peers linked to this profile." %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="row mt-4">
|
<div class="row mt-4">
|
||||||
<div class="col-12 d-flex justify-content-end gap-2">
|
<div class="col-12 d-flex justify-content-end gap-2">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="fas fa-save"></i> {% trans "Save" %}
|
<i class="fas fa-save"></i> {% trans "Save" %}
|
||||||
</button>
|
</button>
|
||||||
<a href="{% url 'scheduler_profile_list' %}" class="btn btn-secondary">
|
<a href="{% url 'scheduler_profile_list' %}" class="btn btn-secondary">
|
||||||
<i class="fas fa-times"></i> {% trans "Cancel" %}
|
<i class="fas fa-times"></i> {% trans "Cancel" %}
|
||||||
</a>
|
</a>
|
||||||
|
{% if profile %}
|
||||||
|
<a href="?uuid={{ profile.uuid }}&show_peers=true" class="btn btn-outline-info">
|
||||||
|
<i class="fas fa-bug"></i> {% trans "Show Peers" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user