root / templates / user_routes.html @ 4b302e54
History | View | Annotate | Download (7.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 |
<script type="text/javascript"> |
9 |
$(document).ready( function(){
|
10 |
var noaction = readCookie('noaction');
|
11 |
$( "#hide_noaction" ).button();
|
12 |
if (noaction == 'true'){
|
13 |
$('#hide_noaction').attr('checked','checked');
|
14 |
$("#hide_noaction").button( "option", "label", "Show Expired, AdminInactive, Error" );
|
15 |
}
|
16 |
$("#hid_mid").val('');
|
17 |
$('#dialog').dialog({
|
18 |
height: 220,
|
19 |
width: 300,
|
20 |
modal: true,
|
21 |
autoOpen: false,
|
22 |
buttons: {
|
23 |
'Delete': function() {
|
24 |
route = $('#route_to_delete').text();
|
25 |
route_url_id = '#del_route_'+route;
|
26 |
url = $(route_url_id).attr('href');
|
27 |
$.ajax({
|
28 |
url: url ,
|
29 |
cache: false,
|
30 |
success: function(data) {
|
31 |
$('#dialog').dialog('close');
|
32 |
window.setTimeout('location.reload()', 1000);
|
33 |
}
|
34 |
});
|
35 |
},
|
36 |
Cancel: function() {
|
37 |
$('#dialog').dialog('close');
|
38 |
},
|
39 |
|
40 |
|
41 |
},
|
42 |
close: function() {
|
43 |
update_val = $("#hid_mid").val();
|
44 |
if (update_val == 'UPDATED'){
|
45 |
$("#hid_mid").val('');
|
46 |
window.setTimeout('location.reload()', 500);
|
47 |
}
|
48 |
}
|
49 |
});
|
50 |
$('#console').dialog({
|
51 |
height: 250,
|
52 |
width: 800,
|
53 |
modal: true,
|
54 |
autoOpen: false,
|
55 |
close: function() {
|
56 |
update_val = $("#hid_mid").val();
|
57 |
if (update_val == 'UPDATED'){
|
58 |
$("#hid_mid").val('');
|
59 |
window.setTimeout('location.reload()', 500);
|
60 |
}
|
61 |
}
|
62 |
});
|
63 |
|
64 |
$('#routes_table').dataTable({
|
65 |
"bJQueryUI": true,
|
66 |
"aoColumns": [
|
67 |
{"bVisible": false, "bSearchable": false,"bSortable": false },
|
68 |
{"bSearchable": true,"bSortable": true},
|
69 |
{"bSearchable": true,"bSortable": true},
|
70 |
{"bSearchable": true,"bSortable": true},
|
71 |
{"bSearchable": true,"bSortable": true},
|
72 |
{"bSearchable": true,"bSortable": true},
|
73 |
{"bSearchable": true,"bSortable": true},
|
74 |
{"bSearchable": true,"bSortable": true},
|
75 |
{"bVisible": true, "bSearchable": false,"bSortable": false}
|
76 |
],
|
77 |
"aaSorting": [[0,'desc']],
|
78 |
"oLanguage": {
|
79 |
"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
|
80 |
},
|
81 |
"iDisplayLength": 25,
|
82 |
});
|
83 |
$.fn.dataTableExt.afnFiltering = new Array();
|
84 |
$.fn.dataTableExt.afnFiltering.push(
|
85 |
function( oSettings, aData, iDataIndex ) {
|
86 |
// 4 here is the column where my statuses are.
|
87 |
var status_middle = $(aData[4]);
|
88 |
var status = $(status_middle[0]).text();
|
89 |
if (( status == "EXPIRED" || status == "ADMININACTIVE" || status == "ERROR") && ($('#hide_noaction').attr('checked'))) {
|
90 |
return false;
|
91 |
}
|
92 |
else {
|
93 |
return true;
|
94 |
}
|
95 |
|
96 |
});
|
97 |
var oTable = $('#routes_table').dataTable();
|
98 |
oTable.fnDraw();
|
99 |
$('#hide_noaction').change( function(){
|
100 |
var noaction = $('#hide_noaction').attr('checked');
|
101 |
if (noaction == true){
|
102 |
$("#hide_noaction").button( "option", "label", "Show Expired, AdminInactive, Error" );
|
103 |
}
|
104 |
else{
|
105 |
$("#hide_noaction").button( "option", "label", "Hide Expired, AdminInactive, Error" );
|
106 |
}
|
107 |
createCookie("noaction", noaction, 30);
|
108 |
oTable.fnDraw();
|
109 |
});
|
110 |
|
111 |
$( ".button_place #routebutton" ).button({
|
112 |
icons: {
|
113 |
primary: "ui-icon-circle-plus"
|
114 |
},
|
115 |
});
|
116 |
$( " .edit_button" ).button({
|
117 |
icons: {
|
118 |
primary: "ui-icon-wrench"
|
119 |
},
|
120 |
});
|
121 |
$( " .del_button" ).button({
|
122 |
icons: {
|
123 |
primary: "ui-icon-circle-close"
|
124 |
},
|
125 |
})
|
126 |
.click(function(){
|
127 |
$('#dialog').dialog('open');
|
128 |
return false;
|
129 |
});
|
130 |
$("#consolebutton").button({
|
131 |
icons: {
|
132 |
primary: "ui-icon-image"
|
133 |
},
|
134 |
})
|
135 |
.click(function(){
|
136 |
$("#consolebutton").stop().stop();
|
137 |
$("#consolebutton").css('color', '#555555');
|
138 |
$('#console').dialog('open');
|
139 |
return false;
|
140 |
});
|
141 |
|
142 |
$(".expiresclass").tooltip();
|
143 |
|
144 |
});
|
145 |
|
146 |
function delete_route(route){
|
147 |
route_name = route;
|
148 |
$('#route_to_delete').text(route_name);
|
149 |
return false;
|
150 |
}
|
151 |
|
152 |
|
153 |
|
154 |
</script>
|
155 |
<style type="text/css"> |
156 |
#console { |
157 |
background: none repeat scroll 0 0 #36102a !important; |
158 |
color: #edeae8 !important; |
159 |
font-family: monospace !important; |
160 |
} |
161 |
.message { |
162 |
font-family: monospace !important; |
163 |
} |
164 |
.tooltip { |
165 |
display:none; |
166 |
background:transparent url(/static/black_arrow.png); |
167 |
font-size:12px; |
168 |
height:70px; |
169 |
width:160px; |
170 |
padding:25px; |
171 |
color:#fff; |
172 |
} |
173 |
|
174 |
</style>
|
175 |
{% endblock %} |
176 |
{% block title %}{% trans "My rules" %}{% endblock %} |
177 |
{% block content %} |
178 |
<div style="float:left"> |
179 |
<h3 style="margin-top: 0px;">{% trans "My rules" %}</h3> |
180 |
</div>
|
181 |
<div class='button_place' style="float:right"> |
182 |
<button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a> |
183 |
</div>
|
184 |
<br><br> |
185 |
<table cellpadding="0" cellspacing="0" border="0" style="width:220px; clear:both;"> |
186 |
<tbody>
|
187 |
<tr>
|
188 |
<td align="left"><input type="checkbox" id="hide_noaction" name="hide_noaction" value="Hide" /><label for="hide_noaction">Hide Expired, AdminInactive, Error</label></td> |
189 |
</tr>
|
190 |
</tbody>
|
191 |
</table>
|
192 |
<br>
|
193 |
<table class="display" width="100%" id="routes_table"> |
194 |
<thead>
|
195 |
<tr>
|
196 |
<th>Id</th> |
197 |
<th>{% trans "Name" %}</th> |
198 |
<th>{% trans "Match" %}</th> |
199 |
<th style="text-align: center;">{% trans "Then" %}</th> |
200 |
<th style="text-align: center; ">{% trans "Status" %}</th> |
201 |
{% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %} |
202 |
<th style="text-align: center;">{% trans "Applier" %}</th> |
203 |
<th style="text-align: center;">{% trans "Expires" %}</th> |
204 |
<th style="text-align: center;">{% trans "Response" %}</th> |
205 |
<th style="text-align: center; width:180px;">{% trans "Actions" %}</th> |
206 |
</tr>
|
207 |
</thead>
|
208 |
|
209 |
<tbody>
|
210 |
{% for route in routes %} |
211 |
|
212 |
<tr {% ifequal 'ACTIVE' %} class="GradeA" {% else %} class="GradeX" {% endifequal %}> |
213 |
<td>{{ route.pk }}</td> |
214 |
<td>{{ route.name }}</td> |
215 |
<td>{{ route.get_match|safe|escape }}</td> |
216 |
<td style="text-align: center;">{{route.get_then|safe|escape}}</td> |
217 |
<td style="text-align: center; "> |
218 |
<span
|
219 |
{% if %} |
220 |
class="expiresclass" |
221 |
style="border-bottom:2px dashed red;" |
222 |
title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}" |
223 |
{% endif %}>{{route.status}}</span> |
224 |
</td>
|
225 |
{% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %} |
226 |
<td style="text-align: center;">{{ route.applier }}</td> |
227 |
<td style="text-align: center;">{{ route.expires }}</td> |
228 |
<td style="text-align: center;">{{ route.response }}</td> |
229 |
<td style="text-align: center; width:180px;"> |
230 |
{% ifequal route.status 'ACTIVE' %} |
231 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> |
232 |
<button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Del</button> |
233 |
<a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a> |
234 |
{% else %} |
235 |
{% ifequal route.status 'INACTIVE' %} |
236 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Reactivate</a> |
237 |
{% else %} |
238 |
{% ifequal route.status 'OUTOFSYNC' %} |
239 |
<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">ReSync</a> |
240 |
{% else %} |
241 |
- |
242 |
{% endifequal %} |
243 |
{% endifequal %} |
244 |
{% endifequal %} |
245 |
</td>
|
246 |
</tr>
|
247 |
|
248 |
{% endfor %} |
249 |
</tbody>
|
250 |
</table>
|
251 |
|
252 |
<div id="dialog" title="Delete Route"> |
253 |
<p>You are about to delete rule <strong><span id="route_to_delete"></span></strong></p> |
254 |
<p>Deleting the rule will automatically remove the configuration from the network and mark this route as inactive.</p> |
255 |
<p>Are you sure you want to proceed?</p> |
256 |
</div>
|
257 |
<div id="console" title="Console"> |
258 |
{% include "poll.html" %} |
259 |
</div>
|
260 |
{% endblock %} |