Revert "Added events system"

This reverts commit f00d569db3.
This commit is contained in:
2025-05-29 14:45:52 +02:00
parent f00d569db3
commit 6d959ac253
24 changed files with 114 additions and 1186 deletions

View File

@@ -46,137 +46,4 @@ document.addEventListener('DOMContentLoaded', function() {
form.submit();
});
}
// Log when rooms page is viewed
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_list_view',
details: {
timestamp: new Date().toISOString()
}
})
});
// Log when a room is opened
const openRoomButtons = document.querySelectorAll('a[href*="/room/"]');
openRoomButtons.forEach(button => {
button.addEventListener('click', function(e) {
const roomId = this.href.split('/room/')[1];
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_open',
details: {
room_id: roomId,
timestamp: new Date().toISOString()
}
})
});
});
});
// Log when a room is deleted
const deleteRoomForms = document.querySelectorAll('form[action*="/delete"]');
deleteRoomForms.forEach(form => {
form.addEventListener('submit', function(e) {
const roomId = this.action.split('/rooms/')[1].split('/delete')[0];
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_delete',
details: {
room_id: roomId,
timestamp: new Date().toISOString()
}
})
});
});
});
// Log when a room is created
const createRoomForm = document.querySelector('form[action*="/create"]');
if (createRoomForm) {
createRoomForm.addEventListener('submit', function(e) {
const formData = new FormData(this);
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_create',
details: {
room_name: formData.get('name'),
description: formData.get('description'),
timestamp: new Date().toISOString()
}
})
});
});
}
// Log when a room is edited
const editRoomForm = document.querySelector('form[action*="/edit"]');
if (editRoomForm) {
editRoomForm.addEventListener('submit', function(e) {
const roomId = this.action.split('/rooms/')[1].split('/edit')[0];
const formData = new FormData(this);
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_update',
details: {
room_id: roomId,
room_name: formData.get('name'),
description: formData.get('description'),
timestamp: new Date().toISOString()
}
})
});
});
}
// Log when room search is performed
if (searchInput) {
let searchTimeout;
searchInput.addEventListener('input', function(e) {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
if (this.value.length > 0) {
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
event_type: 'room_search',
details: {
search_term: this.value,
timestamp: new Date().toISOString()
}
})
});
}
}, 500);
});
}
});