This commit is contained in:
Egor Matveev
2021-12-19 23:15:19 +03:00
parent 014ab7a6b8
commit 17573e1a76
12 changed files with 246 additions and 1 deletions

View File

@@ -23,7 +23,7 @@
<div class="col-9">
<h3>
{{ account.userinfo.surname }} {{ account.userinfo.name }}
<span style="margin-left: 15px; margin-bottom: 20px;" class="badge badge-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span>
<span style="margin-left: 15px; margin-bottom: 20px;" class="badge badge-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span> <a href="/chat_with?username={{ account.username }}"><i class="fa fa-comments"></i></a>
{% if not owner %}
<form method="POST">
{% csrf_token %}
@@ -133,6 +133,14 @@
<input type="checkbox" name="notification_friends" {% if user.userinfo.notification_friends %}checked{% endif %}>
</td>
</tr>
<tr>
<td style="width: 200px;">
Сообщения в оффлайн
</td>
<td>
<input type="checkbox" name="notification_messages" {% if user.userinfo.notification_messages %}checked{% endif %}>
</td>
</tr>
</table>
<button type="submit" class="btn btn-light" style="margin-top: 15px;"><i class="fa fa-save"></i> Сохранить</button>

43
templates/chat.html Normal file
View File

@@ -0,0 +1,43 @@
{% extends 'base_main.html' %}
{% block scripts %}
var page = 1;
function setPage(number) {
page = number;
}
function doPoll() {
jQuery.get('/messages?chat_id={{ chat.id }}&page=' + page.toString(), function(data) {
var e = document.getElementById('messages');
if (e.innerHTML !== data)
e.innerHTML = data;
const name = "page_num_" + page.toString();
elem = document.getElementById(name);
if (elem) {
elem.className = "btn btn-dark";
}
setTimeout(function() {doPoll()}, 2000);
})
}
{% endblock %}
{% block onload %}doPoll(){% endblock %}
{% block main %}
<div class="row">
<div class="col">
<a href="/account?username={{ chat.user.username }}" style="font-size: 40px;"><i class="fa fa-arrow-left"></i></a>
</div>
<div class="col">
<img src="{{ chat.user.userinfo.profile_pic_url }}" width="50px" height="50px" style="border-radius: 50%; margin-right: 10px;">
</div>
<div class="col-10">
<p style="font-size: 40px;">{{ chat.user.username }}</p>
</div>
</div>
<form method="POST">
{% csrf_token %}
<textarea name="text" style="width: 100%; height: 100px;"></textarea>
<button type="submit" class="btn btn-dark">Отправить</button>
</form>
<div id="messages"></div>
{% endblock %}

33
templates/messages.html Normal file
View File

@@ -0,0 +1,33 @@
{% if need_pagination %}
<div style="display: flex; justify-content: flex-end">
<table>
<tr>
{% for num in count_pages %}
<td><button class="btn btn-light" id="page_num_{{ num }}" onclick="setPage({{ num }})">{{ num }}</button></td>
{% endfor %}
</tr>
</table>
</div>
{% endif %}
<div class="container">
{% for message in messages %}
<div class="row" style="margin-bottom: 15px;">
{% if message.user == user %}
<div class="col-8"></div>
<div class="col-4" style="text-align: end; background-color: #b5deec; border-radius: 25px;">
{% else %}
<div class="col-4" style="background-color: #8ccde2; border-radius: 25px;">
{% endif %}
<p style="align-self: end; word-wrap: break-word;">{{ message.text }}</p>
{% if message.user == user %}
</div>
{% else %}
</div>
<div class="col-8">
</div>
{% endif %}
</div>
{% endfor %}
</div>