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