8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +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 committed by Gabriel Detraz
parent f731038eb2
commit 160230d7a1
8 changed files with 283 additions and 180 deletions

View file

@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% 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">
@ -87,5 +86,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</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 go_to_id="machines" %} {% include 'pagination.html' with list=machines_list %}
{% endif %} {% endif %}
<table class="table" id="machines_table">
<thead>
{% trans "DNS name" as tr_dns_name %}
<th>{% include 'buttons/sort.html' with prefix='machine' col='name' text=tr_dns_name %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "MAC address" %}</th>
<th>{% trans "IP address" %}</th>
<th>{% trans "Actions" %}</th>
<tbody>
{% for machine in machines_list %} {% for machine in machines_list %}
<tr class="info"> <div class="panel panel-default">
<td colspan="4"> <div class="panel-heading">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
{% trans "No name" as tr_no_name %} {% 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 }} <i class="fa fa-user"></i> {{ machine.user }}
</a> <i class="fa fa-angle-right"></i>
</td> <b>{{ machine.get_name|default:tr_no_name }}</b>
<td class="text-right"> </div>
<div class="col-sm-6 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>
</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> </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 }}
@ -204,12 +204,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr> </tr>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<tr>
<td colspan="8"></td>
</tr>
{% endfor %}
</tbody>
</table> </table>
</div>
</div>
</div>
{% endfor %}
{% if machines_list.paginator %}
{% include 'pagination.html' with list=machines_list %}
{% endif %}
<script> <script>
$("#machines_table").ready(function () { $("#machines_table").ready(function () {
@ -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,29 +30,61 @@ 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 %}
<div class="panel panel-default">
<div class="panel-heading">
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<h4>{{ room.building }} - {{room.name }}</h4>
</div>
<div class="col-sm-8 text-right">
{% if room.port_set.all %}
<a href="{% url 'multi_op:disconnect-room' room.id %}" class="btn btn-danger btn-sm" role="button"><i class="fa fa-expand"></i></a>
{% endif %}
</div>
</div>
</div>
</div>
<div class="panel-body">
<div class="table-repsonsive">
<table class="table">
<thead> <thead>
<tr> <tr>
{% trans "Room" as tr_room %}
{% trans "Building" as tr_building %}
<th>{% include 'buttons/sort.html' with prefix='building' col='name' text=tr_building %}</th>
<th>{% include 'buttons/sort.html' with prefix='room' col='name' text=tr_room %}</th>
<th>{% trans "Connnected to" %}</th>
<th>{% trans "User"%}</th> <th>{% trans "User"%}</th>
<th>{% trans "Details" %}</th> <th>{% trans "Connected to"%}</th>
<th>{% trans "End of subscription on" %}</th> <th>{% trans "End of subscription on" %}</th>
<th>{% trans "Internet access" %}</th> <th>{% trans "Internet access" %}</th>
<th>{% trans "Action" %}</th>
</tr> </tr>
</thead> </thead>
{% for room in room_list %}
<tr> <tr>
<td>{{ room.building }}</td> <td>
<td>{{ room.name }}</td> {% if room.adherent %}
<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> <a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>
<td>{% if room.adherent %}<a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>{% else %} {% trans "None" %}{% endif %}</td> {% else %}
<td>{{ room.details }}</td> {% trans "None" %}
<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> {% endif %}
</td>
<td>
{% if room.port_set.all %}
<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> <td>
{% if room.adherent.has_access == True %} {% if room.adherent.has_access == True %}
<i class="text-success">{% trans "Active" %}</i> <i class="text-success">{% trans "Active" %}</i>
@ -60,14 +92,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="text-danger">{% trans "Disabled" %}</i> <i class="text-danger">{% trans "Disabled" %}</i>
{% endif %} {% endif %}
</td> </td>
<td>
{% if room.port_set.all %}
<a href="{% url 'multi_op:disconnect-room' room.id %}" class="btn btn-danger btn-sm" role="button"><i class="fa fa-expand"></i></a>
{% endif %}
</td>
</tr> </tr>
{% endfor %}
</table> </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 %}