8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

Add paginator, updates machines, create aff_machines, and minor changes

This commit is contained in:
grisel-davy 2020-10-24 00:52:25 +02:00
parent 685c88d2e5
commit dba0da249e
8 changed files with 283 additions and 180 deletions

View file

@ -29,10 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load i18n %} {% load i18n %}
{% if iptype_list.paginator %} {% if iptype_list.paginator %}
{% include 'pagination.html' with list=iptype_list %} {% include 'pagination.html' with list=iptype_list %}
{% endif %} {% endif %}
{% for type in iptype_list %} {% for type in iptype_list %}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
@ -59,8 +58,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
@ -83,9 +82,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
{% if iptype_list.paginator %}
{% include 'pagination.html' with list=iptype_list %}
{% endif %}

View file

@ -26,36 +26,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load logs_extra %} {% load logs_extra %}
{% load i18n %} {% load i18n %}
<div class="table-responsive"> {% if machines_list.paginator %}
{% if machines_list.paginator %} {% include 'pagination.html' with list=machines_list %}
{% include 'pagination.html' with list=machines_list go_to_id="machines" %} {% endif %}
{% endif %}
<table class="table" id="machines_table"> {% for machine in machines_list %}
<thead> <div class="panel panel-default">
{% trans "DNS name" as tr_dns_name %} <div class="panel-heading">
<th>{% include 'buttons/sort.html' with prefix='machine' col='name' text=tr_dns_name %}</th> <div class="container-fluid">
<th>{% trans "Type" %}</th> <div class="row">
<th>{% trans "MAC address" %}</th> <div class="col-sm-6">
<th>{% trans "IP address" %}</th> {% trans "No name" as tr_no_name %}
<th>{% trans "Actions" %}</th> <i class="fa fa-user"></i> {{ machine.user }}
<tbody> <i class="fa fa-angle-right"></i>
{% for machine in machines_list %} <b>{{ machine.get_name|default:tr_no_name }}</b>
<tr class="info"> </div>
<td colspan="4"> <div class="col-sm-6 text-right">
{% trans "No name" as tr_no_name %}
{% trans "View the profile" as tr_view_the_profile %}
{% if machine.active %}
<span class="text-success">
{% else %}
<span class="text-warning">{% trans "Deactivated" %}:
{% endif %}
<b>{{ machine.get_name|default:tr_no_name }}</b> </span><i class="fa fa-angle-right"></i>
<a href="{% url 'users:profil' userid=machine.user.id %}" title=tr_view_the_profile>
<i class="fa fa-user"></i> {{ machine.user }}
</a>
</td>
<td class="text-right">
{% can_create Interface machine.id %} {% can_create Interface machine.id %}
{% trans "Create an interface" as tr_create_an_interface %} {% 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 %} {% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc=tr_create_an_interface %}
@ -64,8 +50,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_delete machine %} {% can_delete machine %}
{% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %} {% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
{% acl_end %} {% acl_end %}
</td> </div>
</tr> </div>
</div>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "DNS name"%}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "MAC address" %}</th>
<th>{% trans "IP address" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
{% for interface in machine.interface_set.all %} {% for interface in machine.interface_set.all %}
<tr> <tr>
<td> <td>
@ -74,7 +74,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse" <button class="btn btn-default btn-xs" type="button" data-toggle="collapse"
data-target="#collapseDomain_{{ interface.id }}" aria-expanded="true" data-target="#collapseDomain_{{ interface.id }}" aria-expanded="true"
aria-controls="collapseDomain_{{ interface.id }}"> aria-controls="collapseDomain_{{ interface.id }}">
{% trans "Display the aliases" %} {% trans "Show aliases" %}
</button> </button>
{% else %} {% else %}
{{ interface.domain }} {{ interface.domain }}
@ -159,59 +159,64 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% acl_end %} {% acl_end %}
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan=5 style="border-top: none; padding: 1px;"> <td colspan=5 style="border-top: none; padding: 1px;">
<div class="collapse in" id="collapseVendor_{{ interface.id }}"> <div class="collapse in" id="collapseVendor_{{ interface.id }}">
<ul class="list-group" style="margin-bottom: 0;"> <ul class="list-group" style="margin-bottom: 0;">
<li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;"> <li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
{{ interface.get_vendor }} {{ interface.get_vendor }}
</li> </li>
</ul> </ul>
</div> </div>
</td> </td>
</tr> </tr>
{% if ipv6_enabled and interface.ipv6 != 'None' %} {% if ipv6_enabled and interface.ipv6 != 'None' %}
<tr> <tr>
<td colspan=5 style="border-top: none; padding: 1px;"> <td colspan=5 style="border-top: none; padding: 1px;">
<div class="collapse in" id="collapseIpv6_{{ interface.id }}"> <div class="collapse in" id="collapseIpv6_{{ interface.id }}">
<ul class="list-group" style="margin-bottom: 0;"> <ul class="list-group" style="margin-bottom: 0;">
{% for ipv6 in interface.ipv6.all %} {% for ipv6 in interface.ipv6.all %}
<li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;"> <li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
{{ ipv6 }} {{ ipv6 }}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if interface.domain.related_domain.all %} {% if interface.domain.related_domain.all %}
<tr> <tr>
<td colspan=5 style="border-top: none; padding: 1px;"> <td colspan=5 style="border-top: none; padding: 1px;">
<div class="collapse in" id="collapseDomain_{{ interface.id }}"> <div class="collapse in" id="collapseDomain_{{ interface.id }}">
<ul class="list-group" style="margin-bottom: 0;"> <ul class="list-group" style="margin-bottom: 0;">
{% for al in interface.domain.related_domain.all %} {% 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;"> <li class="list-group-item col-xs-6 col-sm-4 col-md-3" style="border: none;">
<a href="http://{{ al }}"> <a href="http://{{ al }}">
{{ al }} {{ al }}
<i class="fa fa-share"></i> <i class="fa fa-share"></i>
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% endfor %}
<tr>
<td colspan="8"></td>
</tr>
{% endfor %} {% endfor %}
</tbody> </table>
</table> </div>
</div>
</div>
{% endfor %}
<script>
{% if machines_list.paginator %}
{% include 'pagination.html' with list=machines_list %}
{% endif %}
<script>
$("#machines_table").ready(function () { $("#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 %}]; 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++) { for (var i = 0; i < alias_div.length; i++) {
@ -232,7 +237,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
}); });
</script> </script>
{% if machines_list.paginator %}
{% include 'pagination.html' with list=machines_list go_to_id="machines" %}
{% endif %}
</div>

View file

@ -0,0 +1,100 @@
{% 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 Lara 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 %}
{% load design %}
{% load acl %}
{% load logs_extra %}
{% load i18n %}
{% if port_list.paginator %}
{% include 'pagination.html' with list=port_list %}
{% endif %}
{% for ports in port_list %}
<div class="panel panel-default pt-2">
<div class="panel-heading">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
<h4>{{ ports.name }}</h4>
</div>
<div class="col-sm-9 text-right">
{% can_edit ports %}
{% include 'buttons/edit.html' with href='machines:edit-portlist' id=ports.id %}
{% acl_end %}
{% can_delete ports %}
{% include 'buttons/suppr.html' with href='machines:del-portlist' id=ports.id %}
{% acl_end %}
</div>
</div>
</div>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "TCP (input)" %}</th>
<th>{% trans "TCP (output)" %}</th>
<th>{% trans "UDP (input)" %}</th>
<th>{% trans "UDP (output)" %}</th>
</tr>
</thead>
<tr>
<td>{% for p in ports.tcp_ports_in %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in ports.tcp_ports_out %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in ports.udp_ports_in %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in ports.udp_ports_out %}{{ p.show_port }}, {% endfor %}</td>
</tr>
</table>
</div>
</div>
<div class="panel-footer">
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
{% trans "Machines" %}
</div>
<div class="col-sm-10">
{% if ports.interface_set.all %}
{% for interface in ports.interface_set.all %}
<a class="fa fa-desktop" href="{% url 'users:profil' userid=interface.machine.user.id %}">
{{ interface }}
</a>
{% endfor %}
{% else %}
{% trans "None" %}
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
{% if port_list.paginator %}
{% include 'pagination.html' with list=port_list %}
{% endif %}

View file

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}{% trans "Machines" %}{% endblock %} {% block title %}{% trans "Machines" %}{% endblock %}
{% block content %} {% block content %}
<div class="mt-20 md-20">
<h2>{% trans "List of IP types" %}</h2> <h2>{% trans "List of IP types" %}</h2>
{% can_create IpType %} {% can_create IpType %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-iptype' %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-iptype' %}">
@ -39,5 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-iptype' %}"> <a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-iptype' %}">
<i class="fa fa-trash"></i> {% trans "Delete one or several IP types" %} <i class="fa fa-trash"></i> {% trans "Delete one or several IP types" %}
</a> </a>
</div>
{% include 'machines/aff_iptype.html' with iptype_list=iptype_list %} {% include 'machines/aff_iptype.html' with iptype_list=iptype_list %}
{% endblock %} {% endblock %}

View file

@ -14,52 +14,7 @@
<i class="fa fa-plus"></i> {% trans "Add a configuration" %} <i class="fa fa-plus"></i> {% trans "Add a configuration" %}
</a> </a>
{% acl_end %} {% acl_end %}
<table class="table table-striped"> <h2></h2>
<thead>
<tr> {% include 'machines/aff_portlist.html' with port_list=port_list %}
<th>{% trans "Name" %}</th>
<th>{% trans "TCP (input)" %}</th>
<th>{% trans "TCP (output)" %}</th>
<th>{% trans "UDP (input)" %}</th>
<th>{% trans "UDP (output)" %}</th>
<th>{% trans "Machines" %}</th>
<th></th>
</tr>
</thead>
{% for pl in port_list %}
<tr>
<td>{{ pl.name }}</td>
<td>{% for p in pl.tcp_ports_in %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in pl.tcp_ports_out %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in pl.udp_ports_in %}{{ p.show_port }}, {% endfor %}</td>
<td>{% for p in pl.udp_ports_out %}{{ p.show_port }}, {% endfor %}</td>
<td>
{% if pl.interface_set.all %}
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="editioninterface"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="editioninterface">
{% for interface in pl.interface_set.all %}
<li>
<a href="{% url 'users:profil' userid=interface.machine.user.id %}">
{{ interface }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<td class="text-right">
{% can_edit pl %}
{% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %}
{% acl_end %}
{% can_delete pl %}
{% include 'buttons/suppr.html' with href='machines:del-portlist' id=pl.id %}
{% acl_end %}
</td>
</tr>
{% endfor %}
</table>
{% endblock %} {% endblock %}

View file

@ -1351,11 +1351,13 @@ def aff_profil(request, user):
@can_view_all(IpType) @can_view_all(IpType)
def index_iptype(request): def index_iptype(request):
"""View used to display the list of existing types of IP.""" """View used to display the list of existing types of IP."""
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
iptype_list = ( iptype_list = (
IpType.objects.select_related("extension") IpType.objects.select_related("extension")
.select_related("vlan") .select_related("vlan")
.order_by("name") .order_by("name")
) )
iptype_list = re2o_paginator(request, iptype_list, pagination_large_number)
return render(request, "machines/index_iptype.html", {"iptype_list": iptype_list}) return render(request, "machines/index_iptype.html", {"iptype_list": iptype_list})

View file

@ -30,44 +30,79 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% include 'pagination.html' with list=room_list %} {% include 'pagination.html' with list=room_list %}
{% endif %} {% endif %}
<table class="table table-striped"> {%for room in room_list %}
<thead> <div class="panel panel-default">
<tr> <div class="panel-heading">
{% trans "Room" as tr_room %} <div class="container-fluid">
{% trans "Building" as tr_building %} <div class="row">
<th>{% include 'buttons/sort.html' with prefix='building' col='name' text=tr_building %}</th> <div class="col-sm-4">
<th>{% include 'buttons/sort.html' with prefix='room' col='name' text=tr_room %}</th> <h4>{{ room.building }} - {{room.name }}</h4>
<th>{% trans "Connnected to" %}</th> </div>
<th>{% trans "User" %}</th> <div class="col-sm-8 text-right">
<th>{% trans "Details" %}</th> {% if room.port_set.all %}
<th>{% trans "End of subscription on" %}</th> <a href="{% url 'multi_op:disconnect-room' room.id %}" class="btn btn-danger btn-sm" role="button"><i class="fa fa-expand"></i></a>
<th>{% trans "Internet access" %}</th> {% endif %}
<th>{% trans "Action" %}</th> </div>
</tr> </div>
</thead> </div>
{% for room in room_list %} </div>
<tr> <div class="panel-body">
<td>{{ room.building }}</td> <div class="table-repsonsive">
<td>{{ room.name }}</td> <table class="table">
<td>{% if room.port_set.all %}<span class="label label-success">{{ asso_name }}{% else %}<span class="label label-danger">{% trans "Other operator" %}{% endif %}</span></td> <thead>
<td>{% if room.adherent %}<a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>{% else %} {% trans "None" %}{% endif %}</td> <tr>
<td>{{ room.details }}</td> <th>{% trans "User"%}</th>
<td>{% if room.adherent.is_adherent %}<i class="text-success">{% else %}<i class="text-danger">{% endif %}{% if room.adherent.end_adhesion %}{{ room.adherent.end_adhesion}}{% else %}{% trans "Non member" %}{% endif %}</i></td> <th>{% trans "Connected to"%}</th>
<td> <th>{% trans "End of subscription on" %}</th>
{% if room.adherent.has_access == True %} <th>{% trans "Internet access" %}</th>
<i class="text-success">{% trans "Active" %}</i> </tr>
{% else %} </thead>
<i class="text-danger">{% trans "Disabled" %}</i> <tr>
{% endif %} <td>
</td> {% if room.adherent %}
<td> <a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>
{% if room.port_set.all %} {% else %}
<a href="{% url 'multi_op:disconnect-room' room.id %}" class="btn btn-danger btn-sm" role="button"><i class="fa fa-expand"></i></a> {% trans "None" %}
{% endif %} {% endif %}
</td> </td>
</tr> <td>
{% endfor %} {% if room.port_set.all %}
</table> <span class="label label-success">{{ asso_name }}</span>
{% else %}
<span class="label label-danger">{% trans "Other operator" %}</span>
{% endif %}
</td>
<td>
{% if room.adherent.is_adherent %}
<i class="text-success">
{% else %}
<i class="text-danger">
{% endif %}
{% if room.adherent.end_adhesion %}
{{ room.adherent.end_adhesion}}
{% else %}
{% trans "Non member" %}
{% endif %}
</i>
</td>
<td>
{% if room.adherent.has_access == True %}
<i class="text-success">{% trans "Active" %}</i>
{% else %}
<i class="text-danger">{% trans "Disabled" %}</i>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
{% if room.details %}
<div class="panel-footer">
<span><b>{% trans "Details: " %}</b>{{ room.details }}</span>
</div>
{% endif %}
</div>
{% endfor %}
{% if room_list.paginator %} {% if room_list.paginator %}
{% include 'pagination.html' with list=room_list %} {% include 'pagination.html' with list=room_list %}

View file

@ -26,6 +26,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load logs_extra %} {% load logs_extra %}
{% load i18n %} {% load i18n %}
{% if switch_list.paginator %}
{% include 'pagination.html' with list=switch_list %}
{% endif %}
{% for switch in switch_list %} {% for switch in switch_list %}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
@ -85,3 +89,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
{% endfor %} {% endfor %}
{% if switch_list.paginator %}
{% include 'pagination.html' with list=switch_list %}
{% endif %}