networks: Update main networks page Internet connectivity section

Closes: #1555

Signed-off-by: Nektarios Katakis <iam@nektarioskatakis.xyz>
[sunil: Use the term 'network topology' consistently]
[sunil: s/Router/router in template]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Nektarios Katakis 2020-02-29 06:12:46 +00:00 committed by Sunil Mohan Adapa
parent 2a00b186ea
commit 06664e1489
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
4 changed files with 51 additions and 33 deletions

View File

@ -0,0 +1,43 @@
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
<h3>
{% blocktrans trimmed %}
{{ box_name }} Internet Connectivity
{% endblocktrans %}
</h3>
<p>
{% blocktrans trimmed %}
The following best describes how your {{ box_name }} is connected in your
network. This information is used only to suggest necessary configuration
actions.
{% endblocktrans %}
</p>
<p>
{% if network_topology == "to_router" %}
{% blocktrans trimmed %}
Your {{ box_name }} gets its Internet connection from your router via Wi-Fi
or Ethernet cable. This is a typical home setup.
{% endblocktrans %}
{% elif network_topology == "as_router" %}
{% blocktrans trimmed %}
Your {{ box_name }} is directly connected to the Internet and all your
devices connect to {{ box_name }} for their Internet connectivity.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
Your Internet connection is directly attached to your {{ box_name }} and there
are no other devices on the network.
{% endblocktrans %}
{% endif %}
<a href="{% url 'networks:network-topology' %}" class="btn btn-default"
role="button">
{% trans 'Update...' %}
</a>
</p>

View File

@ -42,7 +42,7 @@
{% block configuration %}
{% include "connections_list.html" %}
{% include "router_configuration_main.html" %}
{% include "network_topology_main.html" %}
{% include "internet_connectivity_main.html" %}
{% endblock %}

View File

@ -1,31 +0,0 @@
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
<h3>
{% blocktrans trimmed %}
{{ box_name }} Internet Connectivity
{% endblocktrans %}
</h3>
<p>
{% blocktrans trimmed %}
The following best describes how your {{ box_name }} is connected in your
network. This information is used only to suggest necessary configuration
actions.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
Your {{ box_name }} gets its Internet from your Router via Wi-Fi or
Ethernet cable. This is a typical home setup.
{% endblocktrans %}
<a href="{% url 'networks:router-configuration' %}" class="btn btn-default"
role="button">
{% trans 'Update...' %}
</a>
</p>

View File

@ -24,6 +24,8 @@ def index(request):
"""Show connection list."""
connections = network.get_connection_list()
network_topology = kvstore.get_default(networks.NETWORK_TOPOLOGY_TYPE_KEY,
'to_router')
internet_connection_type = kvstore.get_default(
networks.INTERNET_CONNECTION_TYPE_KEY, 'unknown')
return TemplateResponse(
@ -34,7 +36,8 @@ def index(request):
'has_diagnostics': True,
'is_enabled': True,
'connections': connections,
'internet_connectivity_type': internet_connection_type
'network_topology': network_topology,
'internet_connectivity_type': internet_connection_type,
})
@ -426,6 +429,9 @@ class NetworkTopologyView(FormView):
logger.info('Updating network topology type with value %s' %
network_topology)
kvstore.set(networks.NETWORK_TOPOLOGY_TYPE_KEY, network_topology)
if network_topology == 'to_router':
self.success_url = reverse_lazy('networks:router-configuration')
return super().form_valid(form)