8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-06-30 11:04:38 +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 %}
{% if iptype_list.paginator %}
{% include 'pagination.html' with list=iptype_list %}
{% include 'pagination.html' with list=iptype_list %}
{% endif %}
{% for type in iptype_list %}
<div class="panel panel-default">
<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 class="panel-body">
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
@ -83,9 +82,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr>
</table>
</div>
</div>
</div>
</div>
{% 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 i18n %}
<div class="table-responsive">
{% if machines_list.paginator %}
{% include 'pagination.html' with list=machines_list go_to_id="machines" %}
{% endif %}
{% if machines_list.paginator %}
{% include 'pagination.html' with list=machines_list %}
{% 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 %}
<tr class="info">
<td colspan="4">
{% 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">
{% for machine in machines_list %}
<div class="panel panel-default">
<div class="panel-heading">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
{% trans "No name" as tr_no_name %}
<i class="fa fa-user"></i> {{ machine.user }}
<i class="fa fa-angle-right"></i>
<b>{{ machine.get_name|default:tr_no_name }}</b>
</div>
<div class="col-sm-6 text-right">
{% 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 %}
@ -64,8 +50,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_delete machine %}
{% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
{% acl_end %}
</td>
</tr>
</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>
</thead>
{% for interface in machine.interface_set.all %}
<tr>
<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"
data-target="#collapseDomain_{{ interface.id }}" aria-expanded="true"
aria-controls="collapseDomain_{{ interface.id }}">
{% trans "Display the aliases" %}
{% trans "Show aliases" %}
</button>
{% else %}
{{ interface.domain }}
@ -159,59 +159,64 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% acl_end %}
</td>
</tr>
<tr>
<td colspan=5 style="border-top: none; padding: 1px;">
<div class="collapse in" id="collapseVendor_{{ interface.id }}">
<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;">
{{ interface.get_vendor }}
</li>
</ul>
</div>
</td>
</tr>
{% 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>
{% endif %}
{% 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: 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>
{% endif %}
{% endfor %}
<tr>
<td colspan="8"></td>
</tr>
<tr>
<td colspan=5 style="border-top: none; padding: 1px;">
<div class="collapse in" id="collapseVendor_{{ interface.id }}">
<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;">
{{ interface.get_vendor }}
</li>
</ul>
</div>
</td>
</tr>
{% 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>
{% endif %}
{% 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: 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>
{% endif %}
{% 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 () {
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++) {
@ -232,7 +237,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
});
</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 content %}
<div class="mt-20 md-20">
<h2>{% trans "List of IP types" %}</h2>
{% can_create 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' %}">
<i class="fa fa-trash"></i> {% trans "Delete one or several IP types" %}
</a>
</div>
{% include 'machines/aff_iptype.html' with iptype_list=iptype_list %}
{% endblock %}

View file

@ -14,52 +14,7 @@
<i class="fa fa-plus"></i> {% trans "Add a configuration" %}
</a>
{% acl_end %}
<table class="table table-striped">
<thead>
<tr>
<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>
<h2></h2>
{% include 'machines/aff_portlist.html' with port_list=port_list %}
{% endblock %}

View file

@ -1351,11 +1351,13 @@ def aff_profil(request, user):
@can_view_all(IpType)
def index_iptype(request):
"""View used to display the list of existing types of IP."""
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
iptype_list = (
IpType.objects.select_related("extension")
.select_related("vlan")
.order_by("name")
)
iptype_list = re2o_paginator(request, iptype_list, pagination_large_number)
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 %}
{% endif %}
<table class="table table-striped">
<thead>
<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 "Details" %}</th>
<th>{% trans "End of subscription on" %}</th>
<th>{% trans "Internet access" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
{% for room in room_list %}
<tr>
<td>{{ room.building }}</td>
<td>{{ room.name }}</td>
<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>
<td>{% if room.adherent %}<a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>{% else %} {% trans "None" %}{% endif %}</td>
<td>{{ room.details }}</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>
<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>
{% endfor %}
</table>
{%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>
<tr>
<th>{% trans "User"%}</th>
<th>{% trans "Connected to"%}</th>
<th>{% trans "End of subscription on" %}</th>
<th>{% trans "Internet access" %}</th>
</tr>
</thead>
<tr>
<td>
{% if room.adherent %}
<a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>
{% else %}
{% trans "None" %}
{% 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>
{% 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 %}
{% 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 i18n %}
{% if switch_list.paginator %}
{% include 'pagination.html' with list=switch_list %}
{% endif %}
{% for switch in switch_list %}
<div class="panel panel-default">
<div class="panel-heading">
@ -85,3 +89,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
{% endfor %}
{% if switch_list.paginator %}
{% include 'pagination.html' with list=switch_list %}
{% endif %}