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