new
@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.2.5 on 2024-07-31 06:57
|
||||
|
||||
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', '0014_alter_chatmessageattachment_message'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='chatmessageseen',
|
||||
name='guest',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='osichat.chatroomguest'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='chatmessageseen',
|
||||
name='member',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.5 on 2024-07-31 07:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('osichat', '0015_chatmessageseen_guest_alter_chatmessageseen_member'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='chatmessageseen',
|
||||
name='seen_date',
|
||||
field=models.DateTimeField(null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,63 @@
|
||||
|
||||
<div class="w-full sm:w-fit fixed right-5 bottom-[80px] z-40 flex justify-end">
|
||||
<div class="w-[80%] sm:w-[400px] rounded-3xl bg-white border border-gray-100 shadow-md flex flex-col gap-2 p-5">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-start items-center gap-2">
|
||||
<div
|
||||
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.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 %}
|
||||
</div>
|
||||
<p class="text-secondosiblue">{{latest_unread_message.member.first_name}} {{latest_unread_message.member.last_name.0}}. <span class="text-gray-400 text-sm">from Ositcom</span></p>
|
||||
</div>
|
||||
|
||||
<div class="text-gray-500 cursor-pointer hover:text-secondosiblue duration-500" id="closeNewMesagePopup">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if not latest_unread_message.chatmessageattachment %}
|
||||
<p class="text-gray-500">
|
||||
{{latest_unread_message.content}}
|
||||
</p>
|
||||
|
||||
{% elif latest_unread_message.chatmessageattachment and not latest_unread_message.chatmessageattachment.is_image %}
|
||||
<div
|
||||
class="w-full p-4 rounded-md text-white text-sm leading-6 bg-opacity-70 bg-osiblue flex items-center gap-2 text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-7 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>
|
||||
<p>{{latest_unread_message.chatmessageattachment.file_name}}</p>
|
||||
</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.111:8000/{{latest_unread_message.chatmessageattachment.attachment}}" class="w-full h-full object-cover rounded-md">
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="text-sm text-secondosiblue flex items-center gap-2 cursor-pointer hover:text-gray-400 duration-500"
|
||||
id="openChatContainer2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
|
||||
</svg>
|
||||
|
||||
<p>See <span class="font-poppinsBold">{{number_of_unread}}</span> new message{% if not number_of_unread == 1 %}s{% endif %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 4.6 MiB |
Before Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 637 KiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 684 KiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 295 KiB |
Before Width: | Height: | Size: 295 KiB |
Before Width: | Height: | Size: 295 KiB |
Before Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 966 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 3.8 MiB |
After Width: | Height: | Size: 966 KiB |
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 2.4 MiB |
@ -0,0 +1,120 @@
|
||||
const imageDomain = "http://192.168.1.106:8000";
|
||||
|
||||
// TO TRIGGER TEH FILE UPLOADER WHEN CLICKING ON THE UPLOAD FILE SVG
|
||||
document.getElementById('svgFileUpload').addEventListener('click', function() {
|
||||
document.getElementById('fileupload').click();
|
||||
});
|
||||
|
||||
document.getElementById('fileupload').addEventListener('change', function(event) {
|
||||
let files = event.target.files;
|
||||
|
||||
for (let file of files) {
|
||||
let formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('filename', file.name);
|
||||
|
||||
// Display the file during upload
|
||||
if (file.type.startsWith('image/')) {
|
||||
displayImageDuringUpload(file);
|
||||
} else {
|
||||
displayDocumentDuringUpload(file);
|
||||
}
|
||||
|
||||
// Perform the upload
|
||||
fetch(`${imageDomain}/chat-file-uploader/`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.data === 'Uploaded Successfully') {
|
||||
const fullPath = `${imageDomain}/${data.existingPath}`;
|
||||
updateSelectTag(fullPath, file.name);
|
||||
if (file.type.startsWith('image/')) {
|
||||
osichatSocket.send(JSON.stringify({ 'event_type': 'uploaded_image', 'fullPath': fullPath, 'type': 'image' }));
|
||||
} else {
|
||||
osichatSocket.send(JSON.stringify({ 'event_type': 'uploaded_file', 'fullPath': fullPath, 'type': 'document' }));
|
||||
}
|
||||
} else {
|
||||
console.error('Upload failed');
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
});
|
||||
|
||||
function displayImageDuringUpload(file) {
|
||||
let reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
let outerDiv = document.createElement('div');
|
||||
outerDiv.className = 'w-fit p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue';
|
||||
|
||||
let div = document.createElement('div');
|
||||
div.id = 'uploading-' + file.name;
|
||||
div.className = 'image-' + file.name;
|
||||
|
||||
let img = document.createElement('img');
|
||||
img.src = event.target.result;
|
||||
img.style.opacity = '0.2';
|
||||
|
||||
div.appendChild(img);
|
||||
|
||||
outerDiv.appendChild(div);
|
||||
|
||||
document.getElementById('messages').appendChild(outerDiv);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
|
||||
function displayDocumentDuringUpload(file) {
|
||||
let outerDiv = document.createElement('div');
|
||||
outerDiv.className = 'w-full p-4 rounded-l-3xl rounded-tr-3xl text-white shadow-md text-sm leading-6 bg-opacity-70 bg-osiblue';
|
||||
|
||||
let flexContainer = document.createElement('div');
|
||||
flexContainer.className = 'w-full flex items-center gap-1';
|
||||
|
||||
let svg = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-7 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>
|
||||
`;
|
||||
|
||||
let svgDiv = document.createElement('div');
|
||||
svgDiv.innerHTML = svg;
|
||||
|
||||
let textContainer = document.createElement('div');
|
||||
textContainer.className = 'flex flex-col';
|
||||
|
||||
let uploadingText = document.createElement('span');
|
||||
uploadingText.id = 'uploading-' + file.name;
|
||||
uploadingText.textContent = 'Uploading...';
|
||||
|
||||
let fileNameDiv = document.createElement('div');
|
||||
fileNameDiv.className = 'file-name';
|
||||
fileNameDiv.textContent = file.name;
|
||||
|
||||
textContainer.appendChild(uploadingText);
|
||||
textContainer.appendChild(fileNameDiv);
|
||||
|
||||
flexContainer.appendChild(svgDiv);
|
||||
flexContainer.appendChild(textContainer);
|
||||
|
||||
outerDiv.appendChild(flexContainer);
|
||||
|
||||
document.getElementById('messages').appendChild(outerDiv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function updateSelectTag(path, fileName) {
|
||||
let option = document.createElement('option');
|
||||
option.value = path;
|
||||
option.textContent = fileName;
|
||||
option.selected = true;
|
||||
document.getElementById('filePathInput').appendChild(option);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.7 MiB |
Before Width: | Height: | Size: 854 KiB |
Before Width: | Height: | Size: 17 KiB |