mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-10-31 22:24:30 +01:00 
			
		
		
		
	Add specific login and logout pages for chat
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		| @@ -190,7 +190,7 @@ function redrawMessages() { | ||||
|     } | ||||
|  | ||||
|     let fetchMoreButton = document.getElementById('fetch-previous-messages') | ||||
|     if (!messages[selected_channel_id] || messages[selected_channel_id].size % MAX_MESSAGES !== 0) | ||||
|     if (!messages[selected_channel_id].size || messages[selected_channel_id].size % MAX_MESSAGES !== 0) | ||||
|         fetchMoreButton.classList.add('d-none') | ||||
|     else | ||||
|         fetchMoreButton.classList.remove('d-none') | ||||
|   | ||||
| @@ -21,6 +21,11 @@ | ||||
|      style="height: 95vh" id="chat-container"> | ||||
|     <div class="card-header"> | ||||
|         <h3> | ||||
|         {% if fullscreen %} | ||||
|             {# Logout button must be present in a form. The form must includes the whole line. #} | ||||
|             <form action="{% url 'chat:logout' %}" method="post"> | ||||
|                 {% csrf_token %} | ||||
|         {% endif %} | ||||
|             <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#channelSelector" | ||||
|                     aria-controls="channelSelector" aria-expanded="false" aria-label="Toggle channel selector"> | ||||
|                 <span class="navbar-toggler-icon"></span> | ||||
| @@ -30,10 +35,17 @@ | ||||
|                 <button class="btn float-end" type="button" onclick="toggleFullscreen()" title="{% trans "Toggle fullscreen mode" %}"> | ||||
|                     <i class="fas fa-expand"></i> | ||||
|                 </button> | ||||
|             {% else %} | ||||
|                 <button class="btn float-end" title="{% trans "Log out" %}"> | ||||
|                     <i class="fas fa-sign-out-alt"></i> | ||||
|                 </button> | ||||
|             {% endif %} | ||||
|             <button class="btn float-end d-none" type="button" id="install-app-home-screen" title="{% trans "Install app on home screen" %}"> | ||||
|                 <i class="fas fa-download"></i> | ||||
|             </button> | ||||
|             {% if fullscreen %} | ||||
|                 </form> | ||||
|             {% endif %} | ||||
|         </h3> | ||||
|     </div> | ||||
|     <div class="card-body d-flex flex-column-reverse flex-grow-0 overflow-y-scroll" id="chat-messages"> | ||||
|   | ||||
							
								
								
									
										36
									
								
								chat/templates/chat/login.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								chat/templates/chat/login.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| {% load i18n static %} | ||||
|  | ||||
| <!DOCTYPE html> | ||||
| {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} | ||||
| <html lang="{{ LANGUAGE_CODE|default:"fr" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> | ||||
| <head> | ||||
|     <meta charset="utf-8"> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||||
|     <title> | ||||
|         Chat du TFJM² - {% trans "Log in" %} | ||||
|     </title> | ||||
|     <meta name="description" content="Chat du TFJM²"> | ||||
|  | ||||
|     {# Favicon #} | ||||
|     <link rel="shortcut icon" href="{% static "favicon.ico" %}"> | ||||
|     <meta name="theme-color" content="#ffffff"> | ||||
|  | ||||
|     {# Bootstrap CSS #} | ||||
|     <link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}"> | ||||
|     <link rel="stylesheet" href="{% static 'fontawesome/css/all.css' %}"> | ||||
|     <link rel="stylesheet" href="{% static 'fontawesome/css/v4-shims.css' %}"> | ||||
|  | ||||
|     {# Bootstrap JavaScript #} | ||||
|     <script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script> | ||||
|  | ||||
|     <link rel="manifest" href="{% static "chat.webmanifest" %}"> | ||||
| </head> | ||||
| <body class="d-flex w-100 h-100 flex-column"> | ||||
|     <div class="container"> | ||||
|         <h1>{% trans "Log in" %}</h1> | ||||
|         {% include "registration/includes/login.html" %} | ||||
|     </div> | ||||
|  | ||||
| <script src="{% static 'theme.js' %}"></script> | ||||
| </body> | ||||
| </html> | ||||
| @@ -1,6 +1,7 @@ | ||||
| # Copyright (C) 2024 by Animath | ||||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||||
|  | ||||
| from django.contrib.auth.views import LoginView, LogoutView | ||||
| from django.urls import path | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
| from tfjm.views import LoginRequiredTemplateView | ||||
| @@ -10,5 +11,8 @@ app_name = 'chat' | ||||
| urlpatterns = [ | ||||
|     path('', LoginRequiredTemplateView.as_view(template_name="chat/chat.html", | ||||
|                                                extra_context={'title': _("Chat")}), name='chat'), | ||||
|     path('fullscreen/', LoginRequiredTemplateView.as_view(template_name="chat/fullscreen.html"), name='fullscreen'), | ||||
|     path('fullscreen/', LoginRequiredTemplateView.as_view(template_name="chat/fullscreen.html", login_url='chat:login'), | ||||
|          name='fullscreen'), | ||||
|     path('login/', LoginView.as_view(template_name="chat/login.html"), name='login'), | ||||
|     path('logout/', LogoutView.as_view(next_page='chat:fullscreen'), name='logout'), | ||||
| ] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user