Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ 736b67bf

History | View | Annotate | Download (11.5 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
<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
            '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
            Cancel: function(){
33
                $('#dialog').dialog('close');
34
            },
35
        },
36
        close: function(){
37
            update_val = $("#hid_mid").val();
38
            if (update_val == 'UPDATED') {
39
                $("#hid_mid").val('');
40
                window.setTimeout('location.reload()', 500);
41
            }
42
        }
43
    });
44
    $('#console').dialog({
45
        height: 250,
46
        width: 800,
47
        modal: true,
48
        autoOpen: false,
49
                overlay: { opacity: 0.5, background: 'black'},
50
        close: function(){
51
            update_val = $("#hid_mid").val();
52
            if (update_val == 'UPDATED') {
53
                $("#hid_mid").val('');
54
                window.setTimeout('location.reload()', 500);
55
            }
56
        }
57
    });
58
    $('#console').parent().css('opacity', 0.9);
59
        $('#console').parent().css('filter', 'alpha(opacity=90)');
60
        $(".button_place #routebutton").button({
61
        icons: {
62
            primary: "ui-icon-circle-plus"
63
        },
64
    });
65
    $(".edit_button").button({
66
        icons: {
67
            primary: "ui-icon-wrench"
68
        },
69
    }).css('width','100px');;
70
    $(" .del_button").button({
71
        icons: {
72
            primary: "ui-icon-circle-close"
73
        },
74
    }).click(function(){
75
        $('#dialog').dialog('open');
76
        return false;
77
    }).css('width','100px');
78
    $("#consolebutton").button({
79
        icons: {
80
            primary: "ui-icon-image"
81
        },
82
    }).click(function(){
83
        $("#consolebutton").stop().stop();
84
        $("#consolebutton").css('color', '#555555');
85
        $('#console').dialog('open');
86
        return false;
87
    });
88
        $(".statustootipclass").tooltip();
89
    $(".expiresclass").tooltip();
90
        $(".commentclass").tooltip();
91
    var oTable = $('#routes_table').dataTable({
92
        "bJQueryUI": true,
93
        "aoColumns": [{
94
            "bVisible": false,
95
            "bSearchable": false,
96
            "bSortable": false
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
            "bSearchable": true,
117
            "bSortable": true
118
        }, {
119
            "bVisible": true,
120
            "bSearchable": false,
121
            "bSortable": false
122
        }],
123
        "aaSorting": [[0, 'desc']],
124
        "oLanguage": {
125
            "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
126
        },
127
        "iDisplayLength": 25,
128
    });
129
    oTable.fnDraw();
130
    $('input[name="status_filter"]').click(function(){
131
        //slice off the last '|' or it doesn't work
132
        //also be sure to use the third parameter
133
    });
134
    
135
    
136
    var reg_exp = '';
137
    var checkboxs = document.getElementsByName('status_filter');
138
    for (var i = 0, inp; inp = checkboxs[i]; i++) {
139
        checkCookie = readCookie("cookie_" + inp.value);
140
        if (checkCookie) {
141
            if (checkCookie == 'true') {
142
                $(inp).attr('checked', true);
143
            }
144
            else {
145
                $(inp).attr('checked', false);
146
            }
147
        }
148
        
149
        if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
150
            reg_exp = reg_exp + inp.value + '|';
151
        }
152
        
153
    }
154
        if (reg_exp == '') {
155
            reg_exp = 'XXX|'
156
        }
157
    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
158
    
159
    $('input[name="status_filter"]').iToggle({
160
        type: 'checkbox',
161
        onSlide: function(){
162
            var reg_exp = '';
163
            var checkboxs = document.getElementsByName('status_filter');
164
            
165
            for (var i = 0, inp; inp = checkboxs[i]; i++) {
166
                if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
167
                    reg_exp = reg_exp + inp.value + '|';
168
                }
169
                createCookie("cookie_" + inp.value, inp.checked, 30);
170
            }
171
            //passing an empty string will result in no filter
172
            //thus, it must be set to something that will not exist in the column
173
            if (reg_exp == '') {
174
                reg_exp = 'X|'
175
            }
176
            oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
177
        },
178
    });
179
});
180
                
181
function delete_route(route){
182
        route_name = route;
183
        $('#route_to_delete').text(route_name);
184
        return false;
185
}                
186
                
187
                
188

    
189
</script>
190
<style type="text/css">
191
        #console {
192
                background: none repeat scroll 0 0 #36102a !important;
193
                color: #edeae8 !important;
194
                font-family: monospace !important;
195
        }
196
        .message {
197
                font-family: monospace !important;
198
        }
199
        .tooltip {
200
        display:none;
201
        background:transparent url(/static/black_arrow.png);
202
        font-size:12px;
203
        height:70px;
204
        width:160px;
205
        padding:25px;
206
        color:#fff;        
207
}
208
        
209
</style>
210
{% endblock %}
211
{% block title %}{% trans "My rules" %}{% endblock %}
212
{% block content %}
213
{% csrf_token %}
214
<div style="float:left">
215
        <h3 style="margin-top: 0px;">{% trans "My rules" %}</h3>
216
</div>
217
<div class='button_place' style="float:right">
218
        <button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a>
219
</div>
220
<br><br>
221

    
222
<div id='itoggle'>
223
<table cellpadding="0" cellspacing="0" border="0" class="display" style='width:200px;'>
224
                                <tbody>
225
                                        <tr>
226
                                        <th>ACTIVE</th><th>SUSPENDED</th><th>ERROR</th><th>PENDING</th>
227
                                        </tr>
228
                                        <tr class="on_off">
229
                                        <td>
230
                                            <input type="checkbox" class="onoff" name="status_filter" value="ACTIVE" checked ="show_active"/>
231
                                        </td>
232
                                    
233
                                        <td>
234
                                            <input type="checkbox" class="onoff" name="status_filter" value="SUSPENDED" id="show_inactive"/>
235
                                        </td>                                    
236
                                        <td>
237
                                            <input type="checkbox" class="onoff" name="status_filter" value="ERROR" id="show_error"/>
238
                                        </td>
239
                                   
240
                                        <td>
241
                                            <input type="checkbox" class="onoff" name="status_filter" value="PENDING" id="show_pending"/>
242
                                        </td>
243
                                    </tr>
244
                                </tbody>
245
                        </table>
246
                        </div>
247
<table class="display" width="100%" id="routes_table">
248
<thead>
249
<tr>
250
        <th>Id</th>
251
        <th>{% trans "Name" %}</th>
252
        <th>{% trans "Match" %}</th>
253
        <th style="text-align: center;">{% trans "Then" %}</th>
254
        <th style="text-align: center; ">{% trans "Status" %}</th>
255
        {% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %}
256
        <th style="text-align: center;">{% trans "Applier" %}</th>
257
        <th style="text-align: center;">{% trans "Expires" %}</th>
258
        <th style="text-align: center;">{% trans "Response" %}</th>
259
        <th style="text-align: center; width:180px;">{% trans "Actions" %}</th>
260
</tr>
261
</thead>
262

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

    
266
<tr class="GradeC" >
267
        <td>{{ route.pk }}</td>
268
        <td><span {% if  %} class="commentclass" style="border-bottom:1px dotted red;" title="{{route.comments}}"        {% endif %}>{{ route.name }}</span></td>
269
        <td>{{ route.get_match|safe|escape }}</td>
270
        <td style="text-align: center;">{{route.get_then|safe|escape}}</td>
271
        <td style="text-align: center; "><span {% if  == 'EXPIRED' or  == 'ADMININACTIVE' or  == 'INACTIVE' or  == 'OUTOFSYNC'%} class="statustootipclass" style="border-bottom:1px dotted red;" 
272
                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>
273
        {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
274
        <td style="text-align: center;">{{ route.applier }}</td>
275
        <td style="text-align: center;"><span {% if  == 'EXPIRED' or  == 'ADMININACTIVE' or  == 'INACTIVE' or  == 'OUTOFSYNC'%}{% else %}{% if  %}
276
                class="expiresclass" 
277
                style="border-bottom:2px dashed red;" 
278
        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
279
                {% endif %}{% endif %}>{{ route.expires }}</span></td>
280
        <td style="text-align: center;">{% if route.status == 'EXPIRED' %}Rule expired{% else %}{% if route.status == 'ADMININACTIVE' %}Suspended by administrator{% else %}{% if route.status == 'INACTIVE' %}Suspended by user{% else %}{{ route.response }}{% if route.status == 'PENDING' %}<img src="/static/dots.gif">{% endif %}{% endif %}{% endif %}{% endif %}</td>
281
        <td style="text-align: center; width:180px;">
282
                {% ifequal route.status 'ACTIVE' %}
283
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> 
284
                <button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Suspend</button>
285
                <a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a>
286
                {% else %}
287
                {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
288
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Reactivate</a>
289
                {% else %}
290
                {% ifequal route.status 'OUTOFSYNC' %}
291
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">ReSync</a>
292
                {% else %}
293
                {% ifequal route.status 'ERROR' %}
294
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Fix it!</a>
295
                {% else %}
296
                -
297
                {% endifequal %}
298
                {% endifequal %}
299
                {% endif %}
300
                {% endifequal %}
301
                </td>
302
</tr>
303

    
304
{% endfor %}
305
</tbody>
306
</table>
307

    
308
<div id="dialog" title="Suspend Rule">
309
                <p>You are about to suspend rule <strong><span id="route_to_delete"></span></strong></p>
310
                <p>Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.</p>
311
                <p>Are you sure you want to proceed?</p>
312
</div>
313
<div id="console" title="Console">
314
                                        {% include "poll.html" %}
315
</div>
316
{% endblock %}