Statistics
| Branch: | Tag: | Revision:

root / djnro / templates / edumanage / services.html @ 4772922a

History | View | Annotate | Download (6.3 kB)

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

    
6
{% block homeactive %}{% endblock %}
7
{% block servicesactive %}class="active"{% endblock %}
8

    
9
{% block extrahead %}
10
<link href="https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
11
{% endblock %}
12

    
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  %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
20
                        {% endfor %}
21
                        </table>
22
                {% endif %}
23
{% if institution.ertype == 2 or institution.ertype == 3 %}
24
        {% if services %}
25
                <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
26
                        <thead>
27
                                <tr>
28
                                        <th>{% trans "Name" %}</th>
29
                                        <th>{% trans "Address" %}</th>
30
                                        <th>{% trans "SSID" %}</th>
31
                                        <th>{% trans "Encryption Level" %}</th>
32
                                        <th>{% trans "AP no" %}</th>
33
                                        <th>{% trans "Actions" %}</th>
34
                                </tr>
35
                        </thead>
36
                        <tbody>
37
                        {% for service in services %}
38
                            <tr class="GradeC">
39
                                <td><a href="{% url services service.pk %}">{% tolocale service LANGUAGE_CODE %}</a></td>
40
                                <td>{{service.address_street}}<br>{{service.address_city}}</td>
41
                                <td>{{service.SSID}}</td>
42
                            <td>{% for enc in service.enc_level %}{% if enc == '' %}-{% else %}{{enc}}{% if not forloop.last%},{% endif %}{% endif %}{% endfor %}</td>
43
                                <td>{{service.AP_no}}</td>
44
                                <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>
45
                        </tr>
46
                        {% endfor %}
47
                        </tbody>
48
                </table>
49
            {% endif %}
50
        {% endif %}
51

    
52
<div class="modal" id="myModal">
53
        <div class="modal-dialog">
54
            <div class="modal-content">
55
                        <div class="modal-header">
56
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
57
                                <h3 id="myModalLabel">{% trans "Delete Location" %}</h3>
58
                        </div>
59
                        <div class="modal-body" id="mymodalbody">
60
                        </div>
61
                        <div class="modal-footer">
62
                        <button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
63
                        <a class="btn btn-warning" id="delserviceSubmit" href="#">{% trans "Delete" %}</a>
64
                        </div>
65
                </div>
66
        </div>
67
</div>
68
<div>
69
        {% if institution.ertype == 2 or institution.ertype == 3 %}
70
                <a href="{% url edit-services %}" class="btn btn-primary">
71
                        + {% trans "Add a new location" %}
72
                </a>
73
        {% endif %}
74
</div>
75
<div class="modal" id="servDets">
76
        <div class="modal-dialog">
77
            <div class="modal-content">
78
                        <div class="modal-header">
79
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
80
                                <h3 id="myModalLabelservdets">{% trans "Location Details" %}</h3>
81
                        </div>
82
                        <div class="modal-body" id="servDetsbody">
83
                        </div>
84
                        <div class="modal-footer">
85
                                <button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Close" %}</button>
86
                        </div>
87
                </div>
88
        </div>
89
</div>
90
{% endblock %}
91

    
92

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

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

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

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