aboutsummaryrefslogtreecommitdiffstats
path: root/templates/registration
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-03-23 19:10:35 +0100
committerAndrea Lepori <alepori@student.ethz.ch>2022-03-23 19:10:47 +0100
commit7926fee19b2241e2f3facef8b6eb8789f5d97d49 (patch)
tree0ddc4a687feb0ec0e8e81003248905f26ca1c3cc /templates/registration
parentadd option to disable oauth (diff)
downloadscout-subs-7926fee19b2241e2f3facef8b6eb8789f5d97d49.tar.gz
scout-subs-7926fee19b2241e2f3facef8b6eb8789f5d97d49.zip
initial support of user switcher
Diffstat (limited to '')
-rw-r--r--templates/registration/base_client.html34
1 files changed, 30 insertions, 4 deletions
diff --git a/templates/registration/base_client.html b/templates/registration/base_client.html
index 362238c..8543852 100644
--- a/templates/registration/base_client.html
+++ b/templates/registration/base_client.html
@@ -5,6 +5,7 @@
<html>
<head>
{% load static %}
+ {% load app_filter %}
<link rel="stylesheet" type="text/css" href="{% static 'material_icons.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'materialize.min.css' %}">
<style>
@@ -94,6 +95,9 @@
</head>
<body>
<nav class="nav-extended">
+ <form id="user_form" method="post" action="{% url 'user_switcher'%}">
+ {% csrf_token %}
+ <input type="hidden" name="metadata" id="metadata">
<div class="nav-wrapper {{color}}">
<a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb hide-on-small-only">Home</a>
<ul class="left hide-on-med-and-up">
@@ -108,20 +112,31 @@
{% if user.is_staff or perms.client.staff %}
<li class="hide-on-small-only"><a href="{% url 'server' %}">Pannello Admin</a></li>
{% endif %}
- <li class="hide-on-small-only tooltipped" data-position="bottom" data-tooltip="Dati personali"><a href="{% url 'personal' %}">{{ user.username }}</a></li>
- <li class="hide-on-med-and-up tooltipped" data-position="bottom" data-tooltip="Dati personali"><a href="{% url 'personal' %}"><i class="material-icons">person</i></a></li>
{% if user.is_staff or perms.client.staff %}
<li class="tooltipped hide-on-med-and-up" data-position="bottom" data-tooltip="Pannello Admin" class="hide-on-med-and-up"><a href="{% url 'server' %}"><i class="material-icons">build</i></a></li>
{% endif %}
{% if group_view %}
<li class="tooltipped hide-on-med-and-up" data-position="bottom" data-tooltip="Lista documenti" class="hide-on-med-and-up"><a class="modal-trigger" href="#modal_capi"><i class="material-icons">list</i></a></li>
{% endif %}
- <li class="tooltipped" data-position="bottom" data-tooltip="Informazioni"><a href="{% url 'about' %}"><i class="material-icons">info_outline</i></a></li>
- <li class="tooltipped" data-position="bottom" data-tooltip="Logout"><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li>
+ <li class="userswitcher" data-target='userswitcher'><a href="#">{{ user.username }}</a></li>
+ <ul id='userswitcher' class='dropdown-content'>
+ <li><a href="{% url 'personal' %}"><i class="material-icons">person</i>Gestione account</a></li>
+ <li><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i>Logout</a></li>
+ <li class="divider" tabindex="-1"></li>
+ {% for username in request.COOKIES.user_switcher|parse_userswitcher%}
+ {% if username != user.username %}
+ <li><a onclick="switcher_submit('s{{username}}')">{{username}}</a></li>
+ {% endif %}
+ {% endfor %}
+ <li><a onclick="switcher_submit('new')"><i class="material-icons">person_add</i>Aggiungi un altro utente</a></li>
+ <li class="divider" tabindex="-1"></li>
+ <li><a href="{% url 'about' %}">Informazioni sul prodotto</a></li>
+ </ul>
</ul>
</div>
{% block toolbar %}
{% endblock %}
+ </form>
</nav>
<main id="main" style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
@@ -135,6 +150,17 @@
$(document).ready(function(){
$('.tooltipped').tooltip();
});
+
+ document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.userswitcher');
+ var instances = M.Dropdown.init(elems, {"coverTrigger": false, "constrainWidth": false});
+ });
+ function switcher_submit(id) {
+ var form = document.getElementById('user_form')
+ var action = document.getElementById('metadata')
+ action.setAttribute('value', id);
+ form.submit()
+ }
{% block script %}
{% endblock%}
</script>