feat(usermanager): show summary on index view

This commit is contained in:
Julian Lobbes 2022-12-01 00:50:44 +01:00
parent b96cbbde25
commit 1cda01eb1f
3 changed files with 32 additions and 6 deletions

View File

@ -38,12 +38,17 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% if g.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('usermanager.user_list') }}">Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('usermanager.group_list') }}">Groups</a>
</li>
{% endif%}
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
{% if g.is_authenticated %}
<div class="d-flex"">

View File

@ -1,15 +1,21 @@
{% extends 'base.html' %}
{% block content %}
<h1 class="text-center">Welcome to LUMI 2</h1>
<h1 class="text-center">Welcome</h1>
<div class="row justify-content-md-center">
<img src="{{ url_for('static', filename='images/base/toolbox.svg') }}"
alt="Picture of a toolbox."
<img src="{{ url_for('static', filename='images/base/navbar-logo.svg') }}"
alt="Logo for lumi2"
class="img-fluid rounded"
style="max-width: 400px"
>
</div>
<div class="row justify-content-md-center text-center">
<p class="fs-3 text-secondary"><i class="bi-cone-striped"></i> This site is still under construction.</p>
<div class="row justify-content-md-centermt-4">
<p class="fs-3 text-secondary text-center "><i class="bi-cone-striped"></i> This site is still under construction <i class="bi-cone-striped"></i></p>
<p class="fs-3">With Lumi2 you can easily manage the users and user-groups on your LDAP server.</p>
{% if g.is_authenticated %}
<p class="fs-3">There are currently {{ user_count }} <a href="{{ url_for('usermanager.user_list') }}">users</a> and {{ group_count }} <a href="{{ url_for('usermanager.group_list') }}">groups</a>.</p>
{% else %}
<p class="fs-3">You are currently not logged in. Please <a href="{{ url_for('auth.login') }}">log in</a> to continue.</p>
{% endif %}
</div>
{% endblock content %}

View File

@ -6,7 +6,7 @@ from tempfile import TemporaryFile
from json import loads, dumps, JSONDecodeError
from flask import (
Blueprint, render_template, abort, request, flash, redirect, url_for, current_app
Blueprint, render_template, abort, request, flash, redirect, url_for, current_app, g
)
from PIL import Image, UnidentifiedImageError
from flask_wtf import FlaskForm
@ -56,6 +56,21 @@ def _initialize_ldap_dit():
def index():
"""Home page view."""
if g.is_authenticated:
try:
conn = ldap.get_connection()
except Exception:
abort(500)
user_count = len(ldap.get_users(conn))
group_count = len(ldap.get_groups(conn))
conn.unbind()
return render_template(
'usermanager/index.html',
user_count=user_count,
group_count=group_count
)
return render_template('usermanager/index.html')