{% extends 'base.html' %}{% block content %}
<div class="toolbar"><div><h1>{{ t('users.management') }}</h1><p class="muted">{{ t('users.permissions_help') }}</p></div><div class="toolbar-actions"><a class="button button-secondary" href="/settings/ldap-search?show_all=1">{{ t('users.ldap_import') }}</a><a class="button button-secondary" href="/settings/authentication">{{ t('users.login_settings') }}</a></div></div>
<section class="panel"><h2>{{ t('users.create_local') }}</h2><form method="post" action="/users/new" class="compact-form"><div class="form-grid"><label>{{ t('profile.username') }}<input name="username" required></label><label>{{ t('profile.display_name') }}<input name="display_name"></label><label>{{ t('profile.email') }}<input type="email" name="email"></label><label>{{ t('login.password') }}<input type="password" name="password" minlength="8" required></label></div><label class="checkbox-label"><input class="checkbox" type="checkbox" name="is_admin"> {{ t('users.administrator') }}</label><button type="submit">➕ {{ t('users.new') }}</button></form></section>
<div class="sticky-table management-table-scroll"><table class="data-table"><thead><tr><th>{{ t('users.user') }}</th><th>{{ t('profile.source') }}</th><th>{{ t('profile.last_login') }}</th><th>{{ t('users.permissions_groups') }}</th></tr></thead><tbody>
{% for user in users %}<tr><td><strong>{{ user.username }}</strong>{% if user.is_protected %}<br><span class="software-settings-badge">🔐 {{ t('users.protected_local_admin') }}</span>{% endif %}<br><span class="muted">{{ user.display_name or '' }}{% if user.email %} · {{ user.email }}{% endif %}</span>{% if user.is_protected %}<br><span class="muted">{{ t('users.protected_local_admin_help') }}</span>{% endif %}</td><td>{{ user.auth_source }}</td><td>{% if user.last_login %}<time class="local-time" datetime="{{ utc_iso(user.last_login) }}" data-utc="{{ utc_iso(user.last_login) }}">{{ user.last_login }}</time>{% else %}{{ '' }}{% endif %}</td><td><form method="post" action="/users/{{ user.id }}/update" class="user-permission-form"><div class="form-grid"><label>{{ t('profile.display_name') }}<input name="display_name" value="{{ user.display_name or '' }}"></label><label>{{ t('profile.email') }}<input type="email" name="email" value="{{ user.email or '' }}"></label><label>{{ t('users.profile_department') }}<input name="profile_department" value="{{ user.profile_department or '' }}" placeholder="{{ t('users.profile_department_placeholder') }}"></label><label>{{ t('users.profile_location') }}<input name="profile_location" value="{{ user.profile_location or '' }}" placeholder="{{ t('users.profile_location_placeholder') }}"></label>{% if user.auth_source == 'local' %}<label>{{ t('profile.new_password') }}<input type="password" name="new_password"></label>{% endif %}</div><div class="checkbox-row"><label class="checkbox-label"><input class="checkbox" type="checkbox" name="is_active" {% if user.is_active %}checked{% endif %} {% if user.is_protected %}disabled{% endif %}> {{ t('common.active') }}</label><label class="checkbox-label"><input class="checkbox" type="checkbox" name="is_admin" {% if user.is_admin %}checked{% endif %} {% if user.is_protected %}disabled{% endif %}> {{ t('users.administrator') }}</label></div><fieldset><legend>{{ t('users.asset_visibility') }}</legend><p class="muted">{{ t('users.asset_visibility_help') }}</p><div class="group-checkboxes"><label class="checkbox-label"><input class="checkbox" type="checkbox" name="asset_access_scopes" value="self" {% if 'self' in (user.asset_access_scopes or []) %}checked{% endif %}> {{ t('users.scope_self') }}</label><label class="checkbox-label"><input class="checkbox" type="checkbox" name="asset_access_scopes" value="department" {% if 'department' in (user.asset_access_scopes or []) %}checked{% endif %}> {{ t('users.scope_department') }}</label><label class="checkbox-label"><input class="checkbox" type="checkbox" name="asset_access_scopes" value="location" {% if 'location' in (user.asset_access_scopes or []) %}checked{% endif %}> {{ t('users.scope_location') }}</label><label class="checkbox-label"><input class="checkbox" type="checkbox" name="asset_access_scopes" value="all" {% if 'all' in (user.asset_access_scopes or []) %}checked{% endif %}> {{ t('users.scope_all') }}</label></div><p class="muted">{{ t('users.scope_or_hint') }}</p></fieldset><fieldset><legend>{{ t('users.visible_mesh_groups') }}</legend><div class="group-checkboxes">{% for group in mesh_groups %}<label class="checkbox-label"><input class="checkbox" type="checkbox" name="mesh_groups" value="{{ group }}" {% if group in (user.allowed_mesh_groups or []) %}checked{% endif %}> {{ group }}</label>{% else %}<span class="muted">{{ t('users.no_mesh_groups') }}</span>{% endfor %}</div></fieldset><button type="submit">💾 {{ t('users.save') }}</button></form>{% if not user.is_protected %}<form method="post" action="/users/{{ user.id }}/delete" class="user-delete-form" onsubmit="return confirm({{ t('users.delete_confirm', username=user.username)|tojson }});"><button type="submit" class="button button-danger">🗑 {{ t('users.delete') }}</button></form>{% endif %}</td></tr>{% else %}<tr><td colspan="4">{{ t('users.none') }}</td></tr>{% endfor %}
</tbody></table></div>
<p class="muted">{{ t('users.relogin_hint') }}</p>
{% endblock %}
