Skip to content
Snippets Groups Projects
Commit 8934a1b8 authored by Stauros Kroustouris's avatar Stauros Kroustouris
Browse files

rule detail page

parent 505b792c
No related branches found
No related tags found
No related merge requests found
......@@ -515,6 +515,7 @@ class Route(models.Model):
get_then.short_description = 'Then statement'
get_then.allow_tags = True
#
def get_match(self):
ret = '<dl class="dl-horizontal">'
if self.destination:
......
......@@ -187,7 +187,8 @@ def build_routes_json(groutes):
rd = {}
rd['id'] = r.pk
# name with link to rule details
rd['name'] = '<a href="%s">%s</a>' % (r.get_absolute_url(), r.name)
rd['name'] = r.name
rd['details'] = '<a href="%s">%s</a>' % (r.get_absolute_url(), r.name)
if not r.comments:
rd['comments'] = 'Not Any'
else:
......@@ -723,5 +724,8 @@ def lookupShibAttr(attrmap, requestMeta):
return ''
# show the details of specific route
@login_required
def routedetails(request, route_slug):
raise NotImplementedError
route = get_object_or_404(Route, name=route_slug)
return render(request, 'flowspy/route_details.html', {'route': route})
{% extends "base.html" %}
{% load i18n %}
{% block contentplaceholder %}
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">{{ route.name }}</h1>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div>
<i class="fa fa-clock-o"></i> {% trans "Expires" %}: {{ route.expires|date:"d M y" }}
</div>
</div>
<div class="col-md-12">
<div>
<i class="fa fa-pencil-square-o"></i> {% trans "Last update" %}: {{route.last_updated}} {% trans "by" %} {{route.applier}}
</div>
<div>
<h2>{% trans 'About' %}</h2>
{{ route.get_then }}
{% trans 'all'%}
{% if route.protocol.count %}
{% for proto in route.protocol.all %}
{{ proto }} {% if not forloop.last %},{% endif %}
{% endfor %}
{% endif %}
{% trans 'traffic from' %}
{{ route.source }}
{% if route.port.count %}, {% trans 'port' %}
{% for port in route.port.all %}
{{ port }} {% if not forloop.last %},{% endif %}
{% endfor %}
{% endif %}
{% trans 'to' %}
{{ route.destination }}
{% if route.destinationport.count %}, {% trans 'port' %}
{% for port in route.destinationport.all %}
{{ port }} {% if not forloop.last %},{% endif %}
{% endfor %}
{% endif %}
{% if route.fragmenttype.count %}
({% trans 'Fragmentypes' %}:
{% for f in route.fragmenttype.all %}
{{ f }} {% if not forloop.last %},{% endif %}
{% endfor %}
)
{% endif %}
{% if route.status = 'EXPIRED' or route.status = 'ADMININACTIVE' or route.status = 'INACTIVE' %}
<span class="label label-default">DEACTIVATED</span>
{% elif route.status = 'OUTOFSYNC' %}
<span class="label label-danger">ERROR</span>
{% elif route.status = 'ACTIVE' %}
<span class="label label-success">{{ route.status }}</span>
{% elif route.status = 'PENDING' %}
<span class="label label-info">{{ route.status }}</span>
{% else %}
<span class="label label-danger">{{ route.status }}</span>
{% endif %}
{% if route.status != 'PENDING' %}
<a href="{% url edit-route route.name %}" class="btn-info btn btn-sm btn-outline">{% trans "Edit" %}</a>
{% if route.status = 'ACTIVE' %}
<button class="del_button btn-warning btn btn-sm btn-outline" id="{{ route.name }}" data-routename="{{ route.name }}">{% trans "Deactivate" %}</button>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block pagejsbottom %}
<script type="text/javascript">
$('body').on('click', ".del_button", function(){
last_element = false;
var my = $(this);
my.html('Deactivating...')
var routename = $(this).data("routename");
var delurl = "{% url delete-route 'route_placeholder'%}".replace('route_placeholder', routename.toString());
$.ajax({
type: 'POST',
url: delurl,
cache: false,
success: function(data) {
$('.del_button').addClass('disabled').text('Done');
}
});
return false;
});
</script>
{% endblock %}
......@@ -233,11 +233,11 @@ $(document).ready( function(){
},
"aoColumns":[
{"mData":"id", "bSearchable": false,"bSortable": false, "bvisible":false},
{"mData":"name", "sClass" : "alignCenter","bSearchable": true,"bSortable": true,
{"mData":"details", "sClass" : "alignCenter","bSearchable": true,"bSortable": true,
"mRender": function (data, type, full) {
if (full.comments !== null) {
if (!full.comments.trim()) {
return '<small>'+data+'</small>';
return '<small>' + data + '</small>';
}
return '<a rel="tooltip" href="#" data-toggle="tooltip" data-placement="top" title='+full.comments+'><small>'+data+'</small>'
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment