From 874f8d77ab0bc4703378a4aac166eb334ee8c880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 30 Sep 2018 19:26:30 +0200 Subject: [PATCH] turn home page into a list of services + status (#26761) --- hobo/static/css/style.css | 59 ++++++++++++++++++++++++ hobo/templates/hobo/home.html | 84 +++++++++++++++++++++++++++++++---- hobo/views.py | 8 +++- 3 files changed, 142 insertions(+), 9 deletions(-) diff --git a/hobo/static/css/style.css b/hobo/static/css/style.css index 1bbc5d9..fb4c628 100644 --- a/hobo/static/css/style.css +++ b/hobo/static/css/style.css @@ -154,3 +154,62 @@ div.objects-list > div > label > input[type=radio] { div.buttons { margin: 1em 0; } + +div#services > div { + box-sizing: border-box; + background: white; + border: 1px solid #ccc; + border-width: 1px 1px 1px 10px; + margin-bottom: 1rem; + width: 49%; + padding: 0 1ex; +} + +div#services > div h3 { + margin-top: 0.5rem; +} + +div#services > div h3 a { + font-size: 80%; + font-weight: normal; +} + +div#services > div:nth-child(2n+1) { + float: left; +} + +div#services > div:nth-child(2n) { + float: right; +} + +div#services > div.op-ok { + border-color: #00b000; +} + +div#services > div.op-nok { + border-color: #b00000; +} + +div#services p { + margin-bottom: 0.5rem; +} + +div#services span.op-ok::before { + font-family: FontAwesome; + content: "\f058"; /* check-circle */ + display: inline-block; + width: 1.5rem; + color: #00b000; +} + +div#services span.op-nok::before { + font-family: FontAwesome; + content: "\f057"; /* times-circle */ + display: inline-block; + width: 1.5rem; + color: #b00000; +} + +div#services span { + margin-right: 1rem; +} diff --git a/hobo/templates/hobo/home.html b/hobo/templates/hobo/home.html index 49fd2c2..8a9b5d3 100644 --- a/hobo/templates/hobo/home.html +++ b/hobo/templates/hobo/home.html @@ -2,17 +2,85 @@ {% load i18n %} {% block appbar %} -

{% trans 'Welcome' %}

+

{% trans 'System' %}

+ + + + {% endblock %} {% block content %} - +{% if services %} +
+{% for service in services %} +
+

{{ service.title }} {{ service.base_url }}

+

+ {% trans "checking..." %} + + + +

+
+{% endfor %} +
+{% else %} +
+ {% blocktrans %} + This deployment doesn't have any service deployed yet. Click on the + "Services" menu entry in the top right of the page to add a first one. + {% endblocktrans %} +
+{% endif %} + + {% endblock %} diff --git a/hobo/views.py b/hobo/views.py index e293165..882a263 100644 --- a/hobo/views.py +++ b/hobo/views.py @@ -15,7 +15,7 @@ from django.shortcuts import resolve_url from django.utils.encoding import force_text from .environment.models import Authentic -from .environment.utils import Zone, get_operational_services +from .environment.utils import Zone, get_installed_services from .forms import HoboForm, HoboUpdateForm, get_tenant_model def is_superuser(u): @@ -30,6 +30,12 @@ admin_required = user_passes_test(is_superuser) class Home(TemplateView): template_name = 'hobo/home.html' + def get_context_data(self, **kwargs): + context = super(Home, self).get_context_data(**kwargs) + context['services'] = [x for x in get_installed_services() if not x.secondary] + context['services'] = [] + return context + home = admin_required(Home.as_view()) class ManagerHome(edit.CreateView): -- 2.19.1