From 6e557dd1e967bce6abd95fae00e1a2c57c605e1f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 13 Mar 2024 22:59:04 -0700 Subject: [PATCH] system: Organize items into sections Closes: #2161. - Sections are ordered by importance on which administrator must act after setting up the system. - Consistent order across all the languages. - Update the styling for the section hearers. - For system section, make them compact. - Make them look like a header text (with underline) rather than a divider (like in a menu). Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/menu.py | 12 ++++++++++++ plinth/modules/avahi/__init__.py | 3 ++- plinth/modules/backups/__init__.py | 3 ++- plinth/modules/bind/__init__.py | 2 +- plinth/modules/cockpit/__init__.py | 4 +++- plinth/modules/config/__init__.py | 3 ++- plinth/modules/datetime/__init__.py | 3 ++- plinth/modules/diagnostics/__init__.py | 4 +++- plinth/modules/dynamicdns/__init__.py | 3 ++- plinth/modules/firewall/__init__.py | 3 ++- plinth/modules/letsencrypt/__init__.py | 3 ++- plinth/modules/names/__init__.py | 3 ++- plinth/modules/networks/__init__.py | 3 ++- plinth/modules/pagekite/__init__.py | 3 ++- plinth/modules/performance/__init__.py | 4 +++- plinth/modules/power/__init__.py | 4 +++- plinth/modules/privacy/__init__.py | 3 ++- plinth/modules/security/__init__.py | 3 ++- plinth/modules/snapshot/__init__.py | 3 ++- plinth/modules/ssh/__init__.py | 4 +++- plinth/modules/storage/__init__.py | 3 ++- plinth/modules/upgrades/__init__.py | 3 ++- plinth/modules/users/__init__.py | 3 ++- plinth/templates/cards.html | 2 +- plinth/templates/system.html | 26 ++++++++++++++++++++++++++ plinth/urls.py | 12 +++++++++++- static/themes/default/css/main.css | 18 +++++++----------- 27 files changed, 105 insertions(+), 35 deletions(-) diff --git a/plinth/menu.py b/plinth/menu.py index fb1a561fa..a1d50110d 100644 --- a/plinth/menu.py +++ b/plinth/menu.py @@ -3,6 +3,7 @@ from typing import ClassVar from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ from plinth import app @@ -101,3 +102,14 @@ def init(): parent_url_name='index') Menu('menu-system', icon='fa-cog', url_name='system', parent_url_name='index') + + Menu('menu-system-visibility', name=_('Visibility'), icon='fa-cog', + url_name='system:visibility', parent_url_name='system', order=10) + Menu('menu-system-data', name=_('Data'), icon='fa-cog', + url_name='system:data', parent_url_name='system', order=20) + Menu('menu-system-system', name=_('System'), icon='fa-cog', + url_name='system:system', parent_url_name='system', order=30) + Menu('menu-system-security', name=_('Security'), icon='fa-cog', + url_name='system:security', parent_url_name='system', order=40) + Menu('menu-system-administration', name=_('Administration'), icon='fa-cog', + url_name='system:administration', parent_url_name='system', order=50) diff --git a/plinth/modules/avahi/__init__.py b/plinth/modules/avahi/__init__.py index 33c33ea49..8226a0bd4 100644 --- a/plinth/modules/avahi/__init__.py +++ b/plinth/modules/avahi/__init__.py @@ -50,7 +50,8 @@ class AvahiApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-avahi', info.name, None, info.icon, - 'avahi:index', parent_url_name='system') + 'avahi:index', + parent_url_name='system:visibility', order=50) self.add(menu_item) packages = Packages('packages-avahi', ['avahi-daemon', 'avahi-utils']) diff --git a/plinth/modules/backups/__init__.py b/plinth/modules/backups/__init__.py index 1944ce64c..5a6c6db19 100644 --- a/plinth/modules/backups/__init__.py +++ b/plinth/modules/backups/__init__.py @@ -47,7 +47,8 @@ class BackupsApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-backups', info.name, None, info.icon, - 'backups:index', parent_url_name='system') + 'backups:index', parent_url_name='system:data', + order=20) self.add(menu_item) packages = Packages('packages-backups', ['borgbackup', 'sshfs']) diff --git a/plinth/modules/bind/__init__.py b/plinth/modules/bind/__init__.py index 37c52b6df..4f4971731 100644 --- a/plinth/modules/bind/__init__.py +++ b/plinth/modules/bind/__init__.py @@ -44,7 +44,7 @@ class BindApp(app_module.App): menu_item = menu.Menu('menu-bind', info.name, info.short_description, info.icon, 'bind:index', - parent_url_name='system') + parent_url_name='system:visibility', order=30) self.add(menu_item) packages = Packages('packages-bind', ['bind9']) diff --git a/plinth/modules/cockpit/__init__.py b/plinth/modules/cockpit/__init__.py index 7d39c4d55..571d17419 100644 --- a/plinth/modules/cockpit/__init__.py +++ b/plinth/modules/cockpit/__init__.py @@ -59,7 +59,9 @@ class CockpitApp(app_module.App): menu_item = menu.Menu('menu-cockpit', info.name, info.short_description, info.icon, - 'cockpit:index', parent_url_name='system') + 'cockpit:index', + parent_url_name='system:administration', + order=20) self.add(menu_item) shortcut = frontpage.Shortcut('shortcut-cockpit', info.name, diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index 8a79e4666..fb28c948f 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -47,7 +47,8 @@ class ConfigApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-config', _('Configure'), None, info.icon, - 'config:index', parent_url_name='system') + 'config:index', parent_url_name='system:system', + order=30) self.add(menu_item) packages = Packages('packages-config', ['zram-tools']) diff --git a/plinth/modules/datetime/__init__.py b/plinth/modules/datetime/__init__.py index 052349009..4bc35802c 100644 --- a/plinth/modules/datetime/__init__.py +++ b/plinth/modules/datetime/__init__.py @@ -71,7 +71,8 @@ class DateTimeApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-datetime', info.name, None, info.icon, - 'datetime:index', parent_url_name='system') + 'datetime:index', + parent_url_name='system:system', order=40) self.add(menu_item) packages = Packages('packages-datetime', ['systemd-timesyncd']) diff --git a/plinth/modules/diagnostics/__init__.py b/plinth/modules/diagnostics/__init__.py index 9e9a56bc0..ff771de82 100644 --- a/plinth/modules/diagnostics/__init__.py +++ b/plinth/modules/diagnostics/__init__.py @@ -55,7 +55,9 @@ class DiagnosticsApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-diagnostics', info.name, None, info.icon, - 'diagnostics:index', parent_url_name='system') + 'diagnostics:index', + parent_url_name='system:administration', + order=30) self.add(menu_item) backup_restore = BackupRestore('backup-restore-diagnostics', diff --git a/plinth/modules/dynamicdns/__init__.py b/plinth/modules/dynamicdns/__init__.py index c257e246b..e0e0ec231 100644 --- a/plinth/modules/dynamicdns/__init__.py +++ b/plinth/modules/dynamicdns/__init__.py @@ -64,7 +64,8 @@ class DynamicDNSApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-dynamicdns', info.name, None, info.icon, - 'dynamicdns:index', parent_url_name='system') + 'dynamicdns:index', + parent_url_name='system:visibility', order=20) self.add(menu_item) enable_state = app_module.EnableState('enable-state-dynamicdns') diff --git a/plinth/modules/firewall/__init__.py b/plinth/modules/firewall/__init__.py index 2eb1c87ac..72a1f627e 100644 --- a/plinth/modules/firewall/__init__.py +++ b/plinth/modules/firewall/__init__.py @@ -64,7 +64,8 @@ class FirewallApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-firewall', info.name, None, info.icon, - 'firewall:index', parent_url_name='system') + 'firewall:index', + parent_url_name='system:security', order=30) self.add(menu_item) packages = Packages('packages-firewall', ['firewalld', 'nftables']) diff --git a/plinth/modules/letsencrypt/__init__.py b/plinth/modules/letsencrypt/__init__.py index 823bd4045..a27a14c09 100644 --- a/plinth/modules/letsencrypt/__init__.py +++ b/plinth/modules/letsencrypt/__init__.py @@ -66,7 +66,8 @@ class LetsEncryptApp(app_module.App): menu_item = menu.Menu('menu-letsencrypt', info.name, info.short_description, info.icon, - 'letsencrypt:index', parent_url_name='system') + 'letsencrypt:index', + parent_url_name='system:security', order=20) self.add(menu_item) packages = Packages('packages-letsencrypt', ['certbot']) diff --git a/plinth/modules/names/__init__.py b/plinth/modules/names/__init__.py index e6cf29247..1beaf06cc 100644 --- a/plinth/modules/names/__init__.py +++ b/plinth/modules/names/__init__.py @@ -46,7 +46,8 @@ class NamesApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-names', info.name, None, info.icon, - 'names:index', parent_url_name='system') + 'names:index', + parent_url_name='system:visibility', order=10) self.add(menu_item) backup_restore = BackupRestore('backup-restore-names', diff --git a/plinth/modules/networks/__init__.py b/plinth/modules/networks/__init__.py index df9e168d2..54371feda 100644 --- a/plinth/modules/networks/__init__.py +++ b/plinth/modules/networks/__init__.py @@ -62,7 +62,8 @@ class NetworksApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-networks', info.name, None, info.icon, - 'networks:index', parent_url_name='system') + 'networks:index', + parent_url_name='system:system', order=20) self.add(menu_item) packages = Packages('packages-networks', ['network-manager', 'batctl']) diff --git a/plinth/modules/pagekite/__init__.py b/plinth/modules/pagekite/__init__.py index 29e6b313f..033fd8a73 100644 --- a/plinth/modules/pagekite/__init__.py +++ b/plinth/modules/pagekite/__init__.py @@ -64,7 +64,8 @@ class PagekiteApp(app_module.App): menu_item = menu.Menu('menu-pagekite', info.name, info.short_description, info.icon, - 'pagekite:index', parent_url_name='system') + 'pagekite:index', + parent_url_name='system:visibility', order=40) self.add(menu_item) packages = Packages('packages-pagekite', ['pagekite']) diff --git a/plinth/modules/performance/__init__.py b/plinth/modules/performance/__init__.py index 4b681e1ec..59d1498f5 100644 --- a/plinth/modules/performance/__init__.py +++ b/plinth/modules/performance/__init__.py @@ -46,7 +46,9 @@ class PerformanceApp(app_module.App): menu_item = menu.Menu('menu-performance', info.name, info.short_description, info.icon, - 'performance:index', parent_url_name='system') + 'performance:index', + parent_url_name='system:administration', + order=40) self.add(menu_item) packages = Packages('packages-performance', ['cockpit-pcp']) diff --git a/plinth/modules/power/__init__.py b/plinth/modules/power/__init__.py index f80a936bd..3720c0212 100644 --- a/plinth/modules/power/__init__.py +++ b/plinth/modules/power/__init__.py @@ -34,7 +34,9 @@ class PowerApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-power', info.name, None, info.icon, - 'power:index', parent_url_name='system') + 'power:index', + parent_url_name='system:administration', + order=50) self.add(menu_item) backup_restore = BackupRestore('backup-restore-power', diff --git a/plinth/modules/privacy/__init__.py b/plinth/modules/privacy/__init__.py index 56170c12e..89343f93a 100644 --- a/plinth/modules/privacy/__init__.py +++ b/plinth/modules/privacy/__init__.py @@ -36,7 +36,8 @@ class PrivacyApp(app_module.App): menu_item = menu.Menu('menu-privacy', info.name, info.short_description, info.icon, - 'privacy:index', parent_url_name='system') + 'privacy:index', parent_url_name='system:data', + order=10) self.add(menu_item) packages = Packages('packages-privacy', ['popularity-contest', 'gpg']) diff --git a/plinth/modules/security/__init__.py b/plinth/modules/security/__init__.py index a9effe9b9..01ca1e84a 100644 --- a/plinth/modules/security/__init__.py +++ b/plinth/modules/security/__init__.py @@ -37,7 +37,8 @@ class SecurityApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-security', info.name, None, info.icon, - 'security:index', parent_url_name='system') + 'security:index', + parent_url_name='system:security', order=10) self.add(menu_item) packages = Packages('packages-security', ['fail2ban', 'debsecan']) diff --git a/plinth/modules/snapshot/__init__.py b/plinth/modules/snapshot/__init__.py index 5e1c215e7..f4cf52846 100644 --- a/plinth/modules/snapshot/__init__.py +++ b/plinth/modules/snapshot/__init__.py @@ -53,7 +53,8 @@ class SnapshotApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-snapshot', info.name, None, info.icon, - 'snapshot:index', parent_url_name='system') + 'snapshot:index', parent_url_name='system:data', + order=40) self.add(menu_item) packages = Packages('packages-snapshot', ['snapper']) diff --git a/plinth/modules/ssh/__init__.py b/plinth/modules/ssh/__init__.py index d4a8438db..29cbba45a 100644 --- a/plinth/modules/ssh/__init__.py +++ b/plinth/modules/ssh/__init__.py @@ -45,7 +45,9 @@ class SSHApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-ssh', info.name, None, info.icon, - 'ssh:index', parent_url_name='system') + 'ssh:index', + parent_url_name='system:administration', + order=10) self.add(menu_item) packages = Packages('packages-ssh', ['openssh-server']) diff --git a/plinth/modules/storage/__init__.py b/plinth/modules/storage/__init__.py index 4f7034193..dff8d60b2 100644 --- a/plinth/modules/storage/__init__.py +++ b/plinth/modules/storage/__init__.py @@ -48,7 +48,8 @@ class StorageApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-storage', info.name, None, info.icon, - 'storage:index', parent_url_name='system') + 'storage:index', parent_url_name='system:data', + order=30) self.add(menu_item) packages = Packages('packages-storage', diff --git a/plinth/modules/upgrades/__init__.py b/plinth/modules/upgrades/__init__.py index 82279d3f1..14e7a49c7 100644 --- a/plinth/modules/upgrades/__init__.py +++ b/plinth/modules/upgrades/__init__.py @@ -68,7 +68,8 @@ class UpgradesApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-upgrades', info.name, None, info.icon, - 'upgrades:index', parent_url_name='system') + 'upgrades:index', + parent_url_name='system:system', order=50) self.add(menu_item) packages = Packages('packages-upgrades', diff --git a/plinth/modules/users/__init__.py b/plinth/modules/users/__init__.py index 61b398c6a..021dffa5e 100644 --- a/plinth/modules/users/__init__.py +++ b/plinth/modules/users/__init__.py @@ -62,7 +62,8 @@ class UsersApp(app_module.App): self.add(info) menu_item = menu.Menu('menu-users', info.name, None, info.icon, - 'users:index', parent_url_name='system') + 'users:index', parent_url_name='system:system', + order=10) self.add(menu_item) packages = Packages('packages-users', [ diff --git a/plinth/templates/cards.html b/plinth/templates/cards.html index da19bdc3a..f5ba47d82 100644 --- a/plinth/templates/cards.html +++ b/plinth/templates/cards.html @@ -31,7 +31,7 @@ {% if show_disabled %}
-
{% trans "Disabled" %}
+
{% trans "Disabled" %}
{% for item in submenu.sorted_items %} diff --git a/plinth/templates/system.html b/plinth/templates/system.html index 126688808..7bef3e372 100644 --- a/plinth/templates/system.html +++ b/plinth/templates/system.html @@ -7,3 +7,29 @@ {% load i18n %} {% block body_class %}system-page{% endblock %} + +{% block container %} +
+
+
+ {% include 'messages.html' %} +
+
+
+ +
+ {% for section_item in submenu.sorted_items %} +
{{ section_item.name }}
+
+
+ {% for item in section_item.sorted_items %} + {% if advanced_mode or not item.advanced %} + {% include "card.html" %} + {% endif %} + {% endfor %} +
+
+ {% endfor %} +
+ +{% endblock %} diff --git a/plinth/urls.py b/plinth/urls.py index 34c61068c..c53710caf 100644 --- a/plinth/urls.py +++ b/plinth/urls.py @@ -3,11 +3,20 @@ Django URLconf file containing all urls """ from captcha import views as cviews -from django.urls import re_path +from django.urls import include, re_path from stronghold.decorators import public from . import views +system_urlpatterns = [ + re_path(r'^sys/#visibility$', views.system_index, name='visibility'), + re_path(r'^sys/#data$', views.system_index, name='data'), + re_path(r'^sys/#system$', views.system_index, name='system'), + re_path(r'^sys/#security$', views.system_index, name='security'), + re_path(r'^sys/#administration$', views.system_index, + name='administration'), +] + urlpatterns = [ re_path(r'^$', views.index, name='index'), re_path(r'^language-selection/$', @@ -15,6 +24,7 @@ urlpatterns = [ name='language-selection'), re_path(r'^apps/$', views.AppsIndexView.as_view(), name='apps'), re_path(r'^sys/$', views.system_index, name='system'), + re_path(r'', include((system_urlpatterns, 'system'))), re_path(r'^uninstall/(?P[1-9a-z\-_]+)/$', views.UninstallView.as_view(), name='uninstall'), re_path(r'^rerun-setup/(?P[1-9a-z\-_]+)/$', views.rerun_setup_view, diff --git a/static/themes/default/css/main.css b/static/themes/default/css/main.css index 5f6b2a94d..63c650658 100644 --- a/static/themes/default/css/main.css +++ b/static/themes/default/css/main.css @@ -488,20 +488,16 @@ footer { justify-content: left; } -.card-section-title { +.card-section-title, .system-section-title { display: flex; font-weight: 800; font-size: 1.25rem; - padding: 0 2.875rem; - margin: 1.25rem 0; + margin-bottom: 1.25rem; + border-bottom: var(--neutral-dark-color) solid 2px; } -.card-section-title:before, .card-section-title:after { - color: white; - content: ''; - flex: 1; - border-bottom: var(--neutral-dark-color) solid 2px; - margin: auto 1.125rem; +.card-section-title { + margin-top: 1.25rem; } a.menu_link { @@ -605,7 +601,7 @@ a.menu_link_active { /* Button table - Tables with a list of actions as buttons on top */ .index-page .card-list:before, .apps-page .card-list:before, -.system-page .card-list:before { +.system-page .system-section-title:first-child:before { position: relative; width: 25rem; height: 25rem; @@ -627,7 +623,7 @@ a.menu_link_active { background-image: url('../img/apps-background.svg'); } -.system-page .card-list:before { +.system-page .system-section-title:first-child:before { background-image: url('../img/system-background.svg'); }