Added a hide columns with no actions checkbox. Added cookie to that. Minor cleanup
authorLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Sun, 11 Dec 2011 22:10:51 +0000 (00:10 +0200)
committerLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Sun, 11 Dec 2011 22:10:51 +0000 (00:10 +0200)
static/js/jquery.cookie.js [new file with mode: 0644]
templates/base.html
templates/user_routes.html

diff --git a/static/js/jquery.cookie.js b/static/js/jquery.cookie.js
new file mode 100644 (file)
index 0000000..3c0c868
--- /dev/null
@@ -0,0 +1,24 @@
+function createCookie(name,value,days) {
+       if (days) {
+               var date = new Date();
+               date.setTime(date.getTime()+(days*24*60*60*1000));
+               var expires = "; expires="+date.toGMTString();
+       }
+       else var expires = "";
+       document.cookie = name+"="+value+expires+"; path=/";
+}
+
+function readCookie(name) {
+       var nameEQ = name + "=";
+       var ca = document.cookie.split(';');
+       for(var i=0;i < ca.length;i++) {
+               var c = ca[i];
+               while (c.charAt(0)==' ') c = c.substring(1,c.length);
+               if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+       }
+       return null;
+}
+
+function eraseCookie(name) {
+       createCookie(name,"",-1);
+}
\ No newline at end of file
index a4374f4..8890f8e 100644 (file)
@@ -11,6 +11,7 @@
 <link rel="stylesheet" type="text/css" href="/static/css/smoothness/jquery-ui-1.8.13.custom.css">
 <script type="text/javascript" src="/static/js/jquery-ui-1.8.12.custom.min.js"></script>
 <script type="text/javascript" src="/static/js/jquery.tooltip.min.js"></script>
+<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
 <script type="text/javascript">
 
        function setlang(lang){
                $("#langform").submit();
        }
 
-//function highlight(elemId){
-//    var elem = $(elemId);
-//    elem.css("background-color", "#ffffbb");
-//    setTimeout(function() { $(elemId).animate({ backgroundColor: "white" }, 2000)}, 1500);
-//}
-//
-//   
-//$(document).ready( function(){
-//     if (document.location.hash) {
-//         highlight(document.location.hash);
-//     }
-//     $('a[href*=#]').click(function(){
-//         var elemId = '#' + $(this).attr('href').split('#')[1];
-//         highlight(elemId);
-//     });
-//});
-
 </script>
 {% block extrahead %}{% endblock %}
 </head>
index f200f9c..e6d4605 100644 (file)
@@ -7,6 +7,10 @@
 <script type="text/javascript" src="/static/js/jquery.dataTables.js"></script>
 <script type="text/javascript">
        $(document).ready( function(){
+               var noaction = readCookie('noaction');
+               if (noaction == 'true'){
+                       $('#hide_noaction').attr('checked','checked');
+               }
                $("#hid_mid").val('');
                $('#dialog').dialog({
                        height: 220,
@@ -55,7 +59,7 @@
                    }
                });
                        
-               $('#routes_table').dataTable( {
+               $('#routes_table').dataTable({
                        "bJQueryUI": true,
                        "aoColumns": [ 
                                {"bVisible": false, "bSearchable": false,"bSortable": false },
                                "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
                        },
                        "iDisplayLength": 25,
-       } );
+       });
+       $.fn.dataTableExt.afnFiltering = new Array();
+       $.fn.dataTableExt.afnFiltering.push(
+       function( oSettings, aData, iDataIndex ) {
+               // 4 here is the column where my statuses are.
+               var status_middle = $(aData[4]);
+               var status = $(status_middle[0]).text();
+               if (( status == "EXPIRED" || status == "ADMININACTIVE" || status == "ERROR") && ($('#hide_noaction').attr('checked'))) {
+                       return false;
+               }
+               else {
+                       return true;
+               }
+               
+       });
+       var oTable = $('#routes_table').dataTable();
+       oTable.fnDraw();
+       $('#hide_noaction').change( function(){
+                       var noaction = $('#hide_noaction').attr('checked');
+                       createCookie("noaction", noaction, 30);
+                       oTable.fnDraw(); 
+               });
+       
        $( ".button_place #routebutton" ).button({
             icons: {
                 primary: "ui-icon-circle-plus"
@@ -147,6 +173,18 @@ function delete_route(route){
 <div class='button_place' style="float:right">
        <button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a>
 </div>
+<br><br>
+<table cellpadding="0" cellspacing="0" border="0" style="width:220px; clear:both;">
+       <tbody>
+               <tr>
+                       <td align="left">Hide Expired, AdminInactive, Error</td>
+                       <td align="left">
+                               <input type="checkbox" id="hide_noaction" name="hide_noaction" value="Hide" />
+                       </td>
+               </tr>
+       </tbody>
+</table>
+<br>
 <table class="display" width="100%" id="routes_table">
 <thead>
 <tr>
@@ -177,8 +215,7 @@ function delete_route(route){
                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 %}>{{route.status}}
-               </span>
+               {% endif %}>{{route.status}}</span>
        </td>
        {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
        <td style="text-align: center;">{{ route.applier }}</td>