Revision 1d70dbce djnro/templates/edumanage/services.html

b/djnro/templates/edumanage/services.html
1 1
{% extends "edumanage/welcome.html"%}
2 2
{% load i18n %}
3 3
{% load staticfiles %}
4
{% load tolocale %}
4 5

  
5
{% block crumbs %}
6
<li><a href="{% url manage %}">{% trans "Home" %}</a><span class="divider">/</span></li>
7
<li class="active">{% trans "Locations" %}</li>
8
{% endblock %}
9
{% block extrahead %}
10
<script type="text/javascript" src="{% static 'js/jquery.dataTables.min.js' %}"></script>
11
<script type="text/javascript" src="{% static 'js/datatables_bootstrap.js' %}"></script>
12
<script type="text/javascript">
13
$(document).ready(function(){
14
	 {% if services %}
15
var oTable = $('#table').dataTable({
16
	"sPaginationType": "bootstrap",
17
	"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
18
	"aoColumns": [{
19
        "bSearchable": true,
20
        "bSortable": true
21
    }, {
22
        "bSearchable": true,
23
        "bSortable": true
24
    }, {
25
        "bSearchable": true,
26
        "bSortable": true
27
    }, {
28
        "bSearchable": true,
29
        "bSortable": true
30
    }, {
31
        "bSearchable": true,
32
        "bSortable": true
33
    }, {
34
        "bVisible": true,
35
        "bSearchable": false,
36
        "bSortable": false
37
    }],
38
    "aaSorting": [[0, 'desc']],
39
    "iDisplayLength": 25,
40
    "oSearch": {"bSmart": false, "bRegex":true},
41
    "oLanguage": {
42
    	"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "locations" %}',
43
        "sProcessing":   "Processing...",
44
        "sZeroRecords": '{% trans "No records to display" %}',
45
        "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
46
        "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
47
        "sInfoFiltered": "(filtered from _MAX_ total entries)",
48
        "sInfoPostFix":  "",
49
        "sSearch":       '{% trans "Search:" %}',
50
        "sUrl":          "",
51
        "oPaginate": {
52
            "sFirst":    '{% trans "First" %}',
53
            "sPrevious": '{% trans "Previous" %}',
54
            "sNext":     '{% trans "Next" %}',
55
            "sLast":     '{% trans "Last" %}'
56
        }
57
    }
58
});
59

  
60
oTable.fnDraw();
61
$('[id^=del_service_]').click(function(){
62
	server_id = (this.id).replace("del_service_", '');
63
	name = this.getAttribute("data-servicename");
64
	$("#mymodalbody").html("{% trans 'You are about to delete location' %}: <b>"+name+"</b><br>{% trans 'Press Delete to proceed or Cancel to cancel deletion' %}");
65
	$("#myModalLabel").html("{% trans 'Delete Location' %} "+name);
66
	$('#myModal').modal('show');
67
	$(".modal-footer").show();
68
	$("#service_name_del").html(name)
69
	return false;
70
});
6
{% block homeactive %}{% endblock %}
7
{% block servicesactive %}class="active"{% endblock %}
71 8

  
72
$("#delserviceSubmit").click(function(){
73
	$.ajax({
74
		url:"{% url del-service %}/?service_pk="+server_id,
75
		type: "GET",
76
		success: function(data){
77
			if (data.error){
78
				$(".modal-footer").hide();
79
				$("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
80
			}
81
			if (data.success){
82
				$(".modal-footer").hide();
83
				$("#mymodalbody").html("{% trans 'Service' %} "+name+" {% trans 'successfully deleted' %}");
84
				window.setTimeout('location.reload()', 1000);
85

  
86
			}
87
			}
88
		});
89
});
90
{% endif %}
91
});
92
</script>
9
{% block extrahead %}
10
<link href="https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
93 11
{% endblock %}
94
			{% block homeactive %}{% endblock %}
95
    		{% block servicesactive %}class="active"{% endblock %}
96
            {% block subcontent %}
97
              <h4>{% trans "Locations" %}</h4>
98
              <hr>
99
              {% if messages %}
100
	                <table class="table table-condensed">
101 12

  
102
					    {% for message in messages %}
103
					    <tr {% if message.tags %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
104
					    {% endfor %}
105
					</table>
106
			  {% endif %}
107
              <div>{% if institution.ertype == 2 or institution.ertype == 3 %}<a href="{% url edit-services %}" class="btn btn-primary">{% trans "Add location" %}</a>{% endif %}</div>
108
	              <div class="span10"></div>
109
              {% load tolocale %}
110
              {% if institution.ertype == 2 or institution.ertype == 3 %}
111
              {% if services %}
112
               <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
113
	               <thead>
114
					<tr>
13
{% block management_content %}
14
		<h4>{% trans "Locations" %}</h4>
15
		<hr>
16
		{% if messages %}
17
			<table class="table table-condensed">
18
			{% for message in messages %}
19
				<tr {% if message.tags %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
20
			{% endfor %}
21
			</table>
22
		{% endif %}
23
		<div>
24
			{% if institution.ertype == 2 or institution.ertype == 3 %}
25
				<a href="{% url edit-services %}" class="btn btn-primary">
26
					{% trans "Add location" %}
27
				</a>
28
			{% endif %}
29
		</div>
30
{% if institution.ertype == 2 or institution.ertype == 3 %}
31
	{% if services %}
32
		<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
33
			<thead>
34
				<tr>
115 35
					<th>{% trans "Name" %}</th>
116 36
					<th>{% trans "Address" %}</th>
117 37
					<th>{% trans "SSID" %}</th>
118 38
					<th>{% trans "Encryption Level" %}</th>
119 39
					<th>{% trans "AP no" %}</th>
120 40
					<th>{% trans "Actions" %}</th>
121
					</tr>
122
					</thead>
123
					<tbody>
124
	                {% for service in services %}
125
	              	<tr class="GradeC">
126
	                	<td><a href="{% url services service.pk %}">{% tolocale service LANGUAGE_CODE %}</a></td>
127
	                	<td>{{service.address_street}}<br>{{service.address_city}}</td>
128
	                	<td>{{service.SSID}}</td>
129
                        <td>{% for enc in service.enc_level %}{% if enc == '' %}-{% else %}{{enc}}{% if not forloop.last%},{% endif %}{% endif %}{% endfor %}</td>
130
	                	<td>{{service.AP_no}}</td>
131
	                	<td style="text-align: center;"><a href="{% url edit-services service.pk %}" class="btn btn-small">{% trans "edit" %}</a> <a href="#" id="del_service_{{service.pk}}" data-servicename="{% tolocale service LANGUAGE_CODE%}" class="btn btn-small btn-warning">{% trans "delete" %}</a></td>
132
	                </tr>
133
	              	{% endfor %}
134
	              	</tbody>
135
	              </table>
136
	              {% endif %}
137
              {% endif %}
138
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
139
<div class="modal-header">
140
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
141
<h3 id="myModalLabel">{% trans "Delete Location" %}</h3>
142
</div>
143
<div class="modal-body" id="mymodalbody">
41
				</tr>
42
			</thead>
43
			<tbody>
44
			{% for service in services %}
45
		    	<tr class="GradeC">
46
		        	<td><a href="{% url services service.pk %}">{% tolocale service LANGUAGE_CODE %}</a></td>
47
		        	<td>{{service.address_street}}<br>{{service.address_city}}</td>
48
		        	<td>{{service.SSID}}</td>
49
		            <td>{% for enc in service.enc_level %}{% if enc == '' %}-{% else %}{{enc}}{% if not forloop.last%},{% endif %}{% endif %}{% endfor %}</td>
50
		        	<td>{{service.AP_no}}</td>
51
		        	<td style="text-align: center;"><a href="{% url edit-services service.pk %}" class="btn btn-small">{% trans "edit" %}</a> <a href="#" id="del_service_{{service.pk}}" data-servicename="{% tolocale service LANGUAGE_CODE%}" class="btn btn-small btn-warning">{% trans "delete" %}</a></td>
52
		        </tr>
53
			{% endfor %}
54
			</tbody>
55
		</table>
56
	    {% endif %}
57
	{% endif %}
144 58

  
145
</div>
146
<div class="modal-footer">
147
<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
148
<a class="btn btn-warning" id="delserviceSubmit" href="#">{% trans "Delete" %}</a>
149
</div>
59
<div class="modal" id="myModal">
60
	<div class="modal-dialog">
61
    	<div class="modal-content">
62
			<div class="modal-header">
63
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
64
				<h3 id="myModalLabel">{% trans "Delete Location" %}</h3>
65
			</div>
66
			<div class="modal-body" id="mymodalbody">
67
			</div>
68
			<div class="modal-footer">
69
			<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
70
			<a class="btn btn-warning" id="delserviceSubmit" href="#">{% trans "Delete" %}</a>
71
			</div>
72
		</div>
73
	</div>
150 74
</div>
151 75

  
152
<div class="modal hide fade" id="servDets" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
153
<div class="modal-header">
154
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
155
<h3 id="myModalLabelservdets">{% trans "Location Details" %}</h3>
76
<div class="modal" id="servDets">
77
	<div class="modal-dialog">
78
    	<div class="modal-content">
79
			<div class="modal-header">
80
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
81
				<h3 id="myModalLabelservdets">{% trans "Location Details" %}</h3>
82
			</div>
83
			<div class="modal-body" id="servDetsbody">
84
			</div>
85
			<div class="modal-footer">
86
				<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Close" %}</button>
87
			</div>
88
		</div>
89
	</div>
156 90
</div>
157
<div class="modal-body" id="servDetsbody">
91
{% endblock %}
158 92

  
159
</div>
160
<div class="modal-footer">
161
<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Close" %}</button>
162
</div>
163
</div>
164
		{% endblock %}
93

  
94
{% block extrajs %}
95
<script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
96
<script type="text/javascript" src="//cdn.datatables.net/plug-ins/505bef35b56/integration/bootstrap/1/dataTables.bootstrap.js"></script>
97
<script type="text/javascript">
98
$(document).ready(function(){
99
	{% if services %}
100
	var oTable = $('#table')
101
	.on( 'init.dt', function () {
102
       	$('.pagination ul').addClass('pagination');
103
    })
104
    .dataTable({
105
		"sPaginationType": "bootstrap",
106
		"sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
107
		"aoColumns": [{
108
	        "bSearchable": true,
109
	        "bSortable": true
110
	    },
111
	    {
112
	        "bSearchable": true,
113
	        "bSortable": true
114
	    },
115
	    {
116
	        "bSearchable": true,
117
	        "bSortable": true
118
	    },
119
	    {
120
	        "bSearchable": true,
121
	        "bSortable": true
122
	    },
123
	    {
124
	        "bSearchable": true,
125
	        "bSortable": true
126
	    },
127
	    {
128
	        "bVisible": true,
129
	        "bSearchable": false,
130
	        "bSortable": false
131
	    }],
132
	    "aaSorting": [[0, 'desc']],
133
	    "iDisplayLength": 25,
134
	    "oSearch": {"bSmart": false, "bRegex":true},
135
	    "oLanguage": {
136
	    	"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "locations" %}',
137
	        "sProcessing":   "Processing...",
138
	        "sZeroRecords": '{% trans "No records to display" %}',
139
	        "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
140
	        "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
141
	        "sInfoFiltered": "(filtered from _MAX_ total entries)",
142
	        "sInfoPostFix":  "",
143
	        "sSearch":       '{% trans "Search:" %}',
144
	        "sUrl":          "",
145
	        "oPaginate": {
146
	            "sFirst":    '{% trans "First" %}',
147
	            "sPrevious": '{% trans "Previous" %}',
148
	            "sNext":     '{% trans "Next" %}',
149
	            "sLast":     '{% trans "Last" %}'
150
	        }
151
	    }
152
	});
153

  
154
	oTable.fnDraw();
155
	$('[id^=del_service_]').click(function(){
156
		server_id = (this.id).replace("del_service_", '');
157
		name = this.getAttribute("data-servicename");
158
		$("#mymodalbody").html("{% trans 'You are about to delete location' %}: <b>"+name+"</b><br>{% trans 'Press Delete to proceed or Cancel to cancel deletion' %}");
159
		$("#myModalLabel").html("{% trans 'Delete Location' %} "+name);
160
		$('#myModal').modal('show');
161
		$(".modal-footer").show();
162
		$("#service_name_del").html(name)
163
		return false;
164
	});
165

  
166
	$("#delserviceSubmit").click(function(){
167
		$.ajax({
168
			url:"{% url del-service %}/?service_pk="+server_id,
169
			type: "GET",
170
			success: function(data){
171
				if (data.error){
172
					$(".modal-footer").hide();
173
					$("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
174
				}
175
				if (data.success){
176
					$(".modal-footer").hide();
177
					$("#mymodalbody").html("{% trans 'Service' %} "+name+" {% trans 'successfully deleted' %}");
178
					window.setTimeout('location.reload()', 1000);
179

  
180
				}
181
				}
182
			});
183
	});
184
	{% endif %}
185
});
186
</script>
187
{% endblock %}

Also available in: Unified diff