mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-27 07:06:03 +01:00
Add speed profiles to limit the bandwidth of each peer
This commit is contained in:
@@ -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 %}
|
||||
Reference in New Issue
Block a user