Statistics
| Branch: | Tag: | Revision:

root / templates / user_routes.html @ 7c4bc8de

History | View | Annotate | Download (6.3 kB)

1
{% extends "base.html" %}
2
{% load i18n %}
3
{% block extrahead %}
4
<script type="text/javascript" src="/static/js/jquery.dataTables.js"></script>
5
<script type="text/javascript">
6
        $(document).ready( function(){
7
                $("#hid_mid").val('');
8
                $('#dialog').dialog({
9
                        height: 220,
10
            width: 300,
11
                        modal: true,
12
                        autoOpen: false,
13
                        buttons: {
14
                'Delete': function() {
15
                route = $('#route_to_delete').text();
16
                route_url_id = '#del_route_'+route;
17
                url = $(route_url_id).attr('href');
18
                        $.ajax({
19
                        url: url ,
20
                        cache: false,
21
                        success: function(data) {
22
                                $('#dialog').dialog('close');
23
                                window.setTimeout('location.reload()', 1000);
24
                          }
25
                });
26
                },
27
                Cancel: function() {
28
                        $('#dialog').dialog('close');
29
                },
30
                
31

32
        },
33
        close: function() {
34
        update_val = $("#hid_mid").val();
35
                if (update_val == 'UPDATED'){
36
                        $("#hid_mid").val('');
37
                        window.setTimeout('location.reload()', 500);
38
                }
39
    }
40
                });
41
                $('#console').dialog({
42
                        height: 250,
43
            width: 800,
44
                        modal: true,
45
                        autoOpen: false,
46
                        close: function() {
47
                        update_val = $("#hid_mid").val();
48
                                if (update_val == 'UPDATED'){
49
                                        $("#hid_mid").val('');
50
                                        window.setTimeout('location.reload()', 500);
51
                                }
52
                    }
53
                });
54
                        
55
                $('#routes_table').dataTable( {
56
                        "bJQueryUI": true,
57
                        "aoColumns": [ 
58
                                {"bVisible": false, "bSearchable": false,"bSortable": false },
59
                                {"bSearchable": true,"bSortable": true},
60
                                {"bSearchable": true,"bSortable": true},
61
                                {"bSearchable": true,"bSortable": true},
62
                                {"bSearchable": true,"bSortable": true},
63
                                {"bSearchable": true,"bSortable": true},
64
                                {"bSearchable": true,"bSortable": true},
65
                                {"bSearchable": true,"bSortable": true},
66
                                {"bVisible": true, "bSearchable": false,"bSortable": false}
67
                        ],
68
                         "aaSorting": [[0,'desc']],
69
                        "oLanguage": {
70
                                "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
71
                        },
72
                        "iDisplayLength": 25,
73
        } );
74
        $( ".button_place #routebutton" ).button({
75
            icons: {
76
                primary: "ui-icon-circle-plus"
77
            },
78
                        });
79
                $( " .edit_button" ).button({
80
            icons: {
81
                primary: "ui-icon-wrench"
82
            },
83
                        });
84
                $( " .del_button" ).button({
85
            icons: {
86
                primary: "ui-icon-circle-close"
87
            },
88
                        })
89
                        .click(function(){
90
                                $('#dialog').dialog('open');
91
                                return false;
92
                        });
93
                $("#consolebutton").button({
94
            icons: {
95
                primary: "ui-icon-image"
96
            },
97
                        })
98
                        .click(function(){
99
                                $("#consolebutton").stop().stop();
100
                                $("#consolebutton").css('color', '#555555');
101
                                $('#console').dialog('open');
102
                                return false;
103
                        });
104
                        
105
                $(".expiresclass").tooltip();
106

107
                });
108
                
109
function delete_route(route){
110
        route_name = route;
111
        $('#route_to_delete').text(route_name);
112
        return false;
113
}                
114
                
115
                
116

    
117
</script>
118
<style type="text/css">
119
        #console {
120
                background: none repeat scroll 0 0 #36102a !important;
121
                color: #edeae8 !important;
122
                font-family: monospace !important;
123
        }
124
        .message {
125
                font-family: monospace !important;
126
        }
127
        .tooltip {
128
        display:none;
129
        background:transparent url(/static/black_arrow.png);
130
        font-size:12px;
131
        height:70px;
132
        width:160px;
133
        padding:25px;
134
        color:#fff;        
135
}
136
        
137
</style>
138
{% endblock %}
139
{% block title %}{% trans "My rules" %}{% endblock %}
140
{% block content %}
141
<div style="float:left">
142
        <h3 style="margin-top: 0px;">{% trans "My rules" %}</h3>
143
</div>
144
<div class='button_place' style="float:right">
145
        <button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a>
146
</div>
147
<table class="display" width="100%" id="routes_table">
148
<thead>
149
<tr>
150
        <th>Id</th>
151
        <th>{% trans "Name" %}</th>
152
        <th>{% trans "Match" %}</th>
153
        <th style="text-align: center;">{% trans "Then" %}</th>
154
        <th style="text-align: center; ">{% trans "Status" %}</th>
155
        {% comment %}<th style="text-align: center;">{% trans "Details" %}</th>{% endcomment %}
156
        <th style="text-align: center;">{% trans "Applier" %}</th>
157
        <th style="text-align: center;">{% trans "Expires" %}</th>
158
        <th style="text-align: center;">{% trans "Response" %}</th>
159
        <th style="text-align: center; width:180px;">{% trans "Actions" %}</th>
160
</tr>
161
</thead>
162

    
163
<tbody>
164
{% for route in routes %}
165

    
166
<tr {% ifequal  'ACTIVE' %} class="GradeA" {% else %} class="GradeX" {% endifequal %}>
167
        <td>{{ route.pk }}</td>
168
        <td>{{ route.name }}</td>
169
        <td>{{ route.get_match|safe|escape }}</td>
170
        <td style="text-align: center;">{{route.get_then|safe|escape}}</td>
171
        <td style="text-align: center; ">
172
                <span 
173
                {% if  and  >= 0 %}
174
                class="expiresclass" 
175
                style="border-bottom:2px dashed red;" 
176
        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
177
                {% endif %}>{{route.status}}
178
                </span>
179
        </td>
180
        {% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
181
        <td style="text-align: center;">{{ route.applier }}</td>
182
        <td style="text-align: center;">{{ route.expires }}</td>
183
        <td style="text-align: center;">{{ route.response }}</td>
184
        <td style="text-align: center; width:180px;">
185
                {% ifequal route.status 'ACTIVE' %}
186
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> 
187
                <button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Del</button>
188
                <a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a>
189
                {% else %}
190
                {% ifequal route.status 'INACTIVE' %}
191
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Reactivate</a>
192
                {% else %}
193
                {% ifequal route.status 'OUTOFSYNC' %}
194
                <a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">ReSync</a>
195
                {% else %}
196
                -
197
                {% endifequal %}
198
                {% endifequal %}
199
                {% endifequal %}
200
                </td>
201
</tr>
202

    
203
{% endfor %}
204
</tbody>
205
</table>
206

    
207
<div id="dialog" title="Delete Route">
208
                <p>You are about to delete rule <strong><span id="route_to_delete"></span></strong></p>
209
                <p>Deleting the rule will automatically remove the configuration from the network and mark this route as inactive.</p>
210
                <p>Are you sure you want to proceed?</p>
211
</div>
212
<div id="console" title="Console">
213
                                        {% include "poll.html" %}
214
</div>
215
{% endblock %}