Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ ff8bc42e

History | View | Annotate | Download (11.4 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
        
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
        "oLanguage": {
96
            "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
97
        },
98
        "iDisplayLength": 25,
99
    });
100
    
101
    oTable.fnDraw();
102
    
103
    $('input[name="status_filter"]').click(function(){
104
    
105
        //slice off the last '|' or it doesn't work
106
        //also be sure to use the third parameter
107
    });
108
    
109
    $(".button_place #routebutton").button({
110
        icons: {
111
            primary: "ui-icon-circle-plus"
112
        },
113
    });
114
    $(".edit_button").button({
115
        icons: {
116
            primary: "ui-icon-wrench"
117
        },
118
    }).css('width','100px');;
119
    $(" .del_button").button({
120
        icons: {
121
            primary: "ui-icon-circle-close"
122
        },
123
    }).click(function(){
124
        $('#dialog').dialog('open');
125
        return false;
126
    }).css('width','100px');
127
    $("#consolebutton").button({
128
        icons: {
129
            primary: "ui-icon-image"
130
        },
131
    }).click(function(){
132
        $("#consolebutton").stop().stop();
133
        $("#consolebutton").css('color', '#555555');
134
        $('#console').dialog('open');
135
        return false;
136
    });
137
    
138
        $(".statustootipclass").tooltip();
139
    $(".expiresclass").tooltip();
140
        $(".commentclass").tooltip();
141
    var reg_exp = '';
142
    var checkboxs = document.getElementsByName('status_filter');
143
    for (var i = 0, inp; inp = checkboxs[i]; i++) {
144
        checkCookie = readCookie("cookie_" + inp.value);
145
        if (checkCookie) {
146
            if (checkCookie == 'true') {
147
                $(inp).attr('checked', true);
148
            }
149
            else {
150
                $(inp).attr('checked', false);
151
            }
152
        }
153
        
154
        if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
155
            reg_exp = reg_exp + inp.value + '|';
156
        }
157
        
158
    }
159
        if (reg_exp == '') {
160
            reg_exp = 'XXX|'
161
        }
162
    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
163
    
164
    $('input[name="status_filter"]').iToggle({
165
        type: 'checkbox',
166
        onSlide: function(){
167
            var reg_exp = '';
168
            var checkboxs = document.getElementsByName('status_filter');
169
            
170
            for (var i = 0, inp; inp = checkboxs[i]; i++) {
171
                if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
172
                    reg_exp = reg_exp + inp.value + '|';
173
                }
174
                createCookie("cookie_" + inp.value, inp.checked, 30);
175
            }
176
            //passing an empty string will result in no filter
177
            //thus, it must be set to something that will not exist in the column
178
            if (reg_exp == '') {
179
                reg_exp = 'X|'
180
            }
181
            oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
182
        },
183
    });
184
});
185
                
186
function delete_route(route){
187
        route_name = route;
188
        $('#route_to_delete').text(route_name);
189
        return false;
190
}                
191
                
192
                
193

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

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

    
269
<tbody>
270
{% for route in routes %}
271

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

    
313
{% endfor %}
314
</tbody>
315
</table>
316

    
317
<div id="dialog" title="Suspend Rule">
318
                <p>You are about to suspend rule <strong><span id="route_to_delete"></span></strong></p>
319
                <p>Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.</p>
320
                <p>Are you sure you want to proceed?</p>
321
</div>
322
<div id="console" title="Console">
323
                                        {% include "poll.html" %}
324
</div>
325
{% endblock %}