Revision 62ee35d6 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
<script type="text/javascript" src="/static/js/datatables_bootstrap.js"></script>
9

  
10 10
<script type="text/javascript">
11

  
11 12
$(document).ready(function(){
13
	$('[rel=tooltip]').tooltip();
12 14
    $("#hid_mid").val('');
13 15
    $('#dialog').dialog({
14 16
        height: 250,
......
66 68
        icons: {
67 69
            primary: "ui-icon-wrench"
68 70
        },
69
    }).css('width','110px').css('margin-bottom','2px');
71
    }).css('margin-bottom','2px');
70 72
    $(" .del_button").button({
71 73
        icons: {
72 74
            primary: "ui-icon-circle-close"
......
74 76
    }).click(function(){
75 77
        $('#dialog').dialog('open');
76 78
        return false;
77
    }).css('width','110px');
78
    $("#consolebutton").button({
79
        icons: {
80
            primary: "ui-icon-image"
81
        },
82
    }).click(function(){
79
    });
80
    $("#consolebutton").button().click(function(){
83 81
        $("#consolebutton").stop().stop();
84
        $("#consolebutton").css('color', '#555555');
85 82
        $('#console').dialog('open');
86 83
        return false;
87 84
    });
88
	$(".statustootipclass").tooltip();
89
    $(".expiresclass").tooltip();
90
	$(".commentclass").tooltip();
85

  
86

  
91 87
    var oTable = $('#routes_table').dataTable({
92
        "bJQueryUI": true,
88
    	"sPaginationType": "bootstrap",
89
    	"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
93 90
        "aoColumns": [{
94 91
            "bVisible": false,
95 92
            "bSearchable": false,
......
122 119
        }],
123 120
        "aaSorting": [[0, 'desc']],
124 121
        "iDisplayLength": 25,
122
        "oSearch": {"bSmart": false, "bRegex":true},
125 123
        "oLanguage": {
126 124
        	"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "rules" %}',
127 125
            "sProcessing":   "Processing...",
......
140 138
            }
141 139
        }
142 140
    });
141

  
143 142
    oTable.fnDraw();
144
    $('input[name="status_filter"]').click(function(){
145
        //slice off the last '|' or it doesn't work
146
        //also be sure to use the third parameter
147
    });
148
    
149 143
    
150 144
    var reg_exp = '';
151 145
    var checkboxs = document.getElementsByName('status_filter');
......
153 147
        checkCookie = readCookie("cookie_" + inp.value);
154 148
        if (checkCookie) {
155 149
            if (checkCookie == 'true') {
156
                $(inp).attr('checked', true);
150
                $(inp).addClass('active');
157 151
            }
158 152
            else {
159
                $(inp).attr('checked', false);
153
                $(inp).removeClass('active');
160 154
            }
161 155
        }
162 156
        
163
        if (inp.type.toLowerCase() == 'checkbox' && inp.checked == true) {
157
        if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
164 158
            reg_exp = reg_exp + inp.value + '|';
165 159
        }
166 160
        
167 161
    }
168 162
	if (reg_exp == '') {
169
            reg_exp = 'XXX|'
163
            reg_exp = '|'
170 164
        }
165
	console.log(reg_exp.slice(0, -1))
171 166
    oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
172 167
    
173
    $('input[name="status_filter"]').iToggle({
174
        type: 'checkbox',
175
        onSlide: function(){
176
            var reg_exp = '';
177
            var checkboxs = document.getElementsByName('status_filter');
178
            
179
            for (var i = 0, inp; inp = checkboxs[i]; i++) {
180
                if (inp.type.toLowerCase() == 'checkbox' && inp.checked) {
181
                    reg_exp = reg_exp + inp.value + '|';
182
                }
183
                createCookie("cookie_" + inp.value, inp.checked, 30);
184
            }
185
            //passing an empty string will result in no filter
186
            //thus, it must be set to something that will not exist in the column
187
            if (reg_exp == '') {
188
                reg_exp = 'X|'
168
    
169
    $('button[name="status_filter"]').click(function(){
170
    	var reg_exp = '';
171
        var checkboxs = document.getElementsByName('status_filter');
172
        $(this).button('toggle');
173
        for (var i = 0, inp; inp = checkboxs[i]; i++) {
174
            if (inp.type.toLowerCase() == 'button' && $(inp).hasClass('active')) {
175
                reg_exp = reg_exp + inp.value + '|';
189 176
            }
190
            oTable.fnFilter(reg_exp.slice(0, -1), 4, true);
191
        },
177
            createCookie("cookie_" + inp.value, $(inp).hasClass('active'), 30);
178
        }
179
        //passing an empty string will result in no filter
180
        //thus, it must be set to something that will not exist in the column
181
        if (reg_exp == '') {
182
            reg_exp = '|'
183
        }
184
        oTable.fnFilter(reg_exp.slice(0, -1), 4, regex=true);
185
        console.log(reg_exp.slice(0, -1))
186
        return false;
192 187
    });
188

  
189
    
193 190
});
194 191
		
195 192
function delete_route(route){
......
210 207
	.message {
211 208
		font-family: monospace !important;
212 209
	}
213
	.tooltip {
214
	display:none;
215
	background:transparent url(/static/black_arrow.png);
216
	font-size:12px;
217
	height:70px;
218
	width:160px;
219
	padding:25px;
220
	color:#fff;	
221
}
210
	
222 211
	
223 212
</style>
224 213
{% endblock %}
225 214
{% block title %}{% trans "My rules" %}{% endblock %}
226 215
{% block content %}
227 216
{% csrf_token %}
217
<div class="row-fluid">
218
<div class="span2">
228 219
<div style="float:left">
229
	<h3 style="margin-top: 0px;">{% trans "My rules" %}</h3>
220
	<h4>{% trans "My rules" %}</h4>
221
</div>
230 222
</div>
223

  
224
<div class="span10">
231 225
<div class='button_place' style="float:right">
232
	<button id="consolebutton">{% trans "Console" %}</button> <a href="{% url add-route %}" id="routebutton">{% trans "Add Rule" %}</a>
226
	<button id="consolebutton" class="btn btn-inverse">
227
		<i class="icon-tasks icon-white" style="align:left;"></i>{% trans "Console" %}</button>
228
		<a href="{% url add-route %}" id="routebutton" class="btn btn-inverse"><i class="icon-plus-sign icon-white"></i>{% trans "Add Rule" %}</a>
229
</div>
233 230
</div>
234
<br><br>
231
</div>
232
<div class="row-fluid" style="padding-top:30px;">
235 233

  
236
<div id='itoggle'>
237
<table cellpadding="0" cellspacing="0" border="0" class="display" style='width:200px;'>
238
				<tbody>
239
					<tr>
240
				        <th>ACTIVE</th><th>SUSPENDED</th><th>ERROR</th><th>PENDING</th>
241
					</tr>
242
					<tr class="on_off">
243
				        <td>
244
				            <input type="checkbox" class="onoff" name="status_filter" value="ACTIVE" checked id="show_active"/>
245
				        </td>
246
				    
247
				        <td>
248
				            <input type="checkbox" class="onoff" name="status_filter" value="SUSPENDED" id="show_inactive"/>
249
				        </td>				    
250
				        <td>
251
				            <input type="checkbox" class="onoff" name="status_filter" value="ERROR" id="show_error"/>
252
				        </td>
253
				   
254
				        <td>
255
				            <input type="checkbox" class="onoff" name="status_filter" value="PENDING" id="show_pending"/>
256
				        </td>
257
				    </tr>
258
				</tbody>
259
			</table>
234
<div id='itoggle' class="span12" style="text-align:center;">
235
   <div class="btn-group" data-toggle="buttons-checkbox">
236
    <button type="button" class="btn btn-small" name="status_filter" value="ACTIVE" id="show_active">Active</button>
237
    <button type="button" class="btn btn-small" name="status_filter" value="SUSPENDED" id="show_inactive">Suspended</button>
238
    <button type="button" class="btn btn-small" name="status_filter" value="ERROR" id="show_error">Error</button>
239
    <button type="button" class="btn btn-small" name="status_filter" value="PENDING" id="show_pending">Pending</button>
240
    </div>
260 241
			</div>
261
<table class="display" width="100%" id="routes_table">
242

  
243
</div>
244

  
245
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="routes_table">
262 246
<thead>
263 247
<tr>
264 248
	<th>Id</th>
......
282 266
	<td><span {% if route.comments %} class="commentclass" style="border-bottom:1px dotted red;" title="{{route.comments}}"	{% endif %}>{{ route.name }}</span></td>
283 267
	<td>{{ route.get_match|safe|escape }}</td>
284 268
	<td style="text-align: center;">{{route.get_then|safe|escape}}</td>
285
	<td style="text-align: center; "><span {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%} class="statustootipclass" style="border-bottom:1px dotted red;" 
286
		title = "{% ifequal route.status 'INACTIVE' %}{% trans "Suspended by user" %}{% else %}{% ifequal route.status 'ADMININACTIVE' %}{% trans "Suspended by administrator" %}{% else %}{% ifequal route.status 'EXPIRED' %}{% trans "Suspended due to expiration" %}{% else %}{% ifequal route.status 'OUTOFSYNC' %}{% trans "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>
269
	<td style="text-align: center; ">{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
270
		<a href="#" rel="tooltip" 
271
			{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}  
272
			data-placement="top" 
273
			title = "{% ifequal route.status 'INACTIVE' %}
274
						{% trans 'Suspended by user' %}
275
					 {% else %}
276
						{% ifequal route.status 'ADMININACTIVE' %}
277
							{% trans 'Suspended by administrator' %}
278
						{% else %}
279
							{% ifequal route.status 'EXPIRED' %}
280
								{% trans 'Suspended due to expiration' %}
281
							{% else %}
282
								{% ifequal route.status 'OUTOFSYNC' %}
283
									{% trans 'Syncronization error. Configuration in device deffers from rule' %}
284
								{% endifequal %}
285
							{% endifequal %}
286
						{% endifequal %}
287
					 {% endifequal %}"
288
			{% 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 %}</a>
289
		{% else %}{{route.status}}{% endif %}</td>
287 290
	{% comment %}<td style="text-align: center;">{{ route.response }}</td>{% endcomment %}
288 291
	<td style="text-align: center;">{{ route.applier }}</td>
289
	<td style="text-align: center;"><span {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}{% else %}{% if route.days_to_expire %}
292
	<td style="text-align: center;">
293
		<span {% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}{% else %}{% if route.days_to_expire %}
290 294
		class="expiresclass" 
291 295
		style="border-bottom:2px dashed red;" 
292 296
        title="Expires {% ifequal route.days_to_expire '0' %}today{% else%}in {{route.days_to_expire}} day{{ route.days_to_expire|pluralize }}{% endifequal %}"
......
294 298
	<td style="text-align: center;">{% if route.status == 'EXPIRED' %}{% trans "Rule expired" %}{% else %}{% if route.status == 'ADMININACTIVE' %}{% trans "Suspended by administrator" %}{% else %}{% if route.status == 'INACTIVE' %}{% trans "Suspended by user" %}{% else %}{{ route.response }}{% if route.status == 'PENDING' %}<img src="/static/dots.gif">{% endif %}{% endif %}{% endif %}{% endif %}</td>
295 299
	<td style="text-align: center; width:180px;">
296 300
		{% ifequal route.status 'ACTIVE' %}
297
		<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a> 
298
		<button class="del_button" id="{{route.name}}" onclick="javascript:delete_route(this.id)">{% trans "Suspend" %}</button>
299
		<a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}"></a>
301
		<a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a> 
302
		<button class="del_button btn btn-danger btn-small" id="{{route.name}}" onclick="javascript:delete_route(this.id)">{% trans "Suspend" %}</button>
303
		<a href="{% url delete-route route.name %}" style="display:none" id="del_route_{{route.name}}" class="btn btn btn-danger btn-small"></a>
300 304
		{% else %}
301 305
		{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
302
		<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "Reactivate" %}</a>
306
		<a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Reactivate" %}</a>
303 307
		{% else %}
304 308
		{% ifequal route.status 'OUTOFSYNC' %}
305
		<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
309
		<a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
306 310
		{% else %}
307 311
		{% ifequal route.status 'ERROR' %}
308
		<a href="{% url edit-route route.name %}" class="edit_button" id="edit_button_{{route.pk}}">{% trans "Fix it!" %}</a>
312
		<a href="{% url edit-route route.name %}" class="edit_button btn btn-small" id="edit_button_{{route.pk}}">{% trans "Fix it!" %}</a>
309 313
		{% else %}
310 314
		-
311 315
		{% endifequal %}
......
318 322
{% endfor %}
319 323
</tbody>
320 324
</table>
321

  
322 325
<div id="dialog" title="{% trans "Suspend Rule" %}">
323 326
		<p>{% blocktrans %}You are about to suspend rule{% endblocktrans %} <strong><span id="route_to_delete"></span></strong></p>
324 327
		<p>{% blocktrans %}Suspending the rule will automatically remove the configuration from the network and mark this rule as inactive.{% endblocktrans %}</p>

Also available in: Unified diff