From 11bf585025f427ab4c7cdf156be5112cae77cc41 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 17 Oct 2015 23:03:19 +0530 Subject: [PATCH] networks: Show network diagram - As discussed in the first boot redesign proposal. - Images are taken from Tango icon set, GNOME icons or created. - Responsive, works for very small widths also. - First cut, special cases of network connectivity are not handled. --- LICENSES | 7 + plinth/modules/first_boot/views.py | 6 +- .../templates/connections_diagram.html | 126 + .../networks/templates/connections_list.html | 6 +- plinth/network.py | 13 +- .../themes/default/img/network-computer.svg | 1779 ++++++++++++ .../img/network-connection-vertical.svg | 197 ++ .../themes/default/img/network-connection.svg | 512 ++++ .../themes/default/img/network-ethernet.svg | 468 +++ .../themes/default/img/network-freedombox.svg | 155 + .../themes/default/img/network-internet.svg | 2528 +++++++++++++++++ static/themes/default/img/network-spacing.svg | 58 + .../themes/default/img/network-wireless.svg | 254 ++ 13 files changed, 6104 insertions(+), 5 deletions(-) create mode 100644 plinth/modules/networks/templates/connections_diagram.html create mode 100644 static/themes/default/img/network-computer.svg create mode 100644 static/themes/default/img/network-connection-vertical.svg create mode 100644 static/themes/default/img/network-connection.svg create mode 100644 static/themes/default/img/network-ethernet.svg create mode 100644 static/themes/default/img/network-freedombox.svg create mode 100644 static/themes/default/img/network-internet.svg create mode 100644 static/themes/default/img/network-spacing.svg create mode 100644 static/themes/default/img/network-wireless.svg diff --git a/LICENSES b/LICENSES index e10df63a0..2fc723b6a 100644 --- a/LICENSES +++ b/LICENSES @@ -37,3 +37,10 @@ otherwise. - static/themes/default/img/FreedomBox-logo-standard.png :: - - static/themes/default/img/FreedomBox-logo-standard.svg :: - - static/themes/default/img/freedombox-logotype.png :: - +- static/themes/default/img/network-computer.svg :: [[https://commons.wikimedia.org/wiki/File:Gnome-computer.svg][LGPLv3+]] +- static/themes/default/img/network-connection.svg :: [[http://tango.freedesktop.org/][Public Domain]] +- static/themes/default/img/network-connection-vertical.svg :: [[http://tango.freedesktop.org/][Public Domain]] +- static/themes/default/img/network-ethernet.svg :: [[http://tango.freedesktop.org/][Public Domain]] +- static/themes/default/img/network-freedombox.svg :: [[http://thread.gmane.org/gmane.linux.debian.freedombox.user/4124/focus=4439][GPL3+/CC-BY-SA]] +- static/themes/default/img/network-internet.svg :: [[http://tango.freedesktop.org/][Public Domain]] +- static/themes/default/img/network-wireless.svg :: [[http://tango.freedesktop.org/][Public Domain]] diff --git a/plinth/modules/first_boot/views.py b/plinth/modules/first_boot/views.py index a59efef16..cfc5cc945 100644 --- a/plinth/modules/first_boot/views.py +++ b/plinth/modules/first_boot/views.py @@ -23,6 +23,7 @@ from django.views.generic import CreateView, TemplateView from gettext import gettext as _ from plinth import kvstore +from plinth import network from .forms import State1Form @@ -53,6 +54,9 @@ def state10(request): if User.objects.all(): kvstore.set('firstboot_state', 10) + connections = network.get_connection_list() + return render_to_response('firstboot_state10.html', - {'title': _('Setup Complete')}, + {'title': _('Setup Complete'), + 'connections': connections}, context_instance=RequestContext(request)) diff --git a/plinth/modules/networks/templates/connections_diagram.html b/plinth/modules/networks/templates/connections_diagram.html new file mode 100644 index 000000000..7a385c05e --- /dev/null +++ b/plinth/modules/networks/templates/connections_diagram.html @@ -0,0 +1,126 @@ +{% comment %} +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +{% endcomment %} + +{% load static %} + + + +
+
+ Internet +
+
+ + + Connection +
+

External

+ {% for connection in connections %} + {% if connection.interface_name and connection.is_active and connection.zone == 'external' %} + {% if connection.type == '802-3-ethernet' %} + Ethernet + {% elif connection.type == '802-11-wireless' %} + Wi-Fi + {% endif %} + + {{ connection.name }} ({{ connection.interface_name }}) + {% endif %} + {% endfor %} +
+
+
+ FreedomBox +
+
+ + +
+

Internal

+ {% for connection in connections %} + {% if connection.interface_name and connection.is_active and connection.zone == 'internal' %} +

+ {% if connection.type == '802-3-ethernet' %} + Ethernet + {% elif connection.type == '802-11-wireless' %} + Wi-Fi + {% endif %} + + {{ connection.name }} ({{ connection.interface_name }}) +

+ {% endif %} + {% endfor %} +
+ Connection +
+
+ Computer +
+
diff --git a/plinth/modules/networks/templates/connections_list.html b/plinth/modules/networks/templates/connections_list.html index bca0a5ec2..739934174 100644 --- a/plinth/modules/networks/templates/connections_list.html +++ b/plinth/modules/networks/templates/connections_list.html @@ -56,7 +56,7 @@ {% block content %}
-
+
{% for connection in connections %}
@@ -99,11 +99,13 @@ {{ connection.name }} - {{ connection.type }} + {{ connection.type_name }}
{% endfor %}
+ {% include "connections_diagram.html" %} + {% include "diagnostics_button.html" with module="networks" %}
diff --git a/plinth/network.py b/plinth/network.py index e40b1ec05..7daf302dc 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -213,13 +213,22 @@ def get_connection_list(): for connection in client.get_connections(): # Display a friendly type name if known. connection_type = connection.get_connection_type() - connection_type = CONNECTION_TYPE_NAMES.get(connection_type, - connection_type) + connection_type_name = CONNECTION_TYPE_NAMES.get(connection_type, + connection_type) + + settings_connection = connection.get_setting_connection() + zone = settings_connection.get_zone() + + connection.get_interface_name() + connections.append({ 'name': connection.get_id(), 'uuid': connection.get_uuid(), + 'interface_name': connection.get_interface_name(), 'type': connection_type, + 'type_name': connection_type_name, 'is_active': connection.get_uuid() in active_uuids, + 'zone': zone, }) connections.sort(key=lambda connection: connection['is_active'], reverse=True) diff --git a/static/themes/default/img/network-computer.svg b/static/themes/default/img/network-computer.svg new file mode 100644 index 000000000..7dfc79d33 --- /dev/null +++ b/static/themes/default/img/network-computer.svg @@ -0,0 +1,1779 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Computer + + + Lapo Calamandrei + + + + + + + + + Jakub Steiner +Luca Ferretti <elle.uca@libero.it> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/default/img/network-connection-vertical.svg b/static/themes/default/img/network-connection-vertical.svg new file mode 100644 index 000000000..753459a4e --- /dev/null +++ b/static/themes/default/img/network-connection-vertical.svg @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/static/themes/default/img/network-connection.svg b/static/themes/default/img/network-connection.svg new file mode 100644 index 000000000..0dbb6e92b --- /dev/null +++ b/static/themes/default/img/network-connection.svg @@ -0,0 +1,512 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + server + daemon + comupetr + lan + service + provider + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/default/img/network-ethernet.svg b/static/themes/default/img/network-ethernet.svg new file mode 100644 index 000000000..a9fa51c2f --- /dev/null +++ b/static/themes/default/img/network-ethernet.svg @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + Network + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/default/img/network-freedombox.svg b/static/themes/default/img/network-freedombox.svg new file mode 100644 index 000000000..90bd3f145 --- /dev/null +++ b/static/themes/default/img/network-freedombox.svg @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/static/themes/default/img/network-internet.svg b/static/themes/default/img/network-internet.svg new file mode 100644 index 000000000..388dfc446 --- /dev/null +++ b/static/themes/default/img/network-internet.svg @@ -0,0 +1,2528 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-overcast + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/default/img/network-spacing.svg b/static/themes/default/img/network-spacing.svg new file mode 100644 index 000000000..1e5771f44 --- /dev/null +++ b/static/themes/default/img/network-spacing.svg @@ -0,0 +1,58 @@ + + + + + + + + + + image/svg+xml + + + + + + + + diff --git a/static/themes/default/img/network-wireless.svg b/static/themes/default/img/network-wireless.svg new file mode 100644 index 000000000..81f7f6103 --- /dev/null +++ b/static/themes/default/img/network-wireless.svg @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + Wi-Fi network + + + + + + + + + + + + + + + + + + + + + + +