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

@@ -354,24 +354,6 @@ function toggleStar(filename, path = '', roomId) {
.then(r => r.json())
.then(res => {
if (res.success) {
// Log the star/unstar event
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
event_type: res.starred ? 'file_star' : 'file_unstar',
details: {
filename: filename,
path: path,
room_id: roomId,
timestamp: new Date().toISOString()
}
})
});
// Remove the file from the current view since it's no longer starred
currentFiles = currentFiles.filter(f => !(f.name === filename && f.path === path && f.room_id === roomId));
renderFiles(currentFiles);
@@ -412,24 +394,6 @@ function restoreFile(filename, path = '', roomId) {
.then(r => r.json())
.then(res => {
if (res.success) {
// Log the restore event
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
event_type: 'file_restore',
details: {
filename: filename,
path: path,
room_id: roomId,
timestamp: new Date().toISOString()
}
})
});
// Remove the file from the current view since it's been restored
currentFiles = currentFiles.filter(f => !(f.name === filename && f.path === path && f.room_id === roomId));
renderFiles(currentFiles);
@@ -470,7 +434,7 @@ function permanentDeleteFile() {
return;
}
fetch(`/api/rooms/${roomId}/delete_permanent`, {
fetch(`/api/rooms/${roomId}/delete-permanent`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -481,40 +445,39 @@ function permanentDeleteFile() {
path: path
})
})
.then(r => r.json())
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Check if the response is empty
const contentType = response.headers.get('content-type');
if (contentType && contentType.includes('application/json')) {
return response.json();
}
return { success: true }; // If no JSON response, assume success
})
.then(res => {
if (res.success) {
// Log the permanent delete event
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
event_type: 'file_delete_permanent',
details: {
filename: filename,
path: path,
room_id: roomId,
timestamp: new Date().toISOString()
}
})
});
// Remove the file from the current view
// Remove the file from the current view since it's been deleted
currentFiles = currentFiles.filter(f => !(f.name === filename && f.path === path && f.room_id === roomId));
renderFiles(currentFiles);
// Close the modal
const modal = bootstrap.Modal.getInstance(document.getElementById('permanentDeleteModal'));
modal.hide();
if (modal) {
modal.hide();
}
} else {
console.error('Failed to delete file permanently:', res.error);
console.error('Failed to delete file:', res.error || 'Unknown error');
}
})
.catch(error => {
console.error('Error deleting file permanently:', error);
console.error('Error deleting file:', error);
// Show error to user
const modal = bootstrap.Modal.getInstance(document.getElementById('permanentDeleteModal'));
if (modal) {
modal.hide();
}
// You might want to show an error message to the user here
});
}