Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ d0f665cc

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

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

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

    
274
<tbody>
275
{% for route in routes %}
276

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

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

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