aff_machines.html 7.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
quelques clics.

Copyright © 2017  Gabriel Détraz
Copyright © 2017  Goulven Kermarec
Copyright © 2017  Augustin Lemesle

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}

25
{% load acl %}
26
<div class="table-responsive">
Dalahro's avatar
Dalahro committed
27
{% if machines_list.paginator %}
lhark's avatar
lhark committed
28 29
{% include "pagination.html" with list=machines_list %}
{% endif %}
30

31

32
<table class="table" id="machines_table">
33 34 35 36 37 38 39
    <colgroup>
        <col>
        <col>
        <col>
        <col width="{% if ipv6_enabled %}300{% else %}150{% endif %}px">
        <col width="144px">
    </colgroup>
lhark's avatar
lhark committed
40
    <thead>
41
        <th>{% include "buttons/sort.html" with prefix='machine' col='name' text='Nom DNS' %}</th>
42 43 44 45 46
        <th>Type</th>
        <th>MAC</th>
        <th>IP</th>
        <th>Actions</th>
    <tbody>
lhark's avatar
lhark committed
47
    {% for machine in machines_list %}
48 49
        <tr class="info">
            <td colspan="4">
50
                <b>{{ machine.name|default:'<i>Pas de nom</i>' }}</b> <i class="fa-angle-right"></i>
51
                <a href="{% url 'users:profil' userid=machine.user.id %}" title="Voir le profil">
52
                    <i class="fa fa-user"></i> {{ machine.user }}
53 54 55
                </a>
            </td>
            <td class="text-right">
56
             {% can_create Interface machine.id %}
lhark's avatar
lhark committed
57
                {% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc='Ajouter une interface' %}
58
             {% acl_end %}
lhark's avatar
lhark committed
59
                {% include 'buttons/history.html' with href='machines:history' name='machine' id=machine.id %}
60
	     {% can_delete machine %}
61
                {% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
62
	     {% acl_end %}
lhark's avatar
lhark committed
63
            </td>
64 65 66
        </tr>
        {% for interface in machine.interface_set.all %}
        <tr>
lhark's avatar
lhark committed
67
            <td>
chirac's avatar
chirac committed
68
            {% if interface.domain.related_domain.all %}
69 70 71 72
	        {{ interface.domain }}
		<button class="btn btn-default btn-xs" type="button" data-toggle="collapse" data-target="#collapseDomain_{{interface.id}}" aria-expanded="true" aria-controls="collapseDomain_{{interface.id}}">
                    Afficher les alias
                </button>
lhark's avatar
lhark committed
73
            {% else %}
chirac's avatar
chirac committed
74
                {{ interface.domain }}
lhark's avatar
lhark committed
75 76
            {% endif %}
            </td>
lhark's avatar
lhark committed
77
            <td>
78 79 80 81 82 83 84 85 86
                {{ interface.type }}
            </td>
            <td>
                {{ interface.mac_address }}
            </td>
            <td>
                <b>IPv4</b> {{ interface.ipv4 }}
                <br>
                {% if ipv6_enabled and interface.ipv6 != 'None'%}
B's avatar
B committed
87
                <b>IPv6</b>
88
            		<button class="btn btn-default btn-xs" type="button" data-toggle="collapse" data-target="#collapseIpv6_{{interface.id}}" aria-expanded="true" aria-controls="collapseIpv6_{{interface.id}}">
B's avatar
B committed
89
                        Afficher l'IPV6
90
                        </button>
91 92 93 94 95
                {% endif %}
            </td>
            <td class="text-right">
                <div class="dropdown" style="width: 128px;">
                    <button class="btn btn-primary btn-sm dropdown-toggle" type="button" id="editioninterface" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
96
                        <i class="fa fa-edit"></i> <span class="caret"></span>
lhark's avatar
lhark committed
97
                    </button>
98
                    {% include 'buttons/history.html' with href='machines:history' name='interface' id=interface.id %}
99
		    {% can_delete interface %}
100
                    {% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %}
101 102 103 104
		    {% acl_end %}
		    <ul class="dropdown-menu" aria-labelledby="editioninterface">
			{% can_edit interface %}
			<li>
lhark's avatar
lhark committed
105
                            <a href="{% url 'machines:edit-interface' interface.id %}">
106
                                <i class="fa fa-edit"></i> Editer
lhark's avatar
lhark committed
107 108
                            </a>
                        </li>
109 110
		        {% acl_end %}
			{% can_create Domain interface.id %}
lhark's avatar
lhark committed
111
                        <li>
112
                            <a href="{% url 'machines:index-alias' interface.id %}">
113
                                <i class="fa fa-edit"></i> Gerer les alias
114 115
                            </a>
                        </li>
116
			{% acl_end %}
117 118 119
			{% can_create Ipv6List interface.id %}
                        <li>
                            <a href="{% url 'machines:index-ipv6' interface.id %}">
120
                                <i class="fa fa-edit"></i> Gerer les ipv6
121 122 123
                            </a>
                        </li>
			{% acl_end %}
124
			{% can_create OuverturePortList %}
lhark's avatar
lhark committed
125
                        <li>
126
                            <a href="{% url 'machines:port-config' interface.id%}">
127
                                <i class="fa fa-edit"></i> Gerer la configuration des ports
lhark's avatar
lhark committed
128 129
                            </a>
                        </li>
130
			{% acl_end %}
lhark's avatar
lhark committed
131 132 133
                    </ul>
                </div>
            </td>
134
        </tr>
B's avatar
B committed
135

136 137
        {% if ipv6_enabled and interface.ipv6 != 'None'%}
        <tr>
B's avatar
B committed
138
            <td colspan=5 style="border-top: none; padding: 1px;">
139
		 <div class="collapse in" id="collapseIpv6_{{interface.id}}">
B's avatar
B committed
140
                    <ul class="list-group" style="margin-bottom: 0px;">
141
		    {% for ipv6 in interface.ipv6.all %}
142
                        <li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
143 144 145 146
		        {{ipv6}}
			</li>
		        {% endfor %}
		    </ul>
B's avatar
B committed
147 148 149 150 151 152
                </div>
            </td>
        <tr>
        {% endif %}


153 154 155 156 157 158 159 160 161
	{% if interface.domain.related_domain.all %}
	<tr>
            <td colspan=5 style="border-top: none; padding: 1px;">
                <div class="collapse in" id="collapseDomain_{{interface.id}}">
                    <ul class="list-group" style="margin-bottom: 0px;">
                        {% for al in interface.domain.related_domain.all %}
                        <li class="list-group-item col-xs-6 col-sm-4 col-md-3" style="border: none;">
                            <a href="http://{{ al }}">
                                {{ al }}
162
                                <i class="fa fa-share"></i>
163 164 165 166 167 168 169 170
                            </a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </td>
        <tr>
        {% endif %}
171
        {% endfor %}
lhark's avatar
lhark committed
172 173 174 175
        <tr>
            <td colspan="8"></td>
        </tr>
    {% endfor %}
176
    </tbody>
lhark's avatar
lhark committed
177
</table>
178

179

180 181 182 183 184 185 186
<script>
$("#machines_table").ready( function() {
    var alias_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.domain.related_domain.all %}$("#collapseDomain_{{interface.id}}"), {% endif %}{% endfor %}{% endfor %}];
    for (var i=0 ; i<alias_div.length ; i++) {
	alias_div[i].collapse('hide');
    }
} );
187 188 189 190 191 192
$("#machines_table").ready( function() {
    var ipv6_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.ipv6.all %}$("#collapseIpv6_{{interface.id}}"), {% endif %}{% endfor %}{% endfor %}];
    for (var i=0 ; i<ipv6_div.length ; i++) {
	ipv6_div[i].collapse('hide');
    }
} );
193 194
</script>

195 196 197
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% endif %}
198
</div>