Commit 23ae8ecc by Kálmán Viktor

Merge branch 'network-fixes' into 'master'

Network fixes 🚧

See merge request !285
parents 8916d530 c1a10731
$(function() {
$(document).ready( function() {
colortable();
// find disabled nodes, set danger (red) on the rows
$('.node-disabled').closest("tr").addClass('danger');
});
// find disabled nodes, set danger (red) on the rows
function colortable()
{
$('.false').closest("tr").addClass('danger');
$('.true').closest("tr").removeClass('danger');
}
});
{% load sizefieldtags %}
{% load i18n %}
<span class="{% if not record.enabled %}node-disabled{% endif %}"></span>
<i class="fa fa-gears"></i> {% trans "CPU" %}
<div class="progress pull-right">
<div class="progress-bar progress-bar-success" role="progressbar"
......
......@@ -11,3 +11,10 @@
text-align: center;
width: 60px;
}
#rule-list-table {
td {
text-align: center;
&:nth-child(2), &:nth-child(3) {text-align: left;}
}
}
......@@ -148,6 +148,7 @@ class RecordTable(Table):
address = TemplateColumn(
template_name="network/columns/records-address.html"
)
ttl = Column(verbose_name=_("TTL"))
class Meta:
model = Record
......@@ -171,16 +172,26 @@ class SmallRecordTable(Table):
class RuleTable(Table):
r_type = LinkColumn('network.rule', args=[A('pk')])
r_type = LinkColumn(
'network.rule', args=[A('pk')],
verbose_name=_("type"),
orderable=False,
)
color_desc = TemplateColumn(
template_name="network/columns/color-desc.html"
template_name="network/columns/rule-short-description.html",
verbose_name=_("Short description"),
orderable=False,
)
nat_external_port = Column(
verbose_name=_("NAT")
)
class Meta:
model = Rule
attrs = {'class': 'table table-striped table-hover table-condensed'}
fields = ('r_type', 'color_desc', 'owner', 'extra', 'direction',
'action', 'proto', 'sport', 'dport', 'nat',
attrs = {'class': 'table table-striped table-hover table-condensed',
'id': "rule-list-table"}
fields = ('r_type', 'color_desc', 'extra', 'direction',
'action', 'proto', 'dport',
'nat_external_port', )
order_by = 'direction'
......@@ -202,7 +213,7 @@ class VlanTable(Table):
class Meta:
model = Vlan
attrs = {'class': 'table table-striped table-condensed'}
fields = ('vid', 'name', 'interface', 'network4', 'network6',
fields = ('vid', 'name', 'network4', 'network6',
'domain', )
order_by = 'vid'
......
{% if record.r_type == "host" %}
{{ record.host.get_fqdn }}
{% elif record.r_type == "vlan" %}
{{ record.vlan.name }}
{% elif record.r_type == "vlangroup" %}
{{ record.vlangroup }}
[{% for v in record.vlangroup.vlans.all %}
{{ v.name }}{% if not forloop.last %},{% endif %}
{% endfor %}]
{% elif record.r_type == "group" %}
{{ record.hostgroup.name }}
{% elif record.r_type == "firewall" %}
{{ record.firewall }}
{% else %}
-
{% endif %}
{% load i18n %}
{% load l10n %}
{# <span style="color: #FF0000;">[{{ record.r_type }}]</span> #}
{% if record.direction == "1" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %}
{#<span style="color: #0000FF;"> ▸ </span>#}
<i class="fa fa-arrow-right"></i>
{% if record.direction == "0" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %}
<span style="color: #00FF00;">
{% if record.proto %}
proto={{ record.proto }}
{% endif %}
{% if record.sport %}
sport={{ record.sport }}
{% endif %}
{% if record.dport %}
dport={{ record.dport }}
{% endif %}
{{ record.description }}
{% load i18n %}
{% if record.direction == "in" %}
{{ record.foreign_network }}
[{% for v in record.foreign_network.vlans.all %}
{{ v.name }}{% if not forloop.last %},{% endif %}
{% endfor %}]
{% else %}
{% include "network/columns/_rule-type.html" %}
{% endif %}
<i class="fa fa-arrow-right"></i>
{% if record.direction == "out" %}
{{ record.foreign_network }}
[{% for v in record.foreign_network.vlans.all %}
{{ v.name }}{% if not forloop.last %},{% endif %}
{% endfor %}]
{% else %}
{% include "network/columns/_rule-type.html" %}
{% endif %}
{% if record.nat %}
<span class="label label-success">NAT
[
{{record.nat_external_port}}
<i class="fa fa-arrow-right"></i>
{{ record.dport }}
]
{{ record.proto|upper }}
</span>
{% endif %}
......@@ -8,11 +8,28 @@
{% block content %}
<div class="page-header">
<a href="{% url "network.rule_create" %}" class="btn btn-success pull-right"><i class="fa fa-plus-circle"></i> {% trans "Create a new rule" %}</a>
<h1>{% trans "Rules" %} <small>{% trans "list of all rules" %}</small></h1>
<a href="{% url "network.rule_create" %}" class="btn btn-success pull-right">
<i class="fa fa-plus-circle"></i> {% trans "Create a new rule" %}
</a>
<h1>{% trans "Rules" %} <small>{% trans "list of all rules" %}</small></h1>
</div>
<ul class="nav nav-pills" style="margin: 5px 0 20px 0;">
<li class="disabled">
<a href="#">{% trans "Filter by types" %}</a>
</li>
<li {% if not request.GET.type %} class="active"{% endif %}>
<a href="{{ request.path }}">{% trans "ALL" %}</a>
</li>
{% for k, v in types.items %}
<li{% if request.GET.type == k %} class="active"{% endif %}>
<a href="?type={{ k }}">{{ v }}</a>
</li>
{% endfor %}
</ul>
<div class="table-responsive">
{% render_table table %}
{% render_table table %}
</div>
{% endblock %}
......@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from collections import OrderedDict
from netaddr import IPNetwork
from django.views.generic import (TemplateView, UpdateView, DeleteView,
CreateView)
......@@ -597,10 +599,25 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
template_name = "network/rule-list.html"
table_pagination = False
def get_context_data(self, **kwargs):
self.types = OrderedDict([
('vlan', _("Vlan")), ('vlangroup', _("Vlan group")),
('host', _("Host")), ('hostgroup', _("Host group")),
('firewall', _("Firewall"))
])
context = super(RuleList, self).get_context_data(**kwargs)
context['types'] = self.types
return context
def get_table_data(self):
return Rule.objects.select_related('host', 'hostgroup', 'vlan',
'vlangroup', 'firewall',
'foreign_network', 'owner')
rules = Rule.objects.select_related('host', 'hostgroup', 'vlan',
'vlangroup', 'firewall',
'foreign_network', 'owner')
rule_type = self.request.GET.get("type")
if rule_type and rule_type in self.types.keys():
rules = rules.filter(**{'%s__isnull' % rule_type: False})
return rules
class RuleDetail(LoginRequiredMixin, SuperuserRequiredMixin,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment