Revision c78c4531 templates/user_routes.html

b/templates/user_routes.html
5 5
<script type="text/javascript" src="{% url load-js 'poller' %}"></script>
6 6
{% endif %}
7 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>
8 10
<script type="text/javascript">
9
	$(document).ready( function(){
10
		var noaction = readCookie('noaction');
11
		$( "#hide_noaction" ).button();
12
		if (noaction == 'true'){
13
			$('#hide_noaction').attr('checked','checked');
14
			$("#hide_noaction").button( "option", "label", "Show Expired, AdminInactive, Error" );
15
		}
16
		$("#hid_mid").val('');
17
		$('#dialog').dialog({
18
			height: 220,
19
            width: 300,
20
			modal: true,
21
			autoOpen: false,
22
			buttons: {
23
		'Delete': function() {
24
		route = $('#route_to_delete').text();
25
		route_url_id = '#del_route_'+route;
26
		url = $(route_url_id).attr('href');
27
			$.ajax({
28
			url: url ,
29
			cache: false,
30
			success: function(data) {
31
				$('#dialog').dialog('close');
32
				window.setTimeout('location.reload()', 1000);
33
			  }
34
		});
35
		},
36
		Cancel: function() {
37
			$('#dialog').dialog('close');
38
		},
39
		
40

  
41
	},
42
	close: function() {
43
        update_val = $("#hid_mid").val();
44
		if (update_val == 'UPDATED'){
45
			$("#hid_mid").val('');
46
			window.setTimeout('location.reload()', 500);
47
		}
48
    }
49
		});
50
		$('#console').dialog({
51
			height: 250,
52
            width: 800,
53
			modal: true,
54
			autoOpen: false,
55
			close: function() {
56
		        update_val = $("#hid_mid").val();
57
				if (update_val == 'UPDATED'){
58
					$("#hid_mid").val('');
59
					window.setTimeout('location.reload()', 500);
60
				}
61
		    }
62
		});
63
			
64
		$('#routes_table').dataTable({
65
			"bJQueryUI": true,
66
			"aoColumns": [ 
67
				{"bVisible": false, "bSearchable": false,"bSortable": false },
68
				{"bSearchable": true,"bSortable": true},
69
				{"bSearchable": true,"bSortable": true},
70
				{"bSearchable": true,"bSortable": true},
71
				{"bSearchable": true,"bSortable": true},
72
				{"bSearchable": true,"bSortable": true},
73
				{"bSearchable": true,"bSortable": true},
74
				{"bSearchable": true,"bSortable": true},
75
				{"bVisible": true, "bSearchable": false,"bSortable": false}
76
			],
77
			 "aaSorting": [[0,'desc']],
78
			"oLanguage": {
79
				"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> rules'
80
			},
81
			"iDisplayLength": 25,
82
	});
83
	$.fn.dataTableExt.afnFiltering = new Array();
84
	$.fn.dataTableExt.afnFiltering.push(
85
 	function( oSettings, aData, iDataIndex ) {
86
		// 4 here is the column where my statuses are.
87
 		var status_middle = $(aData[4]);
88
		var status = $(status_middle[0]).text();
89
 		if (( status == "EXPIRED" || status == "ADMININACTIVE" || status == "ERROR") && ($('#hide_noaction').attr('checked'))) {
90
 			return false;
91
 		}
92
		else {
93
			return true;
94
		}
95
 		
96
 	});
97
	var oTable = $('#routes_table').dataTable();
98
	oTable.fnDraw();
99
	$('#hide_noaction').change( function(){
100
			var noaction = $('#hide_noaction').attr('checked');
101
			if (noaction == true){
102
				$("#hide_noaction").button( "option", "label", "Show Expired, AdminInactive, Error" );
103
				}
104
			else{
105
				$("#hide_noaction").button( "option", "label", "Hide Expired, AdminInactive, Error" );
106
			}
107
			createCookie("noaction", noaction, 30);
108
			oTable.fnDraw(); 
109
		});
110
	
111
	$( ".button_place #routebutton" ).button({
112
            icons: {
113
                primary: "ui-icon-circle-plus"
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
                });
114 31
            },
115
			});
116
		$( " .edit_button" ).button({
117
            icons: {
118
                primary: "ui-icon-wrench"
32
            Cancel: function(){
33
                $('#dialog').dialog('close');
119 34
            },
120
			});
121
		$( " .del_button" ).button({
122
            icons: {
123
                primary: "ui-icon-circle-close"
124
            },
125
			})
126
			.click(function(){
127
				$('#dialog').dialog('open');
128
				return false;
129
			});
130
		$("#consolebutton").button({
131
            icons: {
132
                primary: "ui-icon-image"
133
            },
134
			})
135
			.click(function(){
136
				$("#consolebutton").stop().stop();
137
				$("#consolebutton").css('color', '#555555');
138
				$('#console').dialog('open');
139
				return false;
140
			});
141
			
142
		$(".expiresclass").tooltip();
143

  
144
		});
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 = 'X|'
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
});
145 182
		
146 183
function delete_route(route){
147 184
	route_name = route;
......
182 219
	<button id="consolebutton">Console</button> <a href="{% url add-route %}" id="routebutton">Add Rule</a>
183 220
</div>
184 221
<br><br>
185
<table cellpadding="0" cellspacing="0" border="0" style="width:220px; clear:both;">
186
	<tbody>
187
		<tr>
188
			<td align="left"><input type="checkbox" id="hide_noaction" name="hide_noaction" value="Hide" /><label for="hide_noaction">Hide Expired, AdminInactive, Error</label></td>
189
		</tr>
190
	</tbody>
191
</table>
192
<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 id="show_active"/>
232
				        </td>
233
				    
234
				        <td>
235
				            <input type="checkbox" class="onoff" name="status_filter" value="SUSPENDED" checked 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" checked id="show_pending"/>
252
				        </td>
253
				    </tr>
254
				</tbody>
255
			</table>
256
			</div>
257
	<table class="display" width="100%" id="nodes_table">
193 258
<table class="display" width="100%" id="routes_table">
194 259
<thead>
195 260
<tr>
......
211 276

  
212 277
<tr class="GradeC" >
213 278
	<td>{{ route.pk }}</td>
214
	<td>{{ route.name }}</td>
279
	<td><span {% if route.comments %}
280
	class="commentclass" 
281
		style="border-bottom:1px dotted red;" 
282
        title="{{route.comments}}"
283
		{% endif %}>{{ route.name }}</span></td>
215 284
	<td>{{ route.get_match|safe|escape }}</td>
216 285
	<td style="text-align: center;">{{route.get_then|safe|escape}}</td>
217
	<td style="text-align: center; ">
218
		<span 
219
		{% if route.days_to_expire %}
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 route.days_to_expire %}
220 290
		class="expiresclass" 
221 291
		style="border-bottom:2px dashed red;" 
222 292
        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
223
		{% endif %}>{{route.status}}</span>
224
	</td>
225
	{% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
226
	<td style="text-align: center;">{{ route.applier }}</td>
227
	<td style="text-align: center;">{{ route.expires }}</td>
293
		{% endif %}>{{ route.expires }}</span></td>
228 294
	<td style="text-align: center;">{{ route.response }}</td>
229 295
	<td style="text-align: center; width:180px;">
230 296
		{% ifequal route.status 'ACTIVE' %}
231 297
		<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">Edit</a> 
232
		<button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Del</button>
298
		<button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">Suspend</button>
233 299
		<a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a>
234 300
		{% else %}
235 301
		{% ifequal route.status 'INACTIVE' %}

Also available in: Unified diff