emile 9 months ago
parent 034f07dc10
commit f300b70523

Binary file not shown.

@ -95,8 +95,6 @@ class OsitcomChatRoom(WebsocketConsumer):
)
if event_type == 'typing':
print(text_data_json.get('typing_status'))
print(text_data_json.get('user_id'))
event = {
'type': 'typing_handler',
'user_id': text_data_json.get('user_id'),
@ -204,6 +202,16 @@ class OsitcomChatRoom(WebsocketConsumer):
}
self.update_read_messages_handler(event)
if event_type == 'end_chat':
event = {
'type': 'end_chat_handler',
'user_id': text_data_json.get('user_id')
}
async_to_sync(self.channel_layer.group_send)(
self.session_id, event
)
@ -239,9 +247,12 @@ class OsitcomChatRoom(WebsocketConsumer):
html = render_to_string("chat-widget.html", context=context)
else:
if chat_room:
html = render_to_string("chat-room.html", context=context)
if chat_room.date_terminated:
html = render_to_string("ended-chat.html", context=context)
else:
html = render_to_string("chat-room.html", context=context)
else:
html = render_to_string("start-conversation.html", context=context)
html = render_to_string("start-chat.html", context=context)
self.send(text_data=json.dumps({
'event_type': 'load_chat',
'html': html,
@ -340,7 +351,33 @@ class OsitcomChatRoom(WebsocketConsumer):
else:
latest_unread_message = None
def uploaded_file_handler(self, event):
message_attachment = get_object_or_404(ChatMessageAttachment, id=event['message_attachment_id'])
context = {
'message_attachment': message_attachment,
'file_type': event['file_type']
}
html = render_to_string("partials/message-attachment.html", context=context)
self.send(text_data=json.dumps({
'event_type': 'uploaded_file',
'file_name': event['file_name'],
'html': html,
}))
def end_chat_handler(self, event):
if event['user_id']:
member = get_object_or_404(User, id=event['user_id'])
else:
member = None
self.chat_room.date_terminated = datetime.now()
self.chat_room.terminated_by = member
self.chat_room.save()
context = {
'chat_room': self.chat_room,
'chat_room_messages': ChatMessage.objects.filter(room=self.chat_room).order_by('date_sent'),
}
html = render_to_string("ended-chat.html", context=context)
self.send(text_data=json.dumps({
'event_type': 'ended_chat',
'html': html,
}))

@ -0,0 +1,26 @@
# Generated by Django 4.2.5 on 2024-08-01 16:49
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('osichat', '0016_chatmessageseen_seen_date'),
]
operations = [
migrations.AddField(
model_name='chatroom',
name='date_terminated',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='chatroom',
name='terminated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='terminated_chatrooms', to=settings.AUTH_USER_MODEL),
),
]

@ -17,6 +17,8 @@ class ChatRoom(models.Model):
name = models.CharField(max_length=300)
created_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, blank=True)
date_created = models.DateTimeField()
terminated_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, blank=True, related_name='terminated_chatrooms')
date_terminated = models.DateTimeField(null=True, blank=True)
@property
def last_updated(self):
last_message = ChatMessage.objects.filter(room=self).order_by('-date_sent').first()
@ -31,6 +33,7 @@ class ChatRoom(models.Model):
else:
return last_updated_time.strftime('%d-%m-%Y')
class ChatRoomGuest(models.Model):
room = models.OneToOneField(ChatRoom, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=300)

@ -49,7 +49,7 @@
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if message.member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.106:8000{{message.member.staffprofile.image.url}}">
src="http://192.168.1.111:8000{{message.member.staffprofile.image.url}}">
{% else %}
<p>{{message.member.first_name.0}}{{message.member.last_name.0}}</p>
{% endif %}
@ -99,7 +99,7 @@
{% if message.chatmessageattachment.is_image %}
<div class="w-full flex justify-end">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<img src="http://192.168.1.106:8000/{{message.chatmessageattachment.attachment}}" class="rounded-md">
<img src="http://192.168.1.111:8000/{{message.chatmessageattachment.attachment}}" class="rounded-md">
</div>
</div>
{% else %}
@ -125,7 +125,7 @@
{% endfor %}
</div>
<audio id="notification-sound" src="http://192.168.1.106:8000/static/notifications/osichat-notification.mp3" preload="auto"></audio>
<audio id="notification-sound" src="http://192.168.1.111:8000/static/notifications/osichat-notification.mp3" preload="auto"></audio>
<div id="typing" class="hidden"></div>
</div>
@ -161,7 +161,7 @@
</div>
<div class="w-full rounded-b-md px-3 pt-3 flex justify-center items-center gap-1 bg-white">
<img src="http://192.168.1.106:8000/static/images/ositcom_logos/ositcom(o).png" class="w-[20px]">
<img src="http://192.168.1.111:8000/static/images/ositcom_logos/ositcom(o).png" class="w-[20px]">
<p class="text-xs text-secondosiblue">Osichat 2.0 by <a href="https://ositcom.com/" target="_blank"
class="hover:text-gray-400 duration-500">Ositcom</a></p>

@ -28,50 +28,49 @@
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
class="text-white w-7 notFilledSvg cursor-pointer hover:scale-105 duration-500" fill="none">
<path
d="M11 3L10.3374 3.23384C7.75867 4.144 6.46928 4.59908 5.73464 5.63742C5 6.67576 5 8.0431 5 10.7778V13.2222C5 15.9569 5 17.3242 5.73464 18.3626C6.46928 19.4009 7.75867 19.856 10.3374 20.7662L11 21"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
<path d="M21 12L11 12M21 12C21 11.2998 19.0057 9.99153 18.5 9.5M21 12C21 12.7002 19.0057 14.0085 18.5 14.5"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<div id="endChat" class="{% if not chat_room or chat_room.date_terminated %} hidden {% endif %}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
class="text-white w-7 notFilledSvg cursor-pointer hover:scale-105 duration-500" fill="none">
<path
d="M11 3L10.3374 3.23384C7.75867 4.144 6.46928 4.59908 5.73464 5.63742C5 6.67576 5 8.0431 5 10.7778V13.2222C5 15.9569 5 17.3242 5.73464 18.3626C6.46928 19.4009 7.75867 19.856 10.3374 20.7662L11 21"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
<path d="M21 12L11 12M21 12C21 11.2998 19.0057 9.99153 18.5 9.5M21 12C21 12.7002 19.0057 14.0085 18.5 14.5"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</div>
</div>
<!-- CLOSE CHAT CONFIRMATION MESSAGE -->
<div class="w-full h-full absolute inset-0 rounded-none md:rounded-md bg-black bg-opacity-50 flex justify-center items-center p-5 z-20 hidden" id="confirmationMessageContainer">
<div class="w-full h-full absolute inset-0 rounded-none md:rounded-md bg-black bg-opacity-50 flex justify-center items-center p-5 z-20 hidden" id="endChatConfirmationContainer">
<div class="w-full h-fit p-5 bg-white rounded-md shadow-md flex flex-col justify-center items-center gap-3 relative">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" id="closeConfirmationMessage" class="w-5 text-secondosiblue absolute top-3 right-3 hover:text-fifthosiblue duration-300 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
<div id="closeConfirmationMessage">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 text-secondosiblue absolute top-3 right-3 hover:text-fifthosiblue duration-300 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</div>
<p class="text-center text-secondosiblue mt-5">Are you sure you want to end this chat?</p>
<button class="rounded-md bg-red-500 border border-red-500 uppercase text-white px-5 py-2 shadow-md text-sm cursor-pointer hover:bg-white hover:text-red-500 duration-300">
<button id="endChatComfirmed" class="rounded-md bg-red-500 border border-red-500 uppercase text-white px-5 py-2 shadow-md text-sm cursor-pointer hover:bg-white hover:text-red-500 duration-300">
End chat
</button>
</div>
</div>
<!-- ENDDDDDDD -->
<!-- SCRIPT -->
<!-- <script>
const closeConfirmationMessage = document.getElementById('closeConfirmationMessage')
closeConfirmationMessage.addEventListener("click", function() {
const confirmationMessageContainer = document.getElementById("confirmationMessageContainer");
if (confirmationMessageContainer) {
confirmationMessageContainer.classList.add("hidden");
}
});
</script> -->
<!-- SCRIPT -->
<!-- END CLOSE CHAT CONFIRMATION MESSAGE -->
<div id="roomContainer" class="flex-l overflow-hidden h-full">
{% if chat_room %}
{% include 'chat-room.html' %}
{% if not chat_room.date_terminated %}
{% include 'chat-room.html' %}
{% else %}
{% include 'ended-chat.html' %}
{% endif %}
{% else %}
{% include 'start-chat.html' %}
{% include 'start-chat.html' %}
{% endif %}
</div>
</div>

@ -0,0 +1,134 @@
{%load static%}
<p id="chatRoomId" class="hidden">{{chat_room.id}}</p>
<div class="w-full h-full md:h-[450px] lg:h-[550px] bg-white rounded-b-none md:rounded-b-md flex flex-col justify-end">
<div class="overflow-y-auto flex flex-col gap-5 px-5 pt-3" id="conversation">
<!-- ROBOT -->
<div class="w-full flex items-end gap-2">
<div>
<div
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-4" color="#000000" fill="none">
<path d="M4 15.5C2.89543 15.5 2 14.6046 2 13.5C2 12.3954 2.89543 11.5 4 11.5" stroke="white"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
<path d="M20 15.5C21.1046 15.5 22 14.6046 22 13.5C22 12.3954 21.1046 11.5 20 11.5"
stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
<path d="M7 7L7 4" stroke="white" stroke-width="1.5" stroke-linejoin="round" />
<path d="M17 7L17 4" stroke="white" stroke-width="1.5" stroke-linejoin="round" />
<circle cx="7" cy="3" r="1" stroke="white" stroke-width="1.5" stroke-linejoin="round" />
<circle cx="17" cy="3" r="1" stroke="white" stroke-width="1.5" stroke-linejoin="round" />
<path
d="M13.5 7H10.5C7.67157 7 6.25736 7 5.37868 7.90898C4.5 8.81796 4.5 10.2809 4.5 13.2069C4.5 16.1329 4.5 17.5958 5.37868 18.5048C6.25736 19.4138 7.67157 19.4138 10.5 19.4138H11.5253C12.3169 19.4138 12.5962 19.5773 13.1417 20.1713C13.745 20.8283 14.6791 21.705 15.5242 21.9091C16.7254 22.1994 16.8599 21.7979 16.5919 20.6531C16.5156 20.327 16.3252 19.8056 16.526 19.5018C16.6385 19.3316 16.8259 19.2898 17.2008 19.2061C17.7922 19.074 18.2798 18.8581 18.6213 18.5048C19.5 17.5958 19.5 16.1329 19.5 13.2069C19.5 10.2809 19.5 8.81796 18.6213 7.90898C17.7426 7 16.3284 7 13.5 7Z"
stroke="white" stroke-width="1.5" stroke-linejoin="round" />
<path d="M9.5 15C10.0701 15.6072 10.9777 16 12 16C13.0223 16 13.9299 15.6072 14.5 15"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
<path d="M9.00896 11H9" stroke="#20336b" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M15.009 11H15" stroke="#20336b" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</svg>
</div>
</div>
<div
class="max-w-[80%] bg-gray-50 px-4 py-3 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-7 bg-opacity-50 shadow-md border border-gray-100">
<p>{% if chat_room.chatroomguest.name %}Hello {{chat_room.chatroomguest.name}},{% else %}Hello,{% endif %} thank you for contacting us. Please bear with us while we
connect you with the next available agent as soon as possible.</p>
</div>
</div>
<!-- USER MESSAGES -->
<div id="messages" class="w-full flex flex-col gap-5 pb-1">
{% for message in chat_room_messages %}
<!-- STAFF MESSAGE -->
{% if message.member %}
<div class="w-full flex items-end justify-start gap-2">
<div>
<div
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if message.member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.111:8000{{message.member.staffprofile.image.url}}">
{% else %}
<p>{{message.member.first_name.0}}{{message.member.last_name.0}}</p>
{% endif %}
</div>
</div>
{% if not message.chatmessageattachment %}
<div
class="max-w-[80%] bg-gray-50 px-4 py-3 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-6 bg-opacity-50 shadow-md border border-gray-100">
<p style="white-space: pre-line; overflow-wrap: anywhere;">{{message.content}}</p>
</div>
{% else %}
{% if message.chatmessageattachment.is_image %}
<div
class="max-w-[80%] bg-gray-50 p-4 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-6 bg-opacity-50 shadow-md border border-gray-100">
<img src="http://192.168.1.106:8000/{{message.chatmessageattachment.attachment}}" class="rounded-md">
</div>
{% else %}
<div
class="max-w-[80%] bg-gray-50 p-4 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-6 bg-opacity-50 shadow-md border border-gray-100">
<div class="w-full flex items-center gap-1">
<div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-5 text-secondosiblue notFilledSvg">
<path d="M8 7L16 7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M8 11L12 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M13 21.5V21C13 18.1716 13 16.7574 13.8787 15.8787C14.7574 15 16.1716 15 19 15H19.5M20 13.3431V10C20 6.22876 20 4.34315 18.8284 3.17157C17.6569 2 15.7712 2 12 2C8.22877 2 6.34315 2 5.17157 3.17157C4 4.34314 4 6.22876 4 10L4 14.5442C4 17.7892 4 19.4117 4.88607 20.5107C5.06508 20.7327 5.26731 20.9349 5.48933 21.1139C6.58831 22 8.21082 22 11.4558 22C12.1614 22 12.5141 22 12.8372 21.886C12.9044 21.8623 12.9702 21.835 13.0345 21.8043C13.3436 21.6564 13.593 21.407 14.0919 20.9081L18.8284 16.1716C19.4065 15.5935 19.6955 15.3045 19.8478 14.9369C20 14.5694 20 14.1606 20 13.3431Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</div>
<div class="flex flex-col">
<span class="text-xs">{{message.chatmessageattachment.file_name}}</span>
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
<!-- GUEST MESSAGE -->
{% else %}
{% if not message.chatmessageattachment %}
<div class="w-full flex justify-end">
<div
class="max-w-[80%] px-4 py-3 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<p style="white-space: pre-line; overflow-wrap: anywhere;">{{message.content}}</p>
</div>
</div>
{% else %}
{% if message.chatmessageattachment.is_image %}
<div class="w-full flex justify-end">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<img src="http://192.168.1.111:8000/{{message.chatmessageattachment.attachment}}" class="rounded-md">
</div>
</div>
{% else %}
<div class="w-full flex justify-end">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<div class="w-full flex items-center gap-1">
<div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-5 text-white notFilledSvg">
<path d="M8 7L16 7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M8 11L12 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M13 21.5V21C13 18.1716 13 16.7574 13.8787 15.8787C14.7574 15 16.1716 15 19 15H19.5M20 13.3431V10C20 6.22876 20 4.34315 18.8284 3.17157C17.6569 2 15.7712 2 12 2C8.22877 2 6.34315 2 5.17157 3.17157C4 4.34314 4 6.22876 4 10L4 14.5442C4 17.7892 4 19.4117 4.88607 20.5107C5.06508 20.7327 5.26731 20.9349 5.48933 21.1139C6.58831 22 8.21082 22 11.4558 22C12.1614 22 12.5141 22 12.8372 21.886C12.9044 21.8623 12.9702 21.835 13.0345 21.8043C13.3436 21.6564 13.593 21.407 14.0919 20.9081L18.8284 16.1716C19.4065 15.5935 19.6955 15.3045 19.8478 14.9369C20 14.5694 20 14.1606 20 13.3431Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</div>
<div class="flex flex-col">
<span class="text-xs">{{message.chatmessageattachment.file_name}}</span>
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</div>
<audio id="notification-sound" src="http://192.168.1.111:8000/static/notifications/osichat-notification.mp3" preload="auto"></audio>
<div id="typing" class="hidden"></div>
</div>
</div>

@ -5,7 +5,7 @@
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if message_attachment.message.member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.106:8000{{message_attachment.message.member.staffprofile.image.url}}">
src="http://192.168.1.111:8000{{message_attachment.message.member.staffprofile.image.url}}">
{% else %}
<p>{{message_attachment.message.member.first_name.0}}{{message_attachment.message.member.last_name.0}}</p>
{% endif %}
@ -14,7 +14,7 @@
{% if file_type == 'image' %}
<div
class="max-w-[80%] bg-gray-50 p-4 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-6 bg-opacity-50 shadow-md border border-gray-100">
<img src="http://192.168.1.106:8000/{{message_attachment.attachment}}" class="rounded-md">
<img src="http://192.168.1.111:8000/{{message_attachment.attachment}}" class="rounded-md">
</div>
{% else %}
<div
@ -39,7 +39,7 @@
{% if file_type == 'image' %}
<div class="w-full flex justify-end">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<img src="http://192.168.1.106:8000/{{message_attachment.attachment}}" class="rounded-md">
<img src="http://192.168.1.111:8000/{{message_attachment.attachment}}" class="rounded-md">
</div>
</div>
{% else %}

@ -1,11 +1,11 @@
{% if chat_message.member %}
<div class="w-full flex items-end justify-start gap-2">
<div class="w-full flex items-end justify-start gap-2 fade-in-up">
<div>
<div
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if chat_message.member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.106:8000{{chat_message.member.staffprofile.image.url}}">
src="http://192.168.1.111:8000{{chat_message.member.staffprofile.image.url}}">
{% else %}
<p>{{chat_message.member.first_name.0}}{{chat_message.member.last_name.0}}</p>
{% endif %}
@ -20,7 +20,7 @@
{% if chat_message.chatmessageattachment.is_image %}
<div
class="max-w-[80%] bg-gray-50 p-4 rounded-r-3xl rounded-tl-3xl text-secondosiblue text-sm leading-6 bg-opacity-50 shadow-md border border-gray-100">
<img src="http://192.168.1.106:8000/{{chat_message.chatmessageattachment.attachment}}" class="rounded-md">
<img src="http://192.168.1.111:8000/{{chat_message.chatmessageattachment.attachment}}" class="rounded-md">
</div>
{% else %}
<div
@ -45,7 +45,7 @@
<!-- GUEST MESSAGE -->
{% else %}
{% if not chat_message.chatmessageattachment %}
<div class="w-full flex justify-end">
<div class="w-full flex justify-end fade-in-up">
<div
class="max-w-[80%] px-4 py-3 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<p style="white-space: pre-line; overflow-wrap: anywhere;">{{chat_message.content}}</p>
@ -53,13 +53,13 @@
</div>
{% else %}
{% if chat_message.chatmessageattachment.is_image %}
<div class="w-full flex justify-end">
<div class="w-full flex justify-end fade-in-up">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<img src="http://192.168.1.106:8000/{{chat_message.chatmessageattachment.attachment}}" class="rounded-md">
<img src="http://192.168.1.111:8000/{{chat_message.chatmessageattachment.attachment}}" class="rounded-md">
</div>
</div>
{% else %}
<div class="w-full flex justify-end">
<div class="w-full flex justify-end fade-in-up">
<div class="max-w-[80%] p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue">
<div class="w-full flex items-center gap-1">
<div>
@ -77,4 +77,15 @@
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<style>
@keyframes fadeInAndUp {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0px); }
}
.fade-in-up {
animation: fadeInAndUp 0.6s ease;
}
</style>

@ -3,7 +3,7 @@
class="w-[30px] h-[30px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.106:8000{{member.staffprofile.image.url}}">
src="http://192.168.1.111:8000{{member.staffprofile.image.url}}">
{% else %}
<p>{{member.first_name.0}}{{member.last_name.0}}</p>
{% endif %}

@ -7,7 +7,7 @@
class="w-[30px] h-[30px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if latest_unread_message.member.staffprofile.image %}
<img class="w-full h-full rounded-full"
src="http://192.168.1.106:8000{{latest_unread_message.member.staffprofile.image.url}}">
src="http://192.168.1.111:8000{{latest_unread_message.member.staffprofile.image.url}}">
{% else %}
<p>{{latest_unread_message.member.first_name.0}}{{latest_unread_message.member.last_name.0}}</p>
{% endif %}
@ -45,7 +45,7 @@
</div>
{% else %}
<div class="w-fit bg-opacity-70 bg-osiblue px-3 py-2 rounded-md w-full h-[300px]">
<img src="http://192.168.1.106:8000{{latest_unread_message.chatmessageattachment.attachment}}" class="w-full h-full object-cover rounded-md">
<img src="http://192.168.1.111:8000{{latest_unread_message.chatmessageattachment.attachment}}" class="w-full h-full object-cover rounded-md">
</div>
{% endif %}

@ -62,7 +62,7 @@
</div>
<div class="w-full rounded-b-md px-3 pt-3 flex justify-center items-center gap-1 bg-white">
<img src="http://192.168.1.106:8000/static/images/ositcom_logos/ositcom(o).png" class="w-[20px]">
<img src="http://192.168.1.111:8000/static/images/ositcom_logos/ositcom(o).png" class="w-[20px]">
<p class="text-xs text-secondosiblue">Osichat 2.0 by <a href="https://ositcom.com/" target="_blank"
class="hover:text-gray-400 duration-500">Ositcom</a></p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

@ -1,5 +1,5 @@
const admin_chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const admin_chat_domain = "192.168.1.106:8000";
const admin_chat_domain = "192.168.1.111:8000";
let chatWebSocket = null;

@ -1,5 +1,5 @@
const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const domain = "192.168.1.106:8000";
const domain = "192.168.1.111:8000";
let osichatSocket;
let isOpen = false;
let chatLoaded = false;
@ -12,7 +12,7 @@ async function fetchSessionID() {
let session_id = 'Unknown';
while (session_id === 'Unknown') {
try {
const response = await fetch('http://192.168.1.106:3000/get-client-session/');
const response = await fetch('http://192.168.1.111:3000/get-client-session/');
const data = await response.json();
if (data.session_id) {
session_id = data.session_id;
@ -82,12 +82,12 @@ function handleLoadChatEvent(data, osichatSocket) {
chatDiv.appendChild(script);
}
const startChatContainer = document.getElementById('startChat');
const startChatContainer = document.getElementById('startChat'); //Case where returned is start-conversation.html
if (startChatContainer) {
handleFormSubmission(startChatContainer, 'start_conversation', osichatSocket);
}
const sendMessageContainer = document.getElementById('sendMessage');
const sendMessageContainer = document.getElementById('sendMessage'); //Case where returned is chat-room.html
if (sendMessageContainer) {
appendTextAreaScript(domain, chatDiv);
handleFormSubmission(sendMessageContainer, 'send_message', osichatSocket);
@ -96,6 +96,14 @@ function handleLoadChatEvent(data, osichatSocket) {
uploadScript.type = 'text/javascript';
uploadScript.src = `http://${domain}/static/js/osichat/upload-file.js`;
chatDiv.appendChild(uploadScript);
const endChatScript = document.createElement('script');
endChatScript.type = 'text/javascript';
endChatScript.src = `http://${domain}/static/js/osichat/end-chat.js`;
chatDiv.appendChild(endChatScript);
const endChatButton = document.getElementById('endChat');
endChatButton.classList.remove('hidden')
}
}
@ -162,6 +170,14 @@ async function initializeChatWebSocket() {
unreadMessages.classList.add('hidden');
}
break;
case 'ended_chat':
const currentChat = document.getElementById(`roomContainer`);
if (currentChat) {
currentChat.innerHTML = data.html;
}
document.getElementById(`endChatConfirmationContainer`).classList.add('hidden');
document.getElementById(`endChat`).classList.add('hidden');
break;
default:
console.log('Unknown event type:', data.event_type);
}
@ -192,6 +208,3 @@ window.addEventListener('offline', () => {
// INITIALIZE CHAT WEB SOCKET
initializeChatWebSocket();

@ -0,0 +1,29 @@
(function() {
const endChat = document.getElementById('endChat');
const endChatConfirmationContainer = document.getElementById("endChatConfirmationContainer");
const closeConfirmationMessage = document.getElementById('closeConfirmationMessage');
const endChatConfirmed = document.getElementById('endChatComfirmed');
endChat.addEventListener("click", function() {
if (endChatConfirmationContainer) {
endChatConfirmationContainer.classList.remove("hidden");
}
});
closeConfirmationMessage.addEventListener("click", function() {
if (closeConfirmationMessage) {
endChatConfirmationContainer.classList.add("hidden");
}
});
endChatConfirmed.addEventListener("click", function() {
const eventMessage = {
event_type: 'end_chat',
};
osichatSocket.send(JSON.stringify(eventMessage));
});
})();

@ -1,5 +1,5 @@
(function () {
const imageDomain = "http://192.168.1.106:8000";
const imageDomain = "http://192.168.1.111:8000";
// TO TRIGGER TEH FILE UPLOADER WHEN CLICKING ON THE UPLOAD FILE SVG
document.getElementById('svgFileUpload').addEventListener('click', function () {

Loading…
Cancel
Save