1 {% extends "base.html" %}
4 {% if user.is_authenticated %}
5 <script type="text/javascript" src="{% url load-js 'poller' %}"></script>
7 <script type="text/javascript" src="/fodstatic/js/jquery.dataTables.js"></script>
8 <script type="text/javascript" src="/fodstatic/js/datatables_bootstrap.js"></script>
10 <script type="text/javascript">
12 $(document).ready(function(){
13 $('[rel=tooltip]').tooltip();
14 $("#hid_mid").val('');
21 '{% trans "Suspend" %}': function(){
22 route = $('#route_to_delete').text();
23 route_url_id = '#del_route_' + route;
24 url = $(route_url_id).attr('href');
28 success: function(data){
29 $('#dialog').dialog('close');
30 window.setTimeout('location.reload()', 1000);
34 '{% trans "Cancel" %}': function(){
35 $('#dialog').dialog('close');
39 update_val = $("#hid_mid").val();
40 if (update_val == 'UPDATED') {
41 $("#hid_mid").val('');
42 window.setTimeout('location.reload()', 500);
46 $('#console').dialog({
51 overlay: { opacity: 0.5, background: 'black'},
53 update_val = $("#hid_mid").val();
54 if (update_val == 'UPDATED') {
55 $("#hid_mid").val('');
56 window.setTimeout('location.reload()', 500);
60 $('#console').parent().css('opacity', 0.9);
61 $('#console').parent().css('filter', 'alpha(opacity=90)');
62 $(".button_place #routebutton").button({
64 primary: "ui-icon-circle-plus"
67 $(".edit_button").button({
69 primary: "ui-icon-wrench"
71 }).css('margin-bottom','2px');
72 $(" .del_button").button({
74 primary: "ui-icon-circle-close"
77 $('#dialog').dialog('open');
80 $("#consolebutton").button().click(function(){
81 $("#consolebutton").stop().stop();
82 $('#console').dialog('open');
87 var oTable = $('#routes_table').dataTable({
88 "sPaginationType": "bootstrap",
89 "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
117 "bSearchable": false,
120 "aaSorting": [[0, 'desc']],
121 "iDisplayLength": 25,
122 "oSearch": {"bSmart": false, "bRegex":true},
124 "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "rules" %}',
125 "sProcessing": "Processing...",
126 "sZeroRecords": '{% trans "No records to display" %}',
127 "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
128 "sInfoEmpty": "{% trans "Showing 0 to 0 of 0 entries" %}",
129 "sInfoFiltered": "(filtered from _MAX_ total entries)",
131 "sSearch": '{% trans "Search:" %}',
134 "sFirst": '{% trans "First" %}',
135 "sPrevious": '{% trans "Previous" %}',
136 "sNext": '{% trans "Next" %}',
137 "sLast": '{% trans "Last" %}'
145 var checkboxs = document.getElementsByName('status_filter');
146 for (var i = 0, inp; inp = checkboxs[i]; i++) {
147 checkCookie = readCookie("cookie_" + inp.value);
149 if (checkCookie == 'true') {
150 $(inp).addClass('active');
153 $(inp).removeClass('active');
157 if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
158 reg_exp = reg_exp + inp.value + '|';
165 console.log(reg_exp.slice(0, -1))
166 oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
169 $('button[name="status_filter"]').click(function(){
171 var checkboxs = document.getElementsByName('status_filter');
172 $(this).button('toggle');
173 for (var i = 0, inp; inp = checkboxs[i]; i++) {
174 if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
175 reg_exp = reg_exp + inp.value + '|';
177 createCookie("cookie_" + inp.value, $(inp).hasClass('active'), 30);
179 //passing an empty string will result in no filter
180 //thus, it must be set to something that will not exist in the column
184 oTable.fnFilter(reg_exp.slice(0, -1), 4, regex=true);
185 console.log(reg_exp.slice(0, -1))
192 function delete_route(route){
194 $('#route_to_delete').text(route_name);
201 <style type="text/css">
203 background: none repeat scroll 0 0 #36102a !important;
204 color: #edeae8 !important;
205 font-family: monospace !important;
208 font-family: monospace !important;
214 {% block title %}{% trans "My rules" %}{% endblock %}
217 <div class="row-fluid">
219 <div style="float:left">
220 <h4>{% trans "My rules" %}</h4>
225 <div class='button_place' style="float:right">
226 <button id="consolebutton" class="btn btn-small btn-inverse">
227 <i class="icon-tasks icon-white" style="align:left;"></i>{% trans "Console" %}</button>
228 <a href="{% url add-route %}" id="routebutton" class="btn btn-small btn-inverse"><i class="icon-plus-sign icon-white"></i>{% trans "Add Rule" %}</a>
233 <div class="row-fluid" style="padding-top:30px;">
235 <div id='itoggle' class="span12" style="text-align:center;">
236 <div class="btn-group" data-toggle="buttons-checkbox">
237 <button type="button" class="btn btn-small" name="status_filter" value="ACTIVE" id="show_active">Active</button>
238 <button type="button" class="btn btn-small" name="status_filter" value="SUSPENDED" id="show_inactive">Suspended</button>
239 <button type="button" class="btn btn-small" name="status_filter" value="ERROR" id="show_error">Error</button>
240 <button type="button" class="btn btn-small" name="status_filter" value="PENDING" id="show_pending">Pending</button>
246 <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="routes_table">
250 <th>{% trans "Name" %}</th>
251 <th>{% trans "Match" %}</th>
252 <th style="text-align: center;">{% trans "Then" %}</th>
253 <th style="text-align: center; ">{% trans "Status" %}</th>
254 {% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %}
255 <th style="text-align: center;">{% trans "Applier" %}</th>
256 <th style="text-align: center;">{% trans "Expires" %}</th>
257 <th style="text-align: center;">{% trans "Response" %}</th>
258 <th style="text-align: center; width:180px;">{% trans "Actions" %}</th>
263 {% for route in routes %}
266 <td>{{ route.pk }}</td>
267 <td><span {% if route.comments %} class="commentclass" style="border-bottom:1px dotted red;" title="{{route.comments}}" {% endif %}>{{ route.name }}</span></td>
268 <td>{{ route.get_match|safe|escape }}</td>
269 <td style="text-align: center;">{{route.get_then|safe|escape}}</td>
270 <td style="text-align: center; ">{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
271 <a href="#" rel="tooltip"
272 {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
274 title = "{% ifequal route.status 'INACTIVE' %}
275 {% trans 'Suspended by user' %}
277 {% ifequal route.status 'ADMININACTIVE' %}
278 {% trans 'Suspended by administrator' %}
280 {% ifequal route.status 'EXPIRED' %}
281 {% trans 'Suspended due to expiration' %}
283 {% ifequal route.status 'OUTOFSYNC' %}
284 {% trans 'Syncronization error. Configuration in device deffers from rule' %}
289 {% endif %}>{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}SUSPENDED{% else %}{% if route.status == 'OUTOFSYNC' %}ERROR{% else %}{{route.status}}{% endif %}{% endif %}</a>
290 {% else %}{{route.status}}{% endif %}</td>
291 {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
292 <td style="text-align: center;">{{ route.applier }}</td>
293 <td style="text-align: center;">
294 <span {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}{% else %}{% if route.days_to_expire %}
296 style="border-bottom:2px dashed red;"
297 title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
298 {% endif %}{% endif %}>{{ route.expires }}</span></td>
299 <td style="text-align: center;">{% if route.status == 'EXPIRED' %}{% trans "Rule expired" %}{% else %}{% if route.status == 'ADMININACTIVE' %}{% trans "Suspended by administrator" %}{% else %}{% if route.status == 'INACTIVE' %}{% trans "Suspended by user" %}{% else %}{{ route.response }}{% if route.status == 'PENDING' %}<img src="/fodstatic/dots.gif">{% endif %}{% endif %}{% endif %}{% endif %}</td>
300 <td style="text-align: center; width:180px;">
301 {% ifequal route.status 'ACTIVE' %}
302 <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a>
303 <button class="del_button btn btn-small" id="{{route.name}}" onclick="javascript:delete_route(this.id)">{% trans "Suspend" %}</button>
304 <a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}" class="btn btn btn-danger btn-small"></a>
306 {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
307 <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Reactivate" %}</a>
309 {% ifequal route.status 'OUTOFSYNC' %}
310 <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
312 {% ifequal route.status 'ERROR' %}
313 <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Fix it!" %}</a>
326 <div id="dialog" title="{% trans "Suspend Rule" %}">
327 <p>{% blocktrans %}You are about to suspend rule{% endblocktrans %} <strong><span id="route_to_delete"></span></strong></p>
328 <p>{% blocktrans %}Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.{% endblocktrans %}</p>
329 <p>{% blocktrans %}Are you sure you want to proceed?{% endblocktrans %}</p>
331 <div id="console" title="{% trans "Console" %}">
332 {% include "poll.html" %}