Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ 2e52e8a5

History | View | Annotate | Download (10.8 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
        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
        $(".statustootipclass").tooltip();
137
    $(".expiresclass").tooltip();
138
        $(".commentclass").tooltip();
139
    var reg_exp = '';
140
    var checkboxs = document.getElementsByName('status_filter');
141
    for (var i = 0, inp; inp = checkboxs[i]; i++) {
142
        checkCookie = readCookie("cookie_" + inp.value);
143
        if (checkCookie) {
144
            if (checkCookie == 'true') {
145
                $(inp).attr('checked', true);
146
            }
147
            else {
148
                $(inp).attr('checked', false);
149
            }
150
        }
151
        
152
        if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
153
            reg_exp = reg_exp + inp.value + '|';
154
        }
155
        
156
    }
157
        if (reg_exp == '') {
158
            reg_exp = 'XXX|'
159
        }
160
    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
161
    
162
    $('input[name="status_filter"]').iToggle({
163
        type: 'checkbox',
164
        onSlide: function(){
165
            var reg_exp = '';
166
            var checkboxs = document.getElementsByName('status_filter');
167
            
168
            for (var i = 0, inp; inp = checkboxs[i]; i++) {
169
                if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
170
                    reg_exp = reg_exp + inp.value + '|';
171
                }
172
                createCookie("cookie_" + inp.value, inp.checked, 30);
173
            }
174
            //passing an empty string will result in no filter
175
            //thus, it must be set to something that will not exist in the column
176
            if (reg_exp == '') {
177
                reg_exp = 'X|'
178
            }
179
            oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
180
        },
181
    });
182
});
183
                
184
function delete_route(route){
185
        route_name = route;
186
        $('#route_to_delete').text(route_name);
187
        return false;
188
}                
189
                
190
                
191

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

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

    
271
<tbody>
272
{% for route in routes %}
273

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

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

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