Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ 861e8360

History | View | Annotate | Download (13.2 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="/fodstatic/js/jquery.dataTables.js"></script>
8
<script type="text/javascript" src="/fodstatic/js/datatables_bootstrap.js"></script>
9

    
10
<script type="text/javascript">
11

12
$(document).ready(function(){
13
        $('[rel=tooltip]').tooltip();
14
    $("#hid_mid").val('');
15
    $('#dialog').dialog({
16
        height: 250,
17
        width: 340,
18
        modal: true,
19
        autoOpen: false,
20
        buttons: {
21
            '{% trans "Deactivate" %}': function(){
22
                route = $('#route_to_delete').text();
23
                route_url_id = '#del_route_' + route;
24
                url = $(route_url_id).attr('href');
25
                $.ajax({
26
                    url: url,
27
                    cache: false,
28
                    success: function(data){
29
                        $('#dialog').dialog('close');
30
                        window.setTimeout('location.reload()', 1000);
31
                    }
32
                });
33
            },
34
            '{% trans "Cancel" %}': function(){
35
                $('#dialog').dialog('close');
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
        $(".button_place #routebutton").button({
63
        icons: {
64
            primary: "ui-icon-circle-plus"
65
        },
66
    });
67
    $(".edit_button").button({
68
        icons: {
69
            primary: "ui-icon-wrench"
70
        },
71
    }).css('margin-bottom','2px');
72
    $(" .del_button").button({
73
        icons: {
74
            primary: "ui-icon-circle-close"
75
        },
76
    }).click(function(){
77
        $('#dialog').dialog('open');
78
        return false;
79
    });
80
    $("#consolebutton").button().click(function(){
81
        $("#consolebutton").stop().stop();
82
        $('#console').dialog('open');
83
        return false;
84
    });
85

86

87
    var oTable = $('#routes_table').dataTable({
88
            "sPaginationType": "bootstrap",
89
            "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
90
        "aoColumns": [{
91
            "bVisible": false,
92
            "bSearchable": false,
93
            "bSortable": false
94
        }, {
95
            "bSearchable": true,
96
            "bSortable": true
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
            "bVisible": true,
117
            "bSearchable": false,
118
            "bSortable": false
119
        }],
120
        "aaSorting": [[0, 'desc']],
121
        "iDisplayLength": 25,
122
        "oSearch": {"bSmart": false, "bRegex":true},
123
        "oLanguage": {
124
                "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "rules" %}',
125
            "sProcessing":   "Processing...",
126
            "sZeroRecords": '{% trans "No records to display" %}',
127
            "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
128
            "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
129
            "sInfoFiltered": "(filtered from _MAX_ total entries)",
130
            "sInfoPostFix":  "",
131
            "sSearch":       '{% trans "Search:" %}',
132
            "sUrl":          "",
133
            "oPaginate": {
134
                "sFirst":    '{% trans "First" %}',
135
                "sPrevious": '{% trans "Previous" %}',
136
                "sNext":     '{% trans "Next" %}',
137
                "sLast":     '{% trans "Last" %}'
138
            }
139
        }
140
    });
141

142
    oTable.fnDraw();
143
    
144
    var reg_exp = '';
145
    var checkboxs = document.getElementsByName('status_filter');
146
    for (var i = 0, inp; inp = checkboxs[i]; i++) {
147
        checkCookie = readCookie("cookie_" + inp.value);
148
        if (checkCookie) {
149
            if (checkCookie == 'true') {
150
                $(inp).addClass('active');
151
            }
152
            else {
153
                $(inp).removeClass('active');
154
            }
155
        }
156
        
157
        if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
158
            reg_exp = reg_exp + inp.value + '|';
159
        }
160
        
161
    }
162
        if (reg_exp == '') {
163
            reg_exp = '|'
164
        }
165
        
166
        
167
    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
168
    
169
    
170
    $('button[name="status_filter"]').click(function(){
171
            var reg_exp = '';
172
        var checkboxs = document.getElementsByName('status_filter');
173
        $(this).button('toggle');
174
        for (var i = 0, inp; inp = checkboxs[i]; i++) {
175
            if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
176
                reg_exp = reg_exp + inp.value + '|';
177
            }
178
            createCookie("cookie_" + inp.value, $(inp).hasClass('active'), 30);
179
        }
180
        //passing an empty string will result in no filter
181
        //thus, it must be set to something that will not exist in the column
182
        if (reg_exp == '') {
183
            reg_exp = '|'
184
        }
185
        oTable.fnFilter(reg_exp.slice(0, -1), 4, regex=true);
186
        return false;
187
    });
188

189
    
190
});
191
                
192
function delete_route(route){
193
        route_name = route;
194
        $('#route_to_delete').text(route_name);
195
        return false;
196
}                
197
                
198
                
199

    
200
</script>
201
<style type="text/css">
202
        #console {
203
                background: none repeat scroll 0 0 #36102a !important;
204
                color: #edeae8 !important;
205
                font-family: monospace !important;
206
        }
207
        .message {
208
                font-family: monospace !important;
209
        }
210
        
211
        
212
</style>
213
{% endblock %}
214
{% block title %}{% trans "My rules" %}{% endblock %}
215
{% block content %}
216
{% csrf_token %}
217
<div class="row-fluid">
218
<div class="span2">
219
<div style="float:left">
220
        <h4>{% trans "My rules" %}</h4>
221
</div>
222
</div>
223

    
224
<div class="span10">
225
<div class='button_place' style="float:right">
226
        <button id="consolebutton" class="btn btn-inverse">
227
                <i class="icon-tasks icon-white" style="align:left;"></i>{% trans "Console" %}</button>
228
                <a href="{% url add-route %}" id="routebutton" class="btn btn-primary"><i class="icon-plus-sign icon-white"></i>{% trans "Add Rule" %}</a>
229
</div>
230
</div>
231
</div>
232
<hr>
233
<div class="row-fluid" style="padding-top:30px;">
234

    
235
<div id='itoggle' class="span12" style="text-align:center;">
236
   <div class="btn-group" data-toggle="buttons-checkbox">
237
    <button type="button" class="btn btn-small" name="status_filter" value="ACTIVE" id="show_active">Active</button>
238
    <button type="button" class="btn btn-small" name="status_filter" value="DEACTIVATED" id="show_inactive">Deactivated</button>
239
    <button type="button" class="btn btn-small" name="status_filter" value="ERROR" id="show_error">Error</button>
240
    <button type="button" class="btn btn-small" name="status_filter" value="PENDING" id="show_pending">Pending</button>
241
    </div>
242
                        </div>
243

    
244
</div>
245

    
246
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="routes_table">
247
<thead>
248
<tr>
249
        <th>Id</th>
250
        <th>{% trans "Name" %}</th>
251
        <th>{% trans "Match" %}</th>
252
        <th style="text-align: center;">{% trans "Then" %}</th>
253
        <th style="text-align: center; ">{% trans "Status" %}</th>
254
        {% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %}
255
        <th style="text-align: center;">{% trans "Applier" %}</th>
256
        <th style="text-align: center;">{% trans "Expires" %}</th>
257
        <th style="text-align: center;">{% trans "Response" %}</th>
258
        <th style="text-align: center; width:180px;">{% trans "Actions" %}</th>
259
</tr>
260
</thead>
261

    
262
<tbody>
263
{% for route in routes %}
264

    
265
<tr class="GradeC" >
266
        <td>{{ route.pk }}</td>
267
        
268
        <td {% if  %}style="color: #0088CC;"{% endif %}>{% if route.comments %}<span rel="tooltip" data-placement="top" title="{{route.comments}}">{{ route.name }}</span>{% else %}{{ route.name }}{% endif %}</td>
269
        
270
        <td>{{ route.get_match|safe|escape }}</td>
271
        
272
        <td style="text-align: center;">{{route.get_then|safe|escape}}</td>
273
        
274
        <td style="text-align: center; ">{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
275
                {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}<span class="label">DEACTIVATED</span>{% else %}{% if route.status == 'OUTOFSYNC' %}<span class="label label-important">ERROR</span>{% else %}{{route.status}}{% endif %}{% endif %}{% else %}{% if route.status == 'ACTIVE' %}<span class="label label-success">{{route.status}}</span>{% else %}{% if route.status == 'PENDING' %}<span class="label label-info">{{route.status}}</span>{% else %}<span class="label label-important">{{route.status}}</span>{% endif %}{% endif %}{% endif %}</td>
276
                
277
        {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
278
        
279
        <td style="text-align: center;">{{ route.applier }}</td>
280
        
281
        <td style="text-align: center;" nowrap
282
                <span {% if  == 'EXPIRED' or  == 'ADMININACTIVE' or  == 'INACTIVE' or  == 'OUTOFSYNC'%}{% else %}{% if  %}
283
                data-placement="top"
284
                rel = 'tooltip'
285
                style="border-bottom:1px dashed red;" 
286
        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
287
                {% endif %}{% endif %}>{{ route.expires|date:"d M y" }}</span></td>
288
                
289
        <td style="text-align: center; {% if route.status == 'EXPIRED' %} color: #0088CC; {% endif %}">
290
                {% if route.status == 'EXPIRED' %}
291
                <span rel="tooltip"
292
                        {% if  == 'EXPIRED' or  == 'ADMININACTIVE' or  == 'INACTIVE' or  == 'OUTOFSYNC'%}  
293
                        data-placement="top" 
294
                        title = "{% ifequal route.status 'INACTIVE' %}
295
                                                {% trans 'Deactivated by user' %}
296
                                         {% else %}
297
                                                {% ifequal route.status 'ADMININACTIVE' %}
298
                                                        {% trans 'Deactivated by administrator' %}
299
                                                {% else %}
300
                                                        {% ifequal route.status 'EXPIRED' %}
301
                                                                {% trans 'Deactivated due to expiration' %}
302
                                                        {% else %}
303
                                                                {% ifequal route.status 'OUTOFSYNC' %}
304
                                                                        {% trans 'Syncronization error. Configuration in device differs from rule' %}
305
                                                                {% endifequal %}
306
                                                        {% endifequal %}
307
                                                {% endifequal %}
308
                                         {% endifequal %}"
309
                        {% endif %}>{% trans "Rule expired" %}</span>{% else %}{% if route.status == 'OUTOFSYNC' %}{% trans 'Syncronization error. Configuration in device differs from rule' %}{% else %}{% if route.status == 'ADMININACTIVE' %}{% trans "Deactivated by administrator" %}{% else %}{% if route.status == 'INACTIVE' %}{% trans "Deactivated by user" %}{% else %}{{ route.response }}{% if route.status == 'PENDING' %}<img src="/fodstatic/dots.gif">{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}</td>
310
                        
311
        <td style="text-align: center; width:180px;">
312
                {% ifequal route.status 'ACTIVE' %}
313
                <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a> 
314
                <button class="del_button btn btn-small" id="{{route.name}}" onclick="javascript:delete_route(this.id)">{% trans "Deactivate" %}</button>
315
                <a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}" class="btn btn btn-danger btn-small"></a>
316
                {% else %}
317
                {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
318
                <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Reactivate" %}</a>
319
                {% else %}
320
                {% ifequal route.status 'OUTOFSYNC' %}
321
                <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
322
                {% else %}
323
                {% ifequal route.status 'ERROR' %}
324
                <a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Fix it!" %}</a>
325
                {% else %}
326
                -
327
                {% endifequal %}
328
                {% endifequal %}
329
                {% endif %}
330
                {% endifequal %}
331
                </td>
332
</tr>
333

    
334
{% endfor %}
335
</tbody>
336
</table>
337
<div id="dialog" title="{% trans "Deactivate " %}">
338
                <p>{% blocktrans %}You are about to deactivate rule{% endblocktrans %} <strong><span id="route_to_delete"></span></strong></p>
339
                <p>{% blocktrans %}Deactivating the rule will automatically remove the configuration from the network and mark this rule as inactive.{% endblocktrans %}</p>
340
                <p>{% blocktrans %}Are you sure you want to proceed?{% endblocktrans %}</p>
341
</div>
342
<div id="console" title="{% trans "Console" %}">
343
                                        {% include "poll.html" %}
344
</div>
345
{% endblock %}