apeters 519dbc73c6 Cat.
Signed-off-by: apeters <apeters@korves.net>
2025-06-03 11:40:56 +00:00

90 lines
2.9 KiB
HTML

<form
hx-trigger="submit throttle:200ms"
hx-patch="/system/users/{{ user.id }}">
<article>
<h6>General</h6>
<fieldset>
<label>Login</label>
<input name="login"
type="text"
value="{{ user.login }}"
required
hx-on:change="document.getElementById('login-{{ user.id }}').textContent=this.value">
</fieldset>
</article>
<article>
<fieldset>
<h6>ACL</h6>
{% for acl in USER_ACLS %}
<input
role="switch"
id="acl-{{- acl -}}-{{ user.id }}"
{% if session["id"] == user.id %}
hx-on:click="!this.checked?(confirm('You are logged in as this user. Removing access may result in a broken session.')?null:event.preventDefault()):null"
{% endif %}
name="acl"
value="{{ acl }}"
type="checkbox" {{ "checked" if acl in user.acl }}>
<label for="acl-{{- acl -}}-{{ user.id }}">{{ acl|capitalize }}</label>
{% endfor %}
</fieldset>
</article>
<article>
<h6>Credentials</h6>
{% if not user.credentials %}
<i>No credentials available</i>
{% endif %}
{% for credential in user.credentials|sort(attribute='friendly_name', reverse=false) %}
<section>
<fieldset>
<span _="install inlineHtmxRename()"
contenteditable
data-patch-parameter="friendly_name"
spellcheck="false"
hx-patch="/system/users/{{ user.id }}/credential/{{ credential.id|hex }}"
hx-trigger="editContent">
{{- credential.friendly_name or 'John Doe' -}}
</span>
<a href="#" hx-disinherit="*" class="{{ "color-red" if not credential.active else "color-green"}}"
hx-patch="/system/users/{{ user.id }}/credential/{{ credential.id|hex }}"
hx-vals='js:{"active": {{ "true" if not credential.active else "false"}}}'
hx-params="active">
{{ "[disabled]" if not credential.active else "[enabled]"}}
</a>
<a href="#" hx-disinherit="*" class="color-red"
hx-confirm="Delete passkey?"
_="install confirmButton"
hx-trigger="confirmedButton throttle:200ms"
hx-delete="/system/users/{{ user.id }}/credential/{{ credential.id|hex }}">
[remove]
</a>
<br>
<small>Last Login:
{% if credential.last_login %}
<span class="" value="{{ credential.last_login }}" _="init set dt to my @value js(dt) return new Date(dt).toLocaleString() end then put result into me"></span>
{% else %}-
{% endif %}
</small>
</fieldset>
</section>
{% endfor %}
</article>
<article>
<h6>Profile data</h6>
{% with
schema=schemas.user_profile,
current_data=user.profile,
root_key="profile"
%}
{% include "includes/form_builder.html" %}
{% endwith %}
</article>
<button data-loading-disable type="submit">Update</button>
</form>