root / templates / user_routes.html @ 62353243
History | View | Annotate | Download (10.8 kB)
1 |
{% extends "base.html" %} |
---|---|
2 |
{% load i18n %} |
3 |
{% block extrahead %} |
4 |
{% if user.is_authenticated %} |
5 |
<script type="text/javascript" src="{% url load-js 'poller' %}"></script> |
6 |
{% endif %} |
7 |
<script type="text/javascript" src="/static/js/jquery.dataTables.js"></script> |
8 |
<link rel="stylesheet" type="text/css" href="/static/css/engage.itoggle.css"/> |
9 |
<script type="text/javascript" src="/static/js/engage.itoggle-min.js"></script> |
10 |
<script type="text/javascript"> |
11 |
$(document).ready(function(){
|
12 |
$("#hid_mid").val('');
|
13 |
$('#dialog').dialog({
|
14 |
height: 250,
|
15 |
width: 340,
|
16 |
modal: true,
|
17 |
autoOpen: false,
|
18 |
buttons: {
|
19 |
'Suspend': function(){
|
20 |
route = $('#route_to_delete').text();
|
21 |
route_url_id = '#del_route_' + route;
|
22 |
url = $(route_url_id).attr('href');
|
23 |
$.ajax({
|
24 |
url: url,
|
25 |
cache: false,
|
26 |
success: function(data){
|
27 |
$('#dialog').dialog('close');
|
28 |
window.setTimeout('location.reload()', 1000);
|
29 |
}
|
30 |
});
|
31 |
},
|
32 |
Cancel: function(){
|
33 |
$('#dialog').dialog('close');
|
34 |
},
|
35 |
|
36 |
|
37 |
},
|
38 |
close: function(){
|
39 |
update_val = $("#hid_mid").val();
|
40 |
if (update_val == 'UPDATED') {
|
41 |
$("#hid_mid").val('');
|
42 |
window.setTimeout('location.reload()', 500);
|
43 |
}
|
44 |
}
|
45 |
});
|
46 |
$('#console').dialog({
|
47 |
height: 250,
|
48 |
width: 800,
|
49 |
modal: true,
|
50 |
autoOpen: false,
|
51 |
close: function(){
|
52 |
update_val = $("#hid_mid").val();
|
53 |
if (update_val == 'UPDATED') {
|
54 |
$("#hid_mid").val('');
|
55 |
window.setTimeout('location.reload()', 500);
|
56 |
}
|
57 |
}
|
58 |
});
|
59 |
|
60 |
var oTable = $('#routes_table').dataTable({
|
61 |
"bJQueryUI": true,
|
62 |
"aoColumns": [{
|
63 |
"bVisible": false,
|
64 |
"bSearchable": false,
|
65 |
"bSortable": false
|
66 |
}, {
|
67 |
"bSearchable": true,
|
68 |
"bSortable": true
|
69 |
}, {
|
70 |
"bSearchable": true,
|
71 |
"bSortable": true
|
72 |
}, {
|
73 |
"bSearchable": true,
|
74 |
"bSortable": true
|
75 |
}, {
|
76 |
"bSearchable": true,
|
77 |
"bSortable": true
|
78 |
}, {
|
79 |
"bSearchable": true,
|
80 |
"bSortable": true
|
81 |
}, {
|
82 |
"bSearchable": true,
|
83 |
"bSortable": true
|
84 |
}, {
|
85 |
"bSearchable": true,
|
86 |
"bSortable": true
|
87 |
}, {
|
88 |
"bVisible": true,
|
89 |
"bSearchable": false,
|
90 |
"bSortable": false
|
91 |
}],
|
92 |
"aaSorting": [[0, 'desc']],
|
93 |
"oLanguage": {
|
94 |
"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
|
95 |
},
|
96 |
"iDisplayLength": 25,
|
97 |
});
|
98 |
|
99 |
oTable.fnDraw();
|
100 |
|
101 |
$('input[name="status_filter"]').click(function(){
|
102 |
|
103 |
//slice off the last '|' or it doesn't work
|
104 |
//also be sure to use the third parameter
|
105 |
});
|
106 |
|
107 |
$(".button_place #routebutton").button({
|
108 |
icons: {
|
109 |
primary: "ui-icon-circle-plus"
|
110 |
},
|
111 |
});
|
112 |
$(".edit_button").button({
|
113 |
icons: {
|
114 |
primary: "ui-icon-wrench"
|
115 |
},
|
116 |
}).css('width','100px');;
|
117 |
$(" .del_button").button({
|
118 |
icons: {
|
119 |
primary: "ui-icon-circle-close"
|
120 |
},
|
121 |
}).click(function(){
|
122 |
$('#dialog').dialog('open');
|
123 |
return false;
|
124 |
}).css('width','100px');
|
125 |
$("#consolebutton").button({
|
126 |
icons: {
|
127 |
primary: "ui-icon-image"
|
128 |
},
|
129 |
}).click(function(){
|
130 |
$("#consolebutton").stop().stop();
|
131 |
$("#consolebutton").css('color', '#555555');
|
132 |
$('#console').dialog('open');
|
133 |
return false;
|
134 |
});
|
135 |
|
136 |
$(".statustootipclass").tooltip();
|
137 |
$(".expiresclass").tooltip();
|
138 |
$(".commentclass").tooltip();
|
139 |
var reg_exp = '';
|
140 |
var checkboxs = document.getElementsByName('status_filter');
|
141 |
for (var i = 0, inp; inp = checkboxs[i]; i++) {
|
142 |
checkCookie = readCookie("cookie_" + inp.value);
|
143 |
if (checkCookie) {
|
144 |
if (checkCookie == 'true') {
|
145 |
$(inp).attr('checked', true);
|
146 |
}
|
147 |
else {
|
148 |
$(inp).attr('checked', false);
|
149 |
}
|
150 |
}
|
151 |
|
152 |
if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
|
153 |
reg_exp = reg_exp + inp.value + '|';
|
154 |
}
|
155 |
|
156 |
}
|
157 |
if (reg_exp == '') {
|
158 |
reg_exp = 'XXX|'
|
159 |
}
|
160 |
oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
|
161 |
|
162 |
$('input[name="status_filter"]').iToggle({
|
163 |
type: 'checkbox',
|
164 |
onSlide: function(){
|
165 |
var reg_exp = '';
|
166 |
var checkboxs = document.getElementsByName('status_filter');
|
167 |
|
168 |
for (var i = 0, inp; inp = checkboxs[i]; i++) {
|
169 |
if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
|
170 |
reg_exp = reg_exp + inp.value + '|';
|
171 |
}
|
172 |
createCookie("cookie_" + inp.value, inp.checked, 30);
|
173 |
}
|
174 |
//passing an empty string will result in no filter
|
175 |
//thus, it must be set to something that will not exist in the column
|
176 |
if (reg_exp == '') {
|
177 |
reg_exp = 'X|'
|
178 |
}
|
179 |
oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
|
180 |
},
|
181 |
});
|
182 |
});
|
183 |
|
184 |
function delete_route(route){
|
185 |
route_name = route;
|
186 |
$('#route_to_delete').text(route_name);
|
187 |
return false;
|
188 |
}
|
189 |
|
190 |
|
191 |
|
192 |
</script>
|
193 |
<style type="text/css"> |
194 |
#console { |
195 |
background: none repeat scroll 0 0 #36102a !important; |
196 |
color: #edeae8 !important; |
197 |
font-family: monospace !important; |
198 |
} |
199 |
.message { |
200 |
font-family: monospace !important; |
201 |
} |
202 |
.tooltip { |
203 |
display:none; |
204 |
background:transparent url(/static/black_arrow.png); |
205 |
font-size:12px; |
206 |
height:70px; |
207 |
width:160px; |
208 |
padding:25px; |
209 |
color:#fff; |
210 |
} |
211 |
|
212 |
</style>
|
213 |
{% endblock %} |
214 |
{% block title %}{% trans "My rules" %}{% endblock %} |
215 |
{% block content %} |
216 |
<div style="float:left"> |
217 |
<h3 style="margin-top: 0px;">{% trans "My rules" %}</h3> |
218 |
</div>
|
219 |
<div class='button_place' style="float:right"> |
220 |
<button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a> |
221 |
</div>
|
222 |
<br><br> |
223 |
|
224 |
<div id='itoggle'> |
225 |
<table cellpadding="0" cellspacing="0" border="0" class="display" style='width:200px;'> |
226 |
<tbody>
|
227 |
<tr>
|
228 |
<th>ACTIVE</th><th>SUSPENDED</th><th>ERROR</th><th>PENDING</th> |
229 |
</tr>
|
230 |
<tr class="on_off"> |
231 |
<td>
|
232 |
<input type="checkbox" class="onoff" name="status_filter" value="ACTIVE" checked ="show_active"/> |
233 |
</td>
|
234 |
|
235 |
<td>
|
236 |
<input type="checkbox" class="onoff" name="status_filter" value="SUSPENDED" id="show_inactive"/> |
237 |
</td>
|
238 |
<td>
|
239 |
<input type="checkbox" class="onoff" name="status_filter" value="ERROR" id="show_error"/> |
240 |
</td>
|
241 |
|
242 |
<td>
|
243 |
<input type="checkbox" class="onoff" name="status_filter" value="PENDING" id="show_pending"/> |
244 |
</td>
|
245 |
</tr>
|
246 |
</tbody>
|
247 |
</table>
|
248 |
</div>
|
249 |
<table class="display" width="100%" id="nodes_table"> |
250 |
<table class="display" width="100%" id="routes_table"> |
251 |
<thead>
|
252 |
<tr>
|
253 |
<th>Id</th> |
254 |
<th>{% trans "Name" %}</th> |
255 |
<th>{% trans "Match" %}</th> |
256 |
<th style="text-align: center;">{% trans "Then" %}</th> |
257 |
<th style="text-align: center; ">{% trans "Status" %}</th> |
258 |
{% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %} |
259 |
<th style="text-align: center;">{% trans "Applier" %}</th> |
260 |
<th style="text-align: center;">{% trans "Expires" %}</th> |
261 |
<th style="text-align: center;">{% trans "Response" %}</th> |
262 |
<th style="text-align: center; width:180px;">{% trans "Actions" %}</th> |
263 |
</tr>
|
264 |
</thead>
|
265 |
|
266 |
<tbody>
|
267 |
{% for route in routes %} |
268 |
|
269 |
<tr class="GradeC" > |
270 |
<td>{{ route.pk }}</td> |
271 |
<td><span {% if %} |
272 |
class="commentclass" |
273 |
style="border-bottom:1px dotted red;" |
274 |
title="{{route.comments}}" |
275 |
{% endif %}>{{ route.name }}</span></td> |
276 |
<td>{{ route.get_match|safe|escape }}</td> |
277 |
<td style="text-align: center;">{{route.get_then|safe|escape}}</td> |
278 |
<td style="text-align: center; "><span |
279 |
{% if == 'EXPIRED' or == 'ADMININACTIVE' or == 'INACTIVE' or == 'OUTOFSYNC'%} |
280 |
class="statustootipclass" |
281 |
style="border-bottom:1px dotted red;" |
282 |
title = "{% ifequal route.status 'INACTIVE' %}Suspended by user{% else %}{% ifequal route.status 'ADMININACTIVE' %}Suspended by administrator{% else %}{% ifequal route.status 'EXPIRED' %}Suspended due to expiration{% else %}{% ifequal route.status 'OUTOFSYNC' %}Syncronization error. Configuration in device deffers from rule{% endifequal %}{% endifequal %}{% endifequal %}{% endifequal %}"{% 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 %}</span></td> |
283 |
{% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %} |
284 |
<td style="text-align: center;">{{ route.applier }}</td> |
285 |
<td style="text-align: center;"><span {% if %} |
286 |
class="expiresclass" |
287 |
style="border-bottom:2px dashed red;" |
288 |
title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}" |
289 |
{% endif %}>{{ route.expires }}</span></td> |
290 |
<td style="text-align: center;">{{ route.response }}</td> |
291 |
<td style="text-align: center; width:180px;"> |
292 |
{% ifequal route.status 'ACTIVE' %} |
293 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> |
294 |
<button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Suspend</button> |
295 |
<a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a> |
296 |
{% else %} |
297 |
{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %} |
298 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Reactivate</a> |
299 |
{% else %} |
300 |
{% ifequal route.status 'OUTOFSYNC' %} |
301 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">ReSync</a> |
302 |
{% else %} |
303 |
- |
304 |
{% endifequal %} |
305 |
{% endif %} |
306 |
{% endifequal %} |
307 |
</td>
|
308 |
</tr>
|
309 |
|
310 |
{% endfor %} |
311 |
</tbody>
|
312 |
</table>
|
313 |
|
314 |
<div id="dialog" title="Suspend Rule"> |
315 |
<p>You are about to suspend rule <strong><span id="route_to_delete"></span></strong></p> |
316 |
<p>Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.</p> |
317 |
<p>Are you sure you want to proceed?</p> |
318 |
</div>
|
319 |
<div id="console" title="Console"> |
320 |
{% include "poll.html" %} |
321 |
</div>
|
322 |
{% endblock %} |