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

@@ -13,95 +13,19 @@
* - Auto-save functionality for permission changes
* @function
*/
document.addEventListener('DOMContentLoaded', function() {
// Initialize Select2
$(document).ready(function() {
// Initialize Select2 for user selection
$('.select2').select2({
theme: 'bootstrap-5'
theme: 'bootstrap-5',
width: '100%',
placeholder: 'Search for a user...',
allowClear: true
});
// Log when a member is added to the room
const addMemberForm = document.querySelector('form[action*="/add_member"]');
if (addMemberForm) {
addMemberForm.addEventListener('submit', function(e) {
const formData = new FormData(this);
const userId = formData.get('user_id');
const roomId = this.action.split('/rooms/')[1].split('/add_member')[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_join',
details: {
room_id: roomId,
user_id: userId,
timestamp: new Date().toISOString()
}
})
});
});
}
// Log when a member is removed from the room
const removeMemberForms = document.querySelectorAll('form[action*="/remove_member"]');
removeMemberForms.forEach(form => {
form.addEventListener('submit', function(e) {
const roomId = this.action.split('/rooms/')[1].split('/remove_member')[0];
const userId = this.action.split('/users/')[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_leave',
details: {
room_id: roomId,
user_id: userId,
timestamp: new Date().toISOString()
}
})
});
});
});
// Log when member permissions are updated
const permissionForms = document.querySelectorAll('.auto-save-perms-form');
permissionForms.forEach(form => {
form.addEventListener('change', function(e) {
const roomId = this.action.split('/rooms/')[1].split('/update_member_permissions')[0];
const userId = this.action.split('/users/')[1];
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_member_permissions_update',
details: {
room_id: roomId,
user_id: userId,
permissions: {
can_view: formData.get('can_view') === '1',
can_download: formData.get('can_download') === 'on',
can_upload: formData.get('can_upload') === 'on',
can_delete: formData.get('can_delete') === 'on',
can_rename: formData.get('can_rename') === 'on',
can_move: formData.get('can_move') === 'on',
can_share: formData.get('can_share') === 'on'
},
timestamp: new Date().toISOString()
}
})
});
// Auto-submit permission form on checkbox change
document.querySelectorAll('.auto-save-perms-form input[type="checkbox"]').forEach(function(checkbox) {
checkbox.addEventListener('change', function() {
this.closest('form').submit();
});
});
});