2021-07-21 01:12:26 +00:00
{% extends "settings.html" %}
2021-08-19 05:14:52 +00:00
{% block pagetitle %}Block Settings - {{'SITE_NAME' | app_config}}{% endblock %}
2021-07-21 01:12:26 +00:00
{% block content %}
2021-09-28 03:44:31 +00:00
< script >
block_user=function() {
var exileForm = document.getElementById("exile-form");
var exileError = document.getElementById("toast-error-message");
var usernameField = document.getElementById("exile-username");
var isValidUsername = usernameField.checkValidity();
username = usernameField.value;
if (isValidUsername) {
var xhr = new XMLHttpRequest();
xhr.open("post", "/settings/block");
xhr.withCredentials=true;
f=new FormData();
f.append("username", username);
f.append("formkey", formkey());
xhr.onload=function(){
if (xhr.status< 300 ) {
window.location.reload(true);
}
else {
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.hide();
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
exileError.textContent = JSON.parse(xhr.response)["error"];
}
}
xhr.send(f)
}
}
< / script >
2021-07-21 01:12:26 +00:00
< div class = "row" >
< div class = "col" >
{% if error %}
< div class = "alert alert-danger alert-dismissible fade show my-3" role = "alert" >
< i class = "fas fa-exclamation-circle my-auto" > < / i >
< span >
{{error}}
< / span >
2021-09-26 09:04:49 +00:00
< button type = "button" class = "close" data-bs-dismiss = "alert" aria-label = "Close" >
2021-07-21 01:12:26 +00:00
< span aria-hidden = "true" > < i class = "far fa-times" > < / i > < / span >
< / button >
< / div >
{% endif %}
< / div >
< / div >
< div class = "row" >
< div class = "col" >
< div class = "d-md-flex justify-content-between mb-3" >
< div >
2021-09-06 16:17:48 +00:00
< h2 class = "h5" > Users you block< / h2 >
2021-07-21 01:12:26 +00:00
< p class = "text-small text-muted mb-md-0" > You have blocked the following users. They cannot reply to your content or notify you with a username mention.< / p >
< / div >
< div class = "mt-auto" >
2021-09-26 09:04:49 +00:00
< button class = "btn btn-primary" data-bs-toggle = "modal" data-bs-target = "#blockmodal" > Block user< / button >
2021-07-21 01:12:26 +00:00
< / div >
< / div >
{% if v.blocking.first() %}
< div class = "card mb-5" >
< table class = "table table-hover rounded mb-0" >
< thead class = "thead-dark" >
< tr >
< th scope = "col" > User< / th >
< th scope = "col" > Blocked since< / th >
< th scope = "col" > < / th >
< / tr >
< / thead >
< tbody class = "text-muted" >
{% for block in v.blocking %}
< tr >
< td >
< a href = "{{block.target.permalink}}" >
2021-09-03 14:08:32 +00:00
< img loading = "lazy" src = "{{block.target.profile_url}}" class = "profile-pic-20 align-top mr-2" > @{{block.target.username}}< / a >
2021-07-21 01:12:26 +00:00
< / td >
< td > {{block.created_date}}< / td >
< td >
< div class = "dropdown float-right dropdown-actions" >
2021-09-26 09:04:49 +00:00
< a href = "#" role = "button" id = "dropdownMoreLink" data-bs-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" style = "line-height: 0;" >
2021-07-21 01:12:26 +00:00
< i class = "fas fa-ellipsis-h text-muted" > < / i >
< / a >
< div class = "dropdown-menu border-0 shadow dropdown-menu-right mt-2" aria-labelledby = "dropdownMoreLink" x-placement = "bottom-end" style = "position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(21px, 18px, 0px);" >
2021-08-11 17:01:19 +00:00
< a class = "dropdown-item" href = "javascript:void(0)" onclick = "post_toast('/settings/unblock?username={{block.target.username}}&formkey={{v.formkey}}')" > < i class = "fas fa-check" > < / i > Unblock< / a >
2021-07-21 01:12:26 +00:00
< / div >
< / div >
< / td >
< / tr >
{% else %}
< td > There are no blocked users< / td >
{% endfor %}
< / tbody >
< / table >
< / div >
{% else %}
< div class = "text-center border-md rounded py-7" >
< i class = "fad fa-ghost text-gray-500 mb-3" style = "font-size: 3.5rem;" > < / i >
< p class = "font-weight-bold text-gray-500 mb-0" > No blocked users< / p >
< / div >
{% endif %}
< / div >
< / div >
2021-09-06 16:17:48 +00:00
< div class = "modal fade" id = "blockmodal" tabindex = "-1" role = "dialog" aria-labelledby = "blockmodal" aria-hidden = "true" >
2021-07-21 01:12:26 +00:00
< div class = "modal-dialog modal-dialog-centered" role = "document" >
< form action = "/settings/block" id = "exile-form" method = "post" onsubmit = "return false;" >
< div class = "modal-content" >
< div class = "modal-header" >
< h5 class = "modal-title" > Block users< / h5 >
2021-09-26 09:04:49 +00:00
< button type = "button" class = "close" data-bs-dismiss = "modal" aria-label = "Close" >
2021-07-21 01:12:26 +00:00
< span aria-hidden = "true" > < i class = "far fa-times" > < / i > < / span >
< / button >
< / div >
< div class = "modal-body" >
< input type = "hidden" name = "formkey" value = "{{v.formkey}}" >
< input type = "text" name = "username" placeholder = "enter username" id = "exile-username" class = "form-control" maxlength = 25 required >
< / div >
< div class = "modal-footer" >
2021-09-26 09:04:49 +00:00
< button type = "button" class = "btn btn-link text-muted" data-bs-dismiss = "modal" > Cancel< / button >
2021-07-21 01:12:26 +00:00
< button type = "button" class = "btn btn-primary" id = "exileUserButton" onclick = "block_user()" > Block user< / button >
< / div >
< / div >
< / form >
< / div >
< / div >
2021-09-26 09:04:49 +00:00
< div class = "toast error" id = "toast-exile-error" role = "alert" aria-live = "assertive" aria-atomic = "true" data-bs-animation = "true" data-bs-autohide = "true" data-bs-delay = "5000" >
2021-07-21 01:12:26 +00:00
< div class = "toast-body text-center" >
< i class = "fas fa-exclamation-circle text-danger mr-2" > < / i > < span id = "toast-error-message" > Error. Please try again.< / span >
< / div >
< / div >
2021-09-28 03:44:31 +00:00
{% endblock %}