firewall rules/settings translation

This commit is contained in:
Eduardo Silva
2025-04-16 12:34:50 -03:00
parent dca75f05a4
commit c60da36047
8 changed files with 194 additions and 80 deletions

View File

@@ -1,15 +1,16 @@
{% extends 'base.html' %}
{% load i18n %}
{% block page_custom_head %}
<style>
.first-line-container {
display: flex;
align-items: center; /* Centraliza os itens verticalmente */
align-items: center;
width: 100%;
}
.more-link {
margin-left: auto; /* Empurra o link para a direita */
margin-left: auto;
text-decoration: none;
}
@@ -36,30 +37,30 @@
<thead>
<th>#</th>
<th><i class="fas fa-info-circle"></i></th>
<th>In</th>
<th>Out</th>
<th>Source</th>
<th>Destination</th>
<th>Protocol</th>
<th>Port</th>
<th>State</th>
<th>Action</th>
<th>{% trans 'In' %}</th>
<th>{% trans 'Out' %}</th>
<th>{% trans 'Source' %}</th>
<th>{% trans 'Destination' %}</th>
<th>{% trans 'Protocol' %}</th>
<th>{% trans 'Port' %}</th>
<th>{% trans 'State' %}</th>
<th>{% trans 'Action' %}</th>
<th><i class="far fa-edit"></i></th>
</thead>
<tbody>
<tr class="fw_automatic_rule">
<td>-</td>
<td><i class="fas fa-info-circle" title="Automatic rule: Allow established/related traffic"></i></td>
<td><i class="fas fa-info-circle" title="{% trans 'Automatic rule: Allow established/related traffic' %}"></i></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>all</td>
<td>{% trans 'all' %}</td>
<td></td>
<td>Related<br>
Established
<td>{% trans 'Related' %}<br>
{% trans 'Established' %}
</td>
<td>ACCEPT</td>
<td>{% trans 'ACCEPT' %}</td>
<td></td>
</tr>
@@ -67,7 +68,7 @@
{% if rule.add_forward_rule and current_chain == 'forward' %}
<tr class="fw_automatic_rule">
<td>-</td>
<td><i class="fas fa-info-circle" title="Port forward automatic rule. {{ rule.description|default_if_none:'' }}"></i></td>
<td><i class="fas fa-info-circle" title="{% trans 'Automatic Rule: Port forward.' %} {{ rule.description|default_if_none:'' }}"></i></td>
<td>{{ firewall_settings.wan_interface }}</td>
<td>wg{{ rule.wireguard_instance.instance_id }}</td>
<td></td>
@@ -87,13 +88,13 @@
{% endif %}
</td>
<td></td>
<td>ACCEPT</td>
<td>{% trans 'ACCEPT' %}</td>
<td></td>
</tr>
{% elif rule.masquerade_source and current_chain == 'postrouting' %}
<tr class="fw_automatic_rule">
<td>-</td>
<td><i class="fas fa-info-circle" title="Port forward automatic rule. {{ rule.description|default_if_none:'' }}"></i></td>
<td><i class="fas fa-info-circle" title="{% trans 'Automatic Rule: Port forward.' %} {{ rule.description|default_if_none:'' }}"></i></td>
<td></td>
<td>wg{{ rule.wireguard_instance.instance_id }}</td>
<td></td>
@@ -134,14 +135,14 @@
{% if rule.destination_ip %}{% if rule.not_destination %}<span title="Not destination">!</span> {% endif %}{{ rule.destination_ip }}/{{ rule.destination_netmask }}<br>{% endif%}
{% for peer in rule.destination_peer.all %}{% if rule.not_destination %}<span title="Not destination">!</span> {% endif %}{{ peer }}{% if rule.destination_peer_include_networks %} <span title="Include peer networks">+</span>{% endif %}<br>{% endfor %}
</td>
<td>{{ rule.get_protocol_display|default_if_none:'all' }}</td>
<td>{% if rule.protocol %}{{ rule.get_protocol_display }}{% else %}{% trans 'all' %}{% endif %}</td>
<td>{{ rule.destination_port|default_if_none:'' }}</td>
<td>
{% if rule.state_new %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}New<br>{% endif %}
{% if rule.state_related %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}Related<br>{% endif %}
{% if rule.state_established %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}Established<br>{% endif %}
{% if rule.state_invalid %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}Invalid<br>{% endif %}
{% if rule.state_untracked %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}Untracked<br>{% endif %}
{% if rule.state_new %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}{% trans 'New' %}<br>{% endif %}
{% if rule.state_related %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}{% trans 'Related' %}<br>{% endif %}
{% if rule.state_established %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}{% trans 'Established' %}<br>{% endif %}
{% if rule.state_invalid %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}{% trans 'Invalid' %}<br>{% endif %}
{% if rule.state_untracked %}{% if rule.not_state %}<span title="Not state">! </span>{% endif %}{% trans 'Untracked' %}<br>{% endif %}
</td>
<td>{{ rule.get_rule_action_display }}</td>
<td style="width: 1%; white-space: nowrap;">
@@ -154,7 +155,7 @@
{% for wireguard_instance in wireguard_instances %}
<tr class="fw_automatic_rule">
<td>-</td>
<td><i class="fas fa-info-circle" title="Automatic Rule: Firewall Settings Peer to Peer traffic"></i></td>
<td><i class="fas fa-info-circle" title="{% trans 'Automatic Rule: Firewall Settings Peer to Peer traffic' %}"></i></td>
<td>wg{{ wireguard_instance.instance_id }}</td>
<td>wg{{ wireguard_instance.instance_id }}</td>
<td></td>
@@ -164,9 +165,9 @@
<td></td>
<td>
{% if firewall_settings.allow_peer_to_peer %}
ACCEPT
{% trans 'ACCEPT' %}
{% else %}
REJECT
{% trans 'REJECT' %}
{% endif %}
</td>
<td></td>
@@ -175,7 +176,7 @@
<tr class="fw_automatic_rule">
<td>-</td>
<td><i class="fas fa-info-circle" title="Automatic Rule: Firewall Settings Instance to Instance"></i></td>
<td><i class="fas fa-info-circle" title="{% trans 'Automatic Rule: Firewall Settings Instance to Instance' %}"></i></td>
<td>wg+</td>
<td>wg+</td>
<td></td>
@@ -183,16 +184,16 @@
<td></td>
<td></td>
<td></td>
<td>{% if firewall_settings.allow_instance_to_instance %}ACCEPT{% else %}REJECT{% endif %}</td>
<td>{% if firewall_settings.allow_instance_to_instance %}{% trans 'ACCEPT' %}{% else %}{% trans 'REJECT' %}{% endif %}</td>
<td></td>
</tr>
{% endif %}
</tbody>
</table>
<a href="/firewall/manage_firewall_rule/?chain={{ current_chain }}" class='btn btn-primary'>Create Firewall Rule</a>
<a href="/firewall/firewall_settings/?chain={{ current_chain }}" class='btn btn-outline-primary'>Firewall Settings</a>
<a class='btn btn-outline-primary' onclick=$('.fw_automatic_rule').slideToggle();>Display automatic rules</a>
<a href="/firewall/manage_firewall_rule/?chain={{ current_chain }}" class='btn btn-primary'>{% trans 'Create Firewall Rule' %}</a>
<a href="/firewall/firewall_settings/?chain={{ current_chain }}" class='btn btn-outline-primary'>{% trans 'Firewall Settings' %}</a>
<a class='btn btn-outline-primary' onclick=$('.fw_automatic_rule').slideToggle();>{% trans 'Display automatic rules' %}</a>
</div>
</div>
</div>
@@ -208,7 +209,6 @@
if (brCount >= 2) {
let contentParts = td.innerHTML.split('<br>');
// Mantém a estrutura do contêiner com o texto e o link "More"
let firstLineContainer = `<div class="first-line-container">${contentParts[0]}<a href="#" class="more-link">more</a></div>`;
td.innerHTML = firstLineContainer +
@@ -219,8 +219,8 @@
document.querySelectorAll('.more-link').forEach(function(link) {
link.addEventListener('click', function(e) {
e.preventDefault(); // Impede a ação padrão do link
let moreText = this.parentNode.nextElementSibling; // Seleciona o span corretamente
e.preventDefault();
let moreText = this.parentNode.nextElementSibling;
if (moreText.style.display === "none") {
moreText.style.display = "inline";
this.textContent = "less";