Chat mit BUtton für eine Person FERTIG!

This commit is contained in:
Holger Trampe 2020-05-24 10:33:36 +02:00
parent 74db8a190c
commit 9b45ac79e5
6 changed files with 45 additions and 36 deletions

View File

@ -4,7 +4,6 @@
z-index: 999; z-index: 999;
height: 100%; height: 100%;
width: 100%; width: 100%;
border-radius: 50%;
} }
.icon-container { .icon-container {
width: 50px; width: 50px;
@ -69,6 +68,7 @@
{ {
$("#dynamicchatwindow_content").html(data); $("#dynamicchatwindow_content").html(data);
$("#dynamicchatwindow").show(); $("#dynamicchatwindow").show();
localStorage.setItem("basechatid", userid);
} }
}); });

View File

@ -153,11 +153,12 @@ $(document).ready(function(){
}) })
sending = true;
function sendNewMessage() function sendNewMessage()
{ {
if($("#message").val().length > 0) if($("#message").val().length > 0 && sending)
{ {
sending = false;
$.ajax( $.ajax(
{ {
type: "GET", type: "GET",
@ -173,7 +174,8 @@ $(document).ready(function(){
$("#message").val(""); $("#message").val("");
chatwebsocket.send("load__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}"); chatwebsocket.send("load__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}");
chatwebsocket.send("stoptyping__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}"); chatwebsocket.send("stoptyping__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}");
} sending = true;
}
}); });
} }
} }
@ -181,7 +183,7 @@ $(document).ready(function(){
$(document).on('keypress',function(e) { $(document).on('keypress',function(e) {
if(e.which == 13) { if(e.which == 13) {
if($("#message").val().length > 0){ if($("#message").val().length > 0 && sending){
sendNewMessage(); sendNewMessage();
} }
} }

View File

@ -1,9 +1,9 @@
<style type="text/css"> <style type="text/css">
.scroll { .scroll {
max-height: 400px; max-height: 400px;
min-height: 500px; min-height: 500px;
overflow-y: auto; overflow-y: auto;
} }
.chatmessageele_breaker .chatmessageele_breaker
{ {
@ -26,6 +26,12 @@
float: left; float: left;
text-align: left; text-align: left;
color: #000000; color: #000000;
}
.roundimg-chat {
border-radius: 50%;
z-index: 999;
height: 100%;
width: 100%;
} }
</style> </style>
{% load counter_tag %} {% load counter_tag %}
@ -65,7 +71,7 @@
{% if message.author == request.user %} {% if message.author == request.user %}
<div style="" class="chatmessageele_me col-7 mb-3 "> <div style="" class="chatmessageele_me col-7 mb-3 ">
<div class='icon-container ml-2 mt-1 ' style="float: right;"> <div class='icon-container ml-2 mt-1 ' style="float: right;">
<img class="img-profile roundimg" src="{{ message.author.profile.get_photo_url }}"> <img class="img-profile roundimg-chat" src="{{ message.author.profile.get_photo_url }}">
</div> </div>
<h6 class="mt-3"><small>{{message.sendtime|date:"H:i"}}</small></h6> <h6 class="mt-3"><small>{{message.sendtime|date:"H:i"}}</small></h6>
<div style="text-align: left;" class="mt-1"> <div style="text-align: left;" class="mt-1">
@ -77,7 +83,7 @@
{% else %} {% else %}
<div style="" class="chatmessageele_other col-7 mb-3"> <div style="" class="chatmessageele_other col-7 mb-3">
<div class='icon-container mr-2 mt-1 ' style="float: left;"> <div class='icon-container mr-2 mt-1 ' style="float: left;">
<img class="img-profile roundimg" src="{{ message.author.profile.get_photo_url }}"> <img class="img-profile roundimg-chat" src="{{ message.author.profile.get_photo_url }}">
</div> </div>
<h6 class="mt-3"><small>{{message.author.first_name}} {{message.author.last_name}},&nbsp;{{message.sendtime|date:"H:i"}}</small></h6> <h6 class="mt-3"><small>{{message.author.first_name}} {{message.author.last_name}},&nbsp;{{message.sendtime|date:"H:i"}}</small></h6>
<div style="text-align: left;" class="mt-1"> <div style="text-align: left;" class="mt-1">
@ -114,6 +120,7 @@
function closeSingleChat(){ function closeSingleChat(){
chatwebsocket.close(); chatwebsocket.close();
$("#dynamicchatwindow").hide(); $("#dynamicchatwindow").hide();
localStorage. removeItem("basechatid");
} }
$(document).ready(function(){ $(document).ready(function(){
@ -189,12 +196,13 @@ $(document).ready(function(){
} }
}) })
var sending = true;
function sendNewMessage() function sendNewMessage()
{ {
if($("#message").val().length > 0) if($("#message").val().length > 0 && sending)
{ {
sending = false;
$.ajax( $.ajax(
{ {
type: "GET", type: "GET",
@ -210,15 +218,16 @@ $(document).ready(function(){
$("#message").val(""); $("#message").val("");
chatwebsocket.send("load__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}"); chatwebsocket.send("load__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}");
chatwebsocket.send("stoptyping__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}"); chatwebsocket.send("stoptyping__{{user.pk}}__privatechat_{{roomdata.creator.pk}}_{{roomdata.chatmember_single.pk}}");
sending = true;
} }
}); });
} }
} }
$(document).on('keypress',function(e) { $(document).on('keypress',function(e) {
if(e.which == 13) { if(e.which == 13) {
if($("#message").val().length > 0){ if($("#message").val().length > 0 && sending == true){
sendNewMessage(); sendNewMessage();
} }
} }

View File

@ -14,38 +14,35 @@ from datetime import datetime, timedelta
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
############################################## DEV #####################################
############################################## LOCAL ##################################### BASE_URL = "https://dev01.digitale-agentur.com/"
BASE_URL = "http://localhost:8000/"
CRONAPIKEY = "gCddsaz6NOnE9QbXZM5LasdEk122D" CRONAPIKEY = "gCddsaz6NOnE9QbXZM5LasdEk122D"
MAILINFOKEY = "jka7sd8iukashdna78skduJAHDsu6dilaksdjba65a68iadbhjak" MAILINFOKEY = "jka7sd8iukashdna78skduJAHDsu6dilaksdjba65a68iadbhjak"
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
# Database # MAIL DEV
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases EMAIL_HOST = 'smtp.strato.de'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "support@dev01.digitale-agentur.com"
EMAIL_HOST_PASSWORD = "n2xd7emyKZFb6UREzvbintuUIG"
DEFAULT_FROM_EMAIL = "support@dev01.digitale-agentur.com"
# DEV # DEV
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME' : 'digitaleagentur', 'NAME' : 'digitaleagentur_dev01',
'USER' : 'root', 'USER' : 'digitaleagentur_dev01',
'PASSWORD' : '', 'PASSWORD' : 't3TvtGAOkFHYXdJlUMIu9u3U',
'PORT' : 3306 'PORT' : 3306
} }
} }
# MAIL DEV
EMAIL_HOST = 'gymhum.de'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "holger.trampe"
EMAIL_HOST_PASSWORD = "Motte2016_!"
DEFAULT_FROM_EMAIL = "holger.trampe@gymhum.de"
# REDIS # REDIS
REDIS_URL = ("localhost", 6379) REDIS_URL = ("localhost", 6379)
################################################### LOCAL ############################### ############################################## DEV #####################################

View File

@ -440,7 +440,7 @@
<!-- CHATAREA --> <!-- CHATAREA -->
<div id="dynamicchatwindow" class="col-4" style="position: absolute; bottom: 0px; right: 100px; display: none;"> <div id="dynamicchatwindow" class="col-4" style="position: absolute; bottom: 30px; right: 23px; display: none;z-index: 999;">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -839,7 +839,8 @@ $("#chatButton").click(function(){
}); });
</script> </script>