mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-01-17 13:06:18 +00:00
add server selection and improve modal layout in wireguard peer list
This commit is contained in:
@@ -189,26 +189,47 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="modal-footer d-flex flex-column align-items-stretch">
|
||||
<!-- Row 1: buttons -->
|
||||
<div class="d-flex w-100 justify-content-end flex-wrap">
|
||||
<button type="button" class="btn btn-secondary mb-2" data-dismiss="modal">
|
||||
<i class="fas fa-times"></i> {% trans 'Close' %}
|
||||
</button>
|
||||
|
||||
<a href="#" class="btn btn-info ml-2 mb-2" id="downloadConfigButton">
|
||||
<i class="fas fa-download"></i> {% trans 'Config' %}
|
||||
</a>
|
||||
|
||||
<a href="#" class="btn btn-info ml-2 mb-2" id="qrcodeButton">
|
||||
<i class="fas fa-qrcode"></i> {% trans 'QR Code' %}
|
||||
</a>
|
||||
|
||||
<a href="#" class="btn btn-info ml-2 mb-2" id="inviteButton">
|
||||
<i class="fas fa-share"></i> {% trans 'VPN Invite' %}
|
||||
</a>
|
||||
|
||||
<a href="#" class="btn btn-outline-primary ml-2 mb-2" id="editPeerButton">
|
||||
<i class="far fa-edit"></i> {% trans 'Edit' %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Row 2: server select (right aligned) -->
|
||||
{% if cluster_settings and servers|length > 1 %}
|
||||
<div class="mr-auto form-inline">
|
||||
<label class="mr-2" for="server_select">{% trans 'Server' %}:</label>
|
||||
<select class="form-control" id="server_select">
|
||||
<div class="d-flex w-100 mt-2">
|
||||
<div class="form-inline ml-auto">
|
||||
<label class="mr-2 mb-0" for="server_select">{% trans 'Server' %}:</label>
|
||||
<select class="form-control" id="server_select" style="width: 300px;">
|
||||
{% for server in servers %}
|
||||
<option value="{{ server.address }}">{{ server.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fas fa-times"></i> {% trans 'Close' %}</button>
|
||||
<a href="#" class="btn btn-info" id="downloadConfigButton"><i class="fas fa-download"></i> {% trans 'Config' %}</a>
|
||||
<a href="#" class="btn btn-info" id="qrcodeButton"><i class="fas fa-qrcode"></i> {% trans 'QR Code' %}</a>
|
||||
<a href="#" class="btn btn-info" id="inviteButton"><i class="fas fa-share"></i> {% trans 'VPN Invite' %}</a>
|
||||
<a href="#" class="btn btn-outline-primary" id="editPeerButton"><i class="far fa-edit"></i> {% trans 'Edit' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cluster.models import ClusterSettings
|
||||
from cluster.models import ClusterSettings, Worker
|
||||
from user_manager.models import UserAcl
|
||||
from wgwadmlibrary.tools import check_sort_order_conflict, deduplicate_sort_order, default_sort_peers, \
|
||||
user_allowed_instances, user_allowed_peers, user_has_access_to_instance, user_has_access_to_peer
|
||||
@@ -83,17 +83,24 @@ def view_wireguard_peer_list(request):
|
||||
if settings.WIREGUARD_STATUS_CACHE_ENABLED:
|
||||
refresh_interval = settings.WIREGUARD_STATUS_CACHE_REFRESH_INTERVAL
|
||||
|
||||
if ClusterSettings.objects.filter(name='cluster_settings', enabled=True).exists():
|
||||
cluster_enabled = True
|
||||
else:
|
||||
cluster_enabled = False
|
||||
cluster_settings = ClusterSettings.objects.filter(name='cluster_settings', enabled=True).first()
|
||||
servers = []
|
||||
if cluster_settings:
|
||||
if cluster_settings.primary_enable_wireguard:
|
||||
servers.append({'name': _('Primary Server'), 'address': ''})
|
||||
|
||||
for worker in Worker.objects.filter(enabled=True):
|
||||
port = current_instance.listen_port if current_instance else 51820
|
||||
worker_address = f"{worker.server_address}:{port}"
|
||||
servers.append({'name': worker.display_name, 'address': worker_address})
|
||||
|
||||
context = {
|
||||
'page_title': page_title, 'wireguard_instances': wireguard_instances,
|
||||
'current_instance': current_instance, 'peer_list': peer_list, 'add_peer_enabled': add_peer_enabled,
|
||||
'user_acl': user_acl, 'refresh_interval': refresh_interval,
|
||||
'load_from_cache': load_from_cache, 'cache_previous_count': cache_previous_count,
|
||||
'cluster_enabled': cluster_enabled,
|
||||
'cluster_settings': cluster_settings,
|
||||
'servers': servers,
|
||||
}
|
||||
|
||||
return render(request, 'wireguard/wireguard_peer_list.html', context)
|
||||
|
||||
Reference in New Issue
Block a user