mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-26 22:56:04 +01:00
Add speed profiles to limit the bandwidth of each peer
This commit is contained in:
@@ -78,7 +78,9 @@
|
||||
<tr>
|
||||
<td><code>{{ section.name }}</code></td>
|
||||
<td>
|
||||
{% if section.state == 'synced' %}<span class="badge badge-success">{% trans 'Synchronized' %}</span>
|
||||
{% if section.state == 'synced' and section.warning %}<span class="badge badge-warning">{% trans 'Synchronized with warnings' %}</span>
|
||||
<br><small class="text-warning text-break">{{ section.warning|truncatechars:300 }}</small>
|
||||
{% elif section.state == 'synced' %}<span class="badge badge-success">{% trans 'Synchronized' %}</span>
|
||||
{% elif section.state == 'error' %}<span class="badge badge-danger">{% trans 'Error' %}</span>
|
||||
{% else %}<span class="badge badge-secondary">{% trans 'Pending' %}</span>{% endif %}
|
||||
{% if section.message %}<br><small class="text-muted text-break">{{ section.message|truncatechars:300 }}</small>{% endif %}
|
||||
|
||||
@@ -150,6 +150,11 @@
|
||||
{% empty %}
|
||||
<span class="text-muted">-</span>
|
||||
{% endfor %}
|
||||
{% if worker.operational and worker.warnings.section_warnings %}
|
||||
<br><small class="text-warning" title="{{ worker.warnings.section_warnings|join:', ' }}">
|
||||
<i class="fas fa-exclamation-triangle"></i> {% trans 'Synchronized with warnings' %}
|
||||
</small>
|
||||
{% endif %}
|
||||
{% if worker.operational and worker.warnings.certificate_issues %}
|
||||
<br><small class="text-warning" title="{{ worker.warnings.certificate_issues|join:', ' }}">
|
||||
<i class="fas fa-certificate"></i> {% trans 'Certificates unavailable or expiring soon' %}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card card-danger card-outline">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">{% trans 'Delete Speed Profile' %}</h3>
|
||||
</div>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="card-body">
|
||||
{% if peers or default_for_instances %}
|
||||
<p>{% blocktrans with name=profile.name %}The profile "{{ name }}" is in use.{% endblocktrans %}</p>
|
||||
{% if peers %}
|
||||
<p class="mb-1"><strong>{% trans 'Peers using this profile' %}</strong></p>
|
||||
<ul>
|
||||
{% for peer in peers %}
|
||||
<li><a href="/peer/manage/?peer={{ peer.uuid }}">{{ peer }}</a> <small class="text-muted">(wg{{ peer.wireguard_instance.instance_id }})</small></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if default_for_instances %}
|
||||
<p class="mb-1"><strong>{% trans 'Default profile of the instances' %}</strong></p>
|
||||
<ul>
|
||||
{% for instance in default_for_instances %}
|
||||
<li>wg{{ instance.instance_id }}{% if instance.name %} ({{ instance.name }}){% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<div class="alert alert-warning mb-0">
|
||||
{% trans 'Unlinking removes the profile from these peers and instances. The peers will have no speed limit.' %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>{% blocktrans with name=profile.name %}Are you sure you want to delete the profile "{{ name }}"?{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
{% if peers or default_for_instances %}
|
||||
<button type="submit" name="action" value="unlink_and_delete" class="btn btn-danger">
|
||||
<i class="fas fa-unlink"></i> {% trans 'Unlink and Delete' %}
|
||||
</button>
|
||||
{% else %}
|
||||
<button type="submit" name="action" value="delete" class="btn btn-danger">
|
||||
<i class="fas fa-trash"></i> {% trans 'Confirm Delete' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<a href="{% url 'speed_profile_list' %}" class="btn btn-secondary">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,83 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">{% trans 'Speed Profiles' %}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans 'Name' %}</th>
|
||||
<th>{% trans 'Download' %}</th>
|
||||
<th>{% trans 'Upload' %}</th>
|
||||
<th>{% trans 'Peers' %}</th>
|
||||
<th style="width: 100px;">{% trans 'Actions' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for profile in profiles %}
|
||||
<tr>
|
||||
<td>{{ profile.name }}</td>
|
||||
<td>
|
||||
{% if profile.download_limit %}
|
||||
{{ profile.download_display }} Mbit/s
|
||||
{% if profile.download_burst %}<small class="text-muted">({% trans 'burst' %} {{ profile.download_burst_display }} MB)</small>{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">{% trans 'No limit' %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if profile.upload_limit %}
|
||||
{{ profile.upload_display }} Mbit/s
|
||||
{% if profile.upload_burst %}<small class="text-muted">({% trans 'burst' %} {{ profile.upload_burst_display }} MB)</small>{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">{% trans 'No limit' %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ profile.peer_count }}</td>
|
||||
<td class="text-nowrap">
|
||||
<a
|
||||
{% if user_acl.user_level >= 30 %}
|
||||
href="{% url 'manage_speed_profile' %}?uuid={{ profile.uuid }}" class="btn btn-sm btn-info"
|
||||
{% else %}
|
||||
href="#" class="btn btn-sm btn-info disabled"
|
||||
{% endif %}
|
||||
title="{% trans 'Edit' %}">
|
||||
<i class="far fa-edit"></i>
|
||||
</a>
|
||||
<a
|
||||
{% if user_acl.user_level >= 30 %}
|
||||
href="{% url 'delete_speed_profile' %}?uuid={{ profile.uuid }}" class="btn btn-sm btn-danger"
|
||||
{% else %}
|
||||
href="#" class="btn btn-sm btn-danger disabled"
|
||||
{% endif %}
|
||||
title="{% trans 'Delete' %}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">{% trans 'No speed profiles found.' %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a
|
||||
{% if user_acl.user_level >= 30 %}
|
||||
href="{% url 'manage_speed_profile' %}" class="btn btn-primary"
|
||||
{% else %}
|
||||
href="#" class="btn btn-primary disabled"
|
||||
{% endif %}
|
||||
>
|
||||
<i class="fas fa-plus"></i> {% trans 'Add Profile' %}
|
||||
</a>
|
||||
<a href="{% url 'wireguard_peer_list' %}" class="btn btn-outline-secondary">{% trans 'Back to Peers' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -111,6 +111,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Speed limit -->
|
||||
<div class="form-group">
|
||||
<label>{% trans 'Speed Limit' %}</label>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<span>
|
||||
{% if current_peer.speed_profile %}
|
||||
{{ current_peer.speed_profile.name }}
|
||||
<br><small class="text-muted">{{ current_peer.speed_profile.summary }}</small>
|
||||
{% else %}
|
||||
<span class="text-muted">{% trans 'No limit' %}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<a href="{% url 'wireguard_peer_edit_field' %}?peer={{ current_peer.uuid }}&group=speed"
|
||||
class="btn btn-tool">
|
||||
<i class="fas fa-pen"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Keys Section -->
|
||||
<div class="form-group">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
{% trans 'Disabled Peers' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-outline-secondary" href="{% url 'speed_profile_list' %}">
|
||||
<i class="fas fa-tachometer-alt"></i> {% trans 'Speed Profiles' %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user