aff_machines.html 11.4 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 26
{% load acl %}
{% load logs_extra %}
27
{% load i18n %}
28

29
<div class="table-responsive">
30
    {% if machines_list.paginator %}
31
        {% include 'pagination.html' with list=machines_list go_to_id="machines" %}
32
    {% endif %}
33

34 35 36 37 38 39 40 41 42
    <table class="table" id="machines_table">
        <colgroup>
            <col>
            <col>
            <col>
            <col width="{% if ipv6_enabled %}300{% else %}150{% endif %}px">
            <col width="144px">
        </colgroup>
        <thead>
43
            {% trans "DNS name" as tr_dns_name %}
44
            <th>{% include 'buttons/sort.html' with prefix='machine' col='name' text=tr_dns_name %}</th>
45 46 47 48
            <th>{% trans "Type" %}</th>
            <th>{% trans "MAC address" %}</th>
            <th>{% trans "IP address" %}</th>
            <th>{% trans "Actions" %}</th>
49
            <tbody>
50
            {% for machine in machines_list %}
51 52
                <tr class="info">
                    <td colspan="4">
53 54
                        {% trans "No name" as tr_no_name %}
                        {% trans "View the profile" as tr_view_the_profile %}
55 56 57
                        {% if machine.active %}
                        <span class="text-success">
                        {% else %}
klafyvel's avatar
klafyvel committed
58
                        <span class="text-warning">{% trans "Deactivated" %}: 
59 60
                        {% endif %}
                        <b>{{ machine.get_name|default:tr_no_name }}</b> </span><i class="fa fa-angle-right"></i>
61
                        <a href="{% url 'users:profil' userid=machine.user.id %}" title=tr_view_the_profile>
62 63 64 65
                            <i class="fa fa-user"></i> {{ machine.user }}
                        </a>
                    </td>
                    <td class="text-right">
66 67 68
                    {% can_create Interface machine.id %}
                    {% trans "Create an interface" as tr_create_an_interface %}
                    {% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc=tr_create_an_interface %}
erdnaxe's avatar
erdnaxe committed
69 70 71
                    {% acl_end %}
                    {% history_button machine %}
                    {% can_delete machine %}
72
                    {% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
erdnaxe's avatar
erdnaxe committed
73 74 75 76
                    {% acl_end %}
                </td>
            </tr>
            {% for interface in machine.interface_set.all %}
77 78 79
                <tr>
                    <td>
                        {% if interface.domain.related_domain.all %}
erdnaxe's avatar
erdnaxe committed
80 81 82 83 84 85
                            {{ 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 }}">
                                {% trans "Display the aliases" %}
                            </button>
86
                        {% else %}
erdnaxe's avatar
erdnaxe committed
87
                            {{ interface.domain }}
88 89 90 91
                        {% endif %}
                    </td>
                    <td>
                        {{ interface.type }}
erdnaxe's avatar
erdnaxe committed
92
                    </td>
93 94 95 96 97 98
                    <td>
                        {{ interface.mac_address }}
                    </td>
                    <td>
                        <b>IPv4</b> {{ interface.ipv4 }}
                        <br>
erdnaxe's avatar
erdnaxe committed
99 100 101 102 103 104 105
                        {% if ipv6_enabled and interface.ipv6 != 'None' %}
                            <b>IPv6</b>
                            <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 }}">
                                {% trans "Display the IPv6 address" %}
                            </button>
106 107 108 109 110
                        {% endif %}
                    </td>
                    <td class="text-right">
                        <div style="width: 128px;">
                            <div class="btn-group" role="group">
erdnaxe's avatar
erdnaxe committed
111 112 113
                                <button class="btn btn-primary btn-sm dropdown-toggle" type="button"
                                        id="editioninterface" data-toggle="dropdown" aria-haspopup="true"
                                        aria-expanded="true">
114 115
                                    <i class="fa fa-edit"></i> <span class="caret"></span>
                                </button>
116
                                <ul class="dropdown-menu" aria-labelledby="editioninterface">
117
                                    {% can_edit interface %}
erdnaxe's avatar
erdnaxe committed
118 119 120 121 122 123
                                        <li>
                                            <a href="{% url 'machines:edit-interface' interface.id %}">
                                                <i class="fa fa-edit"></i>
                                                {% trans " Edit" %}
                                            </a>
                                        </li>
124 125
                                    {% acl_end %}
                                    {% can_create Domain interface.id %}
erdnaxe's avatar
erdnaxe committed
126 127 128 129 130 131
                                        <li>
                                            <a href="{% url 'machines:index-alias' interface.id %}">
                                                <i class="fa fa-edit"></i>
                                                {% trans " Manage the aliases" %}
                                            </a>
                                        </li>
132 133
                                    {% acl_end %}
                                    {% can_create Ipv6List interface.id %}
erdnaxe's avatar
erdnaxe committed
134 135 136 137 138 139
                                        <li>
                                            <a href="{% url 'machines:index-ipv6' interface.id %}">
                                                <i class="fa fa-edit"></i>
                                                {% trans " Manage the IPv6 addresses" %}
                                            </a>
                                        </li>
140
                                    {% acl_end %}
141
                                    {% can_create SshFp interface.machine.id %}
erdnaxe's avatar
erdnaxe committed
142 143 144 145 146 147
                                        <li>
                                            <a href="{% url 'machines:index-sshfp' interface.machine.id %}">
                                                <i class="fa fa-edit"></i>
                                                {% trans " Manage the SSH fingerprints" %}
                                            </a>
                                        </li>
148
                                    {% acl_end %}
149
                                    {% can_create OuverturePortList %}
erdnaxe's avatar
erdnaxe committed
150 151 152 153 154 155
                                        <li>
                                            <a href="{% url 'machines:port-config' interface.id %}">
                                                <i class="fa fa-edit"></i>
                                                {% trans " Manage the ports configuration" %}
                                            </a>
                                        </li>
156 157 158 159 160
                                    {% acl_end %}
                                </ul>
                            </div>
                            {% history_button interface %}
                            {% can_delete interface %}
161
                            {% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %}
162
                            {% acl_end %}
163 164 165
                        </div>
                    </td>
                </tr>
erdnaxe's avatar
erdnaxe committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179
                {% if ipv6_enabled and interface.ipv6 != 'None' %}
                    <tr>
                        <td colspan=5 style="border-top: none; padding: 1px;">
                            <div class="collapse in" id="collapseIpv6_{{ interface.id }}">
                                <ul class="list-group" style="margin-bottom: 0;">
                                    {% for ipv6 in interface.ipv6.all %}
                                        <li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
                                            {{ ipv6 }}
                                        </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </td>
                    </tr>
180 181
                {% endif %}
                {% if interface.domain.related_domain.all %}
erdnaxe's avatar
erdnaxe committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
                    <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: 0;">
                                    {% 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 }}
                                                <i class="fa fa-share"></i>
                                            </a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </td>
                    </tr>
198 199
                {% endif %}
            {% endfor %}
erdnaxe's avatar
erdnaxe committed
200 201 202 203 204
            <tr>
                <td colspan="8"></td>
            </tr>
        {% endfor %}
        </tbody>
205
    </table>
206

207
    <script>
erdnaxe's avatar
erdnaxe committed
208 209 210 211 212 213 214 215 216 217 218 219
        $("#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');
            }
        });
        $("#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');
            }
        });
220
    </script>
221

222
    {% if machines_list.paginator %}
223
        {% include 'pagination.html' with list=machines_list go_to_id="machines" %}
224
    {% endif %}
225
</div>