mirror of
https://github.com/lucaspalomodevelop/Party.git
synced 2026-03-13 08:09:37 +00:00
render messages correctly
This commit is contained in:
parent
fdf89fa009
commit
360ff0058d
@ -16,8 +16,9 @@ class Chat:
|
||||
|
||||
@classmethod
|
||||
def getAllMessages(self)-> list[dict]:
|
||||
return list(self.collection.find())
|
||||
|
||||
messages = self.collection.find()
|
||||
print(messages)
|
||||
return list(messages)
|
||||
|
||||
@classmethod
|
||||
def insertMessage(self, content: str, author: str, timestamp: str):
|
||||
@ -37,5 +38,6 @@ class Chat:
|
||||
'author': author,
|
||||
'timestamp': timestamp,
|
||||
}
|
||||
print(message)
|
||||
|
||||
return message
|
||||
|
||||
@ -6,7 +6,8 @@ function getNChatMessages(socket, count, skip) {
|
||||
data = JSON.parse(data.data.messages)
|
||||
|
||||
for (let message of data) {
|
||||
message_array.push(buildChatMessage(message.content, message.author, message.timestamp));
|
||||
console.log(message)
|
||||
message_array.push(buildChatMessage(message.sender, message.text, message.timestamp['$date']));
|
||||
}
|
||||
|
||||
const chatBox = document.getElementById('chatBox');
|
||||
@ -17,8 +18,8 @@ function getNChatMessages(socket, count, skip) {
|
||||
});
|
||||
}
|
||||
|
||||
function buildChatMessage(content, author, timestap) {
|
||||
console.log(content, author, timestap);
|
||||
function buildChatMessage(author, content, timestap) {
|
||||
//console.log(content, author, timestap);
|
||||
const message = document.createElement('div');
|
||||
message.classList.add('chat-message');
|
||||
|
||||
|
||||
@ -53,20 +53,21 @@
|
||||
<div class="hidden-div">
|
||||
<h1>Planer</h1>
|
||||
<table id="events">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Event</td>
|
||||
<td>Zeit</td>
|
||||
<td>Status</td>
|
||||
<td>Verwalten</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>f</td>
|
||||
<td>f</td>
|
||||
<td>f</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Event</td>
|
||||
<td>Zeit</td>
|
||||
<td>Status</td>
|
||||
<td>Verwalten</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>f</td>
|
||||
<td>f</td>
|
||||
<td>f</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<form action="/api/get_events">
|
||||
<input class="event_input" typ="text" name="Event" placeholder="Essen" maxlength="20" minlength="1" required>
|
||||
<input class="event_time" type="datetime-local" id="meeting-time"
|
||||
|
||||
@ -1,12 +1,22 @@
|
||||
from party.chat import Chat
|
||||
from faker import Faker
|
||||
import pymongo
|
||||
|
||||
fake = Faker()
|
||||
|
||||
Chat.init()
|
||||
def get_connection():
|
||||
CONNECTION_STRING = 'mongodb://localhost:27017/'
|
||||
client = pymongo.MongoClient(CONNECTION_STRING)
|
||||
return client['partyyy']['messages']
|
||||
|
||||
connection = get_connection()
|
||||
|
||||
def generate_message():
|
||||
Chat.insertMessage(fake.text(), fake.name(), fake.date_time().isoformat())
|
||||
message = {
|
||||
'sender': fake.name(),
|
||||
'text': fake.sentence() * 2,
|
||||
'timestamp': fake.date_time_this_year()
|
||||
}
|
||||
connection.insert_one(message)
|
||||
|
||||
MESSAGE_COUNT = 1000
|
||||
for i in range(MESSAGE_COUNT):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user