nopaque/app/templates/users/edit_profile.html.j2

155 lines
5.7 KiB
Plaintext
Raw Normal View History

2022-11-30 13:36:42 +00:00
{% extends "base.html.j2" %}
{% import "materialize/wtf.html.j2" as wtf %}
{% block page_content %}
<div class="container">
<div class="row">
<div class="col s12">
2022-12-05 08:40:02 +00:00
<h1 id="title">{{ title }}</h1>
</div>
2022-11-30 13:36:42 +00:00
<div class="col s12">
2022-12-13 14:01:04 +00:00
2022-12-05 08:40:02 +00:00
<div class="card">
<form method="POST" enctype="multipart/form-data">
2022-11-30 13:36:42 +00:00
<div class="card-content">
2022-12-13 14:01:04 +00:00
<div class="row">
<div class="col s6">
{{ edit_profile_settings_form.hidden_tag() }}
{{ wtf.render_field(edit_profile_settings_form.username, material_icon='person') }}
{{ wtf.render_field(edit_profile_settings_form.email, material_icon='email') }}
</div>
</div>
</div>
<div class="card-action">
<div class="right-align">
{{ wtf.render_field(edit_profile_settings_form.submit, material_icon='send') }}
</div>
</div>
</form>
</div>
<form method="POST">
{{ edit_privacy_settings_form.hidden_tag() }}
<div class="card">
<div class="card-content">
<span class="card-title">Privacy settings</span>
<br>
{{ wtf.render_field(edit_privacy_settings_form.is_public, id='public-profile') }}
<br>
<hr>
<br>
{{ wtf.render_field(edit_privacy_settings_form.show_email, data_action='disable', disabled=true) }}
<br>
{{ wtf.render_field(edit_privacy_settings_form.show_last_seen, data_action='disable', disabled=true) }}
<br>
{{ wtf.render_field(edit_privacy_settings_form.show_member_since, data_action='disable', disabled=true) }}
<br>
</div>
<div class="card-action">
<div class="right-align">
{{ wtf.render_field(edit_privacy_settings_form.submit, material_icon='send') }}
</div>
</div>
</div>
</form>
<div class="card">
<form method="POST" enctype="multipart/form-data">
<div class="card-content">
{{ edit_public_profile_information_form.hidden_tag() }}
<div class="row">
<div class="col s12">
<span class="card-title">Public Profile</span>
</div>
</div>
2022-11-30 13:36:42 +00:00
<div class="row">
2022-12-05 15:25:54 +00:00
<div class="col s5">
<div class="row">
2022-12-13 14:01:04 +00:00
<div class="col s2"></div>
<div class="col s8">
2022-12-19 14:35:06 +00:00
{% if user.avatar %}
<img src="{{ url_for('.profile_avatar', user_id=user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
2022-12-05 15:25:54 +00:00
{% else %}
2022-12-19 15:25:10 +00:00
<img src="{{ url_for('static', filename='images/user_avatar.png') }}" alt="user-image" class="circle responsive-img" id="avatar">
2022-12-05 15:25:54 +00:00
{% endif %}
</div>
2022-12-13 14:01:04 +00:00
<div class="col s2"></div>
2022-12-05 15:25:54 +00:00
</div>
<div class="row">
2022-12-13 14:01:04 +00:00
<div class="col s2">
<div class="center-align">
2022-12-19 15:25:10 +00:00
<a class="action-button btn-floating red waves-effect waves-light" style="margin-top:15px;" id="delete-avatar"><i class="material-icons">delete</i></a>
2022-12-13 14:01:04 +00:00
</div>
</div>
<div class="col s10">
{{ wtf.render_field(edit_public_profile_information_form.avatar, accept='image/jpeg, image/png, image/gif', placeholder='Choose an image file', id='avatar-upload') }}
2022-12-05 15:25:54 +00:00
</div>
</div>
2022-11-30 13:36:42 +00:00
</div>
<div class="col s7">
2022-12-13 14:01:04 +00:00
<p></p>
<br>
{{ wtf.render_field(edit_public_profile_information_form.full_name, material_icon='badge') }}
{{ wtf.render_field(edit_public_profile_information_form.about_me, material_icon='description') }}
{{ wtf.render_field(edit_public_profile_information_form.website, material_icon='laptop') }}
{{ wtf.render_field(edit_public_profile_information_form.organization, material_icon='business') }}
{{ wtf.render_field(edit_public_profile_information_form.location, material_icon='location_on') }}
2022-11-30 13:36:42 +00:00
</div>
</div>
</div>
<div class="card-action">
<div class="right-align">
2022-12-13 14:01:04 +00:00
{{ wtf.render_field(edit_public_profile_information_form.submit, material_icon='send') }}
2022-11-30 13:36:42 +00:00
</div>
</div>
2022-12-05 08:40:02 +00:00
</form>
</div>
2022-12-13 14:01:04 +00:00
2022-11-30 13:36:42 +00:00
</div>
</div>
</div>
{% endblock page_content %}
2022-12-13 14:01:04 +00:00
{% block scripts %}
{{ super() }}
<script>
let publicProfile = document.querySelector('#public-profile');
let disableButtons = document.querySelectorAll('[data-action="disable"]');
2022-12-19 15:25:10 +00:00
let deleteButton = document.querySelector('#delete-avatar');
2022-12-13 14:01:04 +00:00
let avatar = document.querySelector('#avatar');
let avatarUpload = document.querySelector('#avatar-upload');
2022-12-19 15:25:10 +00:00
for (let disableButton of disableButtons) {
disableButton.disabled = !publicProfile.checked;
2022-12-13 14:01:04 +00:00
}
2022-12-19 15:25:10 +00:00
publicProfile.addEventListener('change', () => {
2022-12-13 14:01:04 +00:00
if (publicProfile.checked) {
2022-12-19 15:25:10 +00:00
for (let disableButton of disableButtons) {
disableButton.disabled = false;
2022-12-13 14:01:04 +00:00
}
} else {
2022-12-19 15:25:10 +00:00
for (let disableButton of disableButtons) {
disableButton.checked = false;
disableButton.disabled = true;
2022-12-13 14:01:04 +00:00
}
}
});
avatarUpload.addEventListener('change', function() {
let file = this.files[0];
2022-12-19 15:25:10 +00:00
avatar.src = URL.createObjectURL(file);
2022-12-13 14:01:04 +00:00
});
2022-12-19 15:25:10 +00:00
deleteButton.addEventListener('click', () => {
Utils.deleteProfileAvatarRequest({{ user.hashid|tojson }})
.then(
(response) => {
avatar.src = "{{ url_for('static', filename='images/user_avatar.png') }}";
}
);
2022-12-13 14:01:04 +00:00
});
</script>
{% endblock scripts %}