set master pwd al primo lancio - ruoli

This commit is contained in:
2025-02-02 16:35:34 +01:00
parent e3ae8300f1
commit 2d172a3620
16 changed files with 174 additions and 168 deletions

View File

@@ -7,7 +7,7 @@
{% block content %}
<h1 class="mb-4">{% trans "Sign In" %}</h1>
<p class="mb-4">
If you have not created an account yet, then please
{% trans "If you have not created an account yet, then please" %}
<a
href="{% url 'account_signup' %}?next={% url 'profile-onboarding' %}"
class="text-decoration-none"

View File

@@ -1,7 +1,7 @@
{% load static %}
{% load django_htmx %}
<!DOCTYPE html>
<html lang="en">
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -23,10 +23,11 @@
</style>
</head>
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
{% include 'includes/messages.html' %}
{% include 'includes/header.html' %}
{% include 'includes/messages.html' %}
{% block layout %}
{% endblock %}

View File

@@ -1,8 +1,8 @@
{% load static %}
<header class="d-flex align-items-center justify-content-between bg-dark text-white py-3 px-4 sticky-top z-40">
<header class="d-flex align-items-center justify-content-between bg-secondary text-white py-1 px-4 sticky-top z-40">
<div>
<a class="d-flex align-items-center gap-2 text-decoration-none text-white" href="/">
<img class="h-6" src="{% static 'images/ase-logo.png' %}" alt="ASE" height="40"/>
<img class="h-6" src="{% static 'images/ase-logo.png' %}" alt="ASE" height="30"/>
<span class="text-lg fw-bold">MQTT User Management</span>
</a>
</div>
@@ -14,13 +14,17 @@
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle d-flex align-items-center gap-2 text-white" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<img class="h-8 w-8 rounded-circle object-cover" src="{{ request.user.profile.avatar }}" alt="Avatar" height="40"/>
<img class="h-8 w-8 rounded-circle object-cover" src="{{ request.user.profile.avatar }}" alt="Avatar" height="30"/>
{{ request.user.profile.name }}
</a>
<ul class="dropdown-menu dropdown-menu-end shadow-lg" style="min-width: 200px;">
<li><a class="dropdown-item" href="{% url 'profile' %}">My Profile</a></li>
<li><a class="dropdown-item" href="{% url 'profile-edit' %}">Edit Profile</a></li>
<li><a class="dropdown-item" href="{% url 'profile-settings' %}">Settings</a></li>
{% if request.user.is_superuser %}
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="{% url 'admin:index' %}">Site Admin</a></li>
{% endif %}
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="{% url 'account_logout' %}">Log Out</a></li>
</ul>

View File

@@ -3,7 +3,7 @@
<div>
{% for message in messages %}
<div
class="position-fixed top-0 start-50 translate-middle-x mt-3 z-50"
class="position-fixed top-10 start-50 translate-middle-x mt-3 z-30"
style="width: 100%; max-width: 576px"
>
<div

View File

@@ -1,5 +1,5 @@
{% extends 'base.html' %} {% block layout %}
<div class="container">
<div class="container" style="margin-top: 20px;">
<div class="row justify-content-center">
<div class="col-12 col-md-8 col-lg-6">
<div class="bg-white rounded-3 p-4 p-md-5 shadow-lg">

View File

@@ -1,18 +1,5 @@
{% extends 'layouts/blank.html' %} {% block content %}
<!-- Mostra i messaggi di errore o successo -->
{% if messages %}
<div>
{% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
<!-- Form per la creazione dell'utente -->
<h1>Add User</h1>
<form method="post" hx-post="/create_user" hx-target="#content">
{% csrf_token %}

View File

@@ -1,16 +1,5 @@
{% extends 'layouts/blank.html' %} {% block content %}
<!-- Mostra i messaggi di errore o successo -->
{% if messages %}
<div>
{% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
<h1>Add User</h1>
<form method="post">
{% csrf_token %}

View File

@@ -1,20 +1,12 @@
{% extends 'layouts/blank.html' %} {% block content %}
<!-- Mostra i messaggi di errore o successo -->
{% if messages %}
<div>
{% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
<h1>List Mosquitto Users</h1>
<a href="{% url 'create_user' %}">
<button class="btn btn-primary mb-3">Add User</button>
</a>
{% if ase_adm_group %}
<a href="{% url 'create_user' %}">
<button class="btn btn-primary mb-3">Add User</button>
</a>
{% endif %}
<table class="table table-striped">
<thead>
<tr>
@@ -29,20 +21,35 @@
{% for user in users %}
<tr>
<td>{{user.site}}</td>
<td>
<a href="{% url 'edit_user' user.slug %}">{{user.username}}</a
>
<td>{% if ase_adm_group %}
<a href="{% url 'edit_user' user.slug %}">
{% endif %}
{{user.username}}</a>
</td>
<td>{{user.client_id}}</td>
<td>{{user.topic}}</td>
<td id="user-status">
{% if user.status == "enabled" %}
<a href="{% url 'disable_user' user.slug %}">
<button class="btn btn-danger btn-sm">Disable</button>
<a
{% if ase_adm_group %}
href="{% url 'disable_user' user.slug %}"
{% endif %}>
<button class="btn btn-danger btn-sm"
{% if not ase_adm_group %}
disabled
{% endif %}
>Disable</button>
</a>
{% else %}
<a href="{% url 'enable_user' user.slug %}">
<button class="btn btn-warning btn-sm">Enable</button>
<a
{% if ase_adm_group %}
href="{% url 'enable_user' user.slug %}"
{% endif %}>
<button class="btn btn-warning btn-sm"
{% if not ase_adm_group %}
disabled
{% endif %}
>Enable</button>
</a>
{% endif %}
</td>