Added more translations...
[flowspy] / templates / user_routes.html
index 61a5aa3..9786be5 100644 (file)
 {% extends "base.html" %}
 {% load i18n %}
 {% block extrahead %}
+{% if user.is_authenticated %}
+<script type="text/javascript" src="{% url load-js 'poller' %}"></script>
+{% endif %}
 <script type="text/javascript" src="/static/js/jquery.dataTables.js"></script>
+<link rel="stylesheet" type="text/css" href="/static/css/engage.itoggle.css"/>
+<script type="text/javascript" src="/static/js/engage.itoggle-min.js"></script>
 <script type="text/javascript">
-       $(document).ready( function(){
-               $('#dialog').dialog({
-                       height: 220,
-            width: 300,
-                       modal: true,
-                       autoOpen: false,
-                       buttons: {
-               'Delete': function() {
-               route = $('#route_to_delete').text();
-               route_url_id = '#del_route_'+route;
-               url = $(route_url_id).attr('href');
-                       $.ajax({
-                       url: url ,
-                       cache: false,
-                       success: function(data) {
-                               $('#dialog').dialog('close');
-                         }
-               });
-               },
-               Cancel: function() {
-                       $('#dialog').dialog('close');
-               }
-       }
-               });
-               $('#console').dialog({
-                       height: 250,
-            width: 800,
-                       modal: true,
-                       autoOpen: false
-                       });
-                       $('#routes_table').dataTable( {
-                       "bJQueryUI": true,
-                       "oLanguage": {
-                               "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> routes'
-                       },
-                       "iDisplayLength": 25,
-       } );
-       $( ".button_place #routebutton" ).button({
-            icons: {
-                primary: "ui-icon-circle-plus"
-            },
-                       });
-               $( " .edit_button" ).button({
-            icons: {
-                primary: "ui-icon-wrench"
-            },
-                       });
-               $( " .del_button" ).button({
-            icons: {
-                primary: "ui-icon-circle-close"
+$(document).ready(function(){
+    $("#hid_mid").val('');
+    $('#dialog').dialog({
+        height: 250,
+        width: 340,
+        modal: true,
+        autoOpen: false,
+        buttons: {
+            '{% trans "Suspend" %}': function(){
+                route = $('#route_to_delete').text();
+                route_url_id = '#del_route_' + route;
+                url = $(route_url_id).attr('href');
+                $.ajax({
+                    url: url,
+                    cache: false,
+                    success: function(data){
+                        $('#dialog').dialog('close');
+                        window.setTimeout('location.reload()', 1000);
+                    }
+                });
             },
-                       })
-                       .click(function(){
-                               $('#dialog').dialog('open');
-                               return false;
-                       });
-               $("#consolebutton").button({
-            icons: {
-                primary: "ui-icon-image"
+            '{% trans "Cancel" %}': function(){
+                $('#dialog').dialog('close');
             },
-                       })
-                       .click(function(){
-                               $("#consolebutton").stop().stop();
-                               $("#consolebutton").css('color', '#555555');
-                               $('#console').dialog('open');
-                               return false;
-                       });
-               });
+        
+        
+        },
+        close: function(){
+            update_val = $("#hid_mid").val();
+            if (update_val == 'UPDATED') {
+                $("#hid_mid").val('');
+                window.setTimeout('location.reload()', 500);
+            }
+        }
+    });
+    $('#console').dialog({
+        height: 250,
+        width: 800,
+        modal: true,
+        autoOpen: false,
+               overlay: { opacity: 0.5, background: 'black'},
+        close: function(){
+            update_val = $("#hid_mid").val();
+            if (update_val == 'UPDATED') {
+                $("#hid_mid").val('');
+                window.setTimeout('location.reload()', 500);
+            }
+        }
+    });
+    $('#console').parent().css('opacity', 0.9);
+       $('#console').parent().css('filter', 'alpha(opacity=90)');
+    var oTable = $('#routes_table').dataTable({
+        "bJQueryUI": true,
+        "aoColumns": [{
+            "bVisible": false,
+            "bSearchable": false,
+            "bSortable": false
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bSearchable": true,
+            "bSortable": true
+        }, {
+            "bVisible": true,
+            "bSearchable": false,
+            "bSortable": false
+        }],
+        "aaSorting": [[0, 'desc']],
+        "iDisplayLength": 25,
+        "oLanguage": {
+               "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "rules" %}',
+            "sProcessing":   "Processing...",
+            "sZeroRecords": '{% trans "No records to display" %}',
+            "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
+            "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
+            "sInfoFiltered": "(filtered from _MAX_ total entries)",
+            "sInfoPostFix":  "",
+            "sSearch":       '{% trans "Search:" %}',
+            "sUrl":          "",
+            "oPaginate": {
+                "sFirst":    '{% trans "First" %}',
+                "sPrevious": '{% trans "Previous" %}',
+                "sNext":     '{% trans "Next" %}',
+                "sLast":     '{% trans "Last" %}'
+            }
+        }
+    });
+    
+    oTable.fnDraw();
+    
+    $('input[name="status_filter"]').click(function(){
+    
+        //slice off the last '|' or it doesn't work
+        //also be sure to use the third parameter
+    });
+    
+    $(".button_place #routebutton").button({
+        icons: {
+            primary: "ui-icon-circle-plus"
+        },
+    });
+    $(".edit_button").button({
+        icons: {
+            primary: "ui-icon-wrench"
+        },
+    }).css('width','100px');;
+    $(" .del_button").button({
+        icons: {
+            primary: "ui-icon-circle-close"
+        },
+    }).click(function(){
+        $('#dialog').dialog('open');
+        return false;
+    }).css('width','100px');
+    $("#consolebutton").button({
+        icons: {
+            primary: "ui-icon-image"
+        },
+    }).click(function(){
+        $("#consolebutton").stop().stop();
+        $("#consolebutton").css('color', '#555555');
+        $('#console').dialog('open');
+        return false;
+    });
+    
+       $(".statustootipclass").tooltip();
+    $(".expiresclass").tooltip();
+       $(".commentclass").tooltip();
+    var reg_exp = '';
+    var checkboxs = document.getElementsByName('status_filter');
+    for (var i = 0, inp; inp = checkboxs[i]; i++) {
+        checkCookie = readCookie("cookie_" + inp.value);
+        if (checkCookie) {
+            if (checkCookie == 'true') {
+                $(inp).attr('checked', true);
+            }
+            else {
+                $(inp).attr('checked', false);
+            }
+        }
+        
+        if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
+            reg_exp = reg_exp + inp.value + '|';
+        }
+        
+    }
+       if (reg_exp == '') {
+            reg_exp = 'XXX|'
+        }
+    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
+    
+    $('input[name="status_filter"]').iToggle({
+        type: 'checkbox',
+        onSlide: function(){
+            var reg_exp = '';
+            var checkboxs = document.getElementsByName('status_filter');
+            
+            for (var i = 0, inp; inp = checkboxs[i]; i++) {
+                if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
+                    reg_exp = reg_exp + inp.value + '|';
+                }
+                createCookie("cookie_" + inp.value, inp.checked, 30);
+            }
+            //passing an empty string will result in no filter
+            //thus, it must be set to something that will not exist in the column
+            if (reg_exp == '') {
+                reg_exp = 'X|'
+            }
+            oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
+        },
+    });
+});
                
 function delete_route(route){
        route_name = route;
@@ -90,68 +215,125 @@ function delete_route(route){
        .message {
                font-family: monospace !important;
        }
+       .tooltip {
+       display:none;
+       background:transparent url(/static/black_arrow.png);
+       font-size:12px;
+       height:70px;
+       width:160px;
+       padding:25px;
+       color:#fff;     
+}
        
 </style>
 {% endblock %}
-{% block title %}{% trans "My routes" %}{% endblock %}
+{% block title %}{% trans "My rules" %}{% endblock %}
 {% block content %}
+{% csrf_token %}
 <div style="float:left">
-       <h3 style="margin-top: 0px;">{% trans "My routes" %}</h3>
+       <h3 style="margin-top: 0px;">{% trans "My rules" %}</h3>
 </div>
 <div class='button_place' style="float:right">
-       <button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Route</a>
+       <button id="consolebutton">{% trans "Console" %}</button> <a href="{% url add-route %}" id="routebutton">{% trans "Add Rule" %}</a>
 </div>
+<br><br>
+
+<div id='itoggle'>
+<table cellpadding="0" cellspacing="0" border="0" class="display" style='width:200px;'>
+                               <tbody>
+                                       <tr>
+                                       <th>ACTIVE</th><th>SUSPENDED</th><th>ERROR</th><th>PENDING</th>
+                                       </tr>
+                                       <tr class="on_off">
+                                       <td>
+                                           <input type="checkbox" class="onoff" name="status_filter" value="ACTIVE" checked id="show_active"/>
+                                       </td>
+                                   
+                                       <td>
+                                           <input type="checkbox" class="onoff" name="status_filter" value="SUSPENDED" id="show_inactive"/>
+                                       </td>                               
+                                       <td>
+                                           <input type="checkbox" class="onoff" name="status_filter" value="ERROR" id="show_error"/>
+                                       </td>
+                                  
+                                       <td>
+                                           <input type="checkbox" class="onoff" name="status_filter" value="PENDING" id="show_pending"/>
+                                       </td>
+                                   </tr>
+                               </tbody>
+                       </table>
+                       </div>
+       <table class="display" width="100%" id="nodes_table">
 <table class="display" width="100%" id="routes_table">
 <thead>
 <tr>
+       <th>Id</th>
        <th>{% trans "Name" %}</th>
        <th>{% trans "Match" %}</th>
        <th style="text-align: center;">{% trans "Then" %}</th>
-       <th style="text-align: center;">{% trans "Status" %}</th>
+       <th style="text-align: center; ">{% trans "Status" %}</th>
        {% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %}
        <th style="text-align: center;">{% trans "Applier" %}</th>
        <th style="text-align: center;">{% trans "Expires" %}</th>
        <th style="text-align: center;">{% trans "Response" %}</th>
-       <th style="text-align: center; width:140px;">{% trans "Actions" %}</th>
+       <th style="text-align: center; width:180px;">{% trans "Actions" %}</th>
 </tr>
 </thead>
 
 <tbody>
 {% for route in routes %}
 
-<tr {% ifequal route.status 'ACTIVE' %} class="GradeA" {% else %} class="GradeX" {% endifequal %}>
-       <td>{{ route.name }}</td>
+<tr class="GradeC" >
+       <td>{{ route.pk }}</td>
+       <td><span {% if route.comments %}
+       class="commentclass" 
+               style="border-bottom:1px dotted red;" 
+        title="{{route.comments}}"
+               {% endif %}>{{ route.name }}</span></td>
        <td>{{ route.get_match|safe|escape }}</td>
        <td style="text-align: center;">{{route.get_then|safe|escape}}</td>
-       <td style="text-align: center;">{{route.status}}</td>
+       <td style="text-align: center; "><span 
+               {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
+           class="statustootipclass" 
+               style="border-bottom:1px dotted red;" 
+               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>
        {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
        <td style="text-align: center;">{{ route.applier }}</td>
-       <td style="text-align: center;">{{ route.expires }}</td>
-       <td style="text-align: center;">{{ route.response }}</td>
-       <td style="text-align: center;">
+       <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 %}
+               class="expiresclass" 
+               style="border-bottom:2px dashed red;" 
+        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
+               {% endif %}{% endif %}>{{ route.expires }}</span></td>
+       <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>
+       <td style="text-align: center; width:180px;">
                {% ifequal route.status 'ACTIVE' %}
-               <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> 
-               <button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Del</button>
+               <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a> 
+               <button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">{% trans "Suspend" %}</button>
                <a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a>
                {% else %}
-               {% ifequal route.status 'INACTIVE' %}
-               <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Reactivate</a>
+               {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
+               <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "Reactivate" %}</a>
+               {% else %}
+               {% ifequal route.status 'OUTOFSYNC' %}
+               <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
                {% else %}
                -
                {% endifequal %}
-               {% endifequal %}</td>
+               {% endif %}
+               {% endifequal %}
+               </td>
 </tr>
 
 {% endfor %}
 </tbody>
 </table>
 
-<div id="dialog" title="Delete Route">
-               <p>You are about to delete route <strong><span id="route_to_delete"></span></strong></p>
-               <p>Deleting the route will automatically remove the configuration from the network and mark this route as inactive.</p>
-               <p>Are you sure you want to proceed?</p>
+<div id="dialog" title="Suspend Rule">
+               <p>{% blocktrans %}You are about to suspend rule{% endblocktrans %} <strong><span id="route_to_delete"></span></strong></p>
+               <p>{% blocktrans %}Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.{% endblocktrans %}</p>
+               <p>{% blocktrans %}Are you sure you want to proceed?{% endblocktrans %}</p>
 </div>
-<div id="console" title="Console">
+<div id="console" title="{% trans "Console" %}">
                                        {% include "poll.html" %}
 </div>
 {% endblock %}