Added events system

This commit is contained in:
2025-05-29 14:27:15 +02:00
parent 3174f8fa5b
commit f00d569db3
24 changed files with 1186 additions and 114 deletions

View File

@@ -49,4 +49,66 @@
{% block extra_js %}
<script src="{{ url_for('static', filename='js/file-grid.js', v=config.CSS_VERSION) }}"></script>
<script src="{{ url_for('static', filename='js/trash.js', v=config.CSS_VERSION) }}"></script>
<script>
// Add event logging for trash actions
document.addEventListener('DOMContentLoaded', function() {
// Log when trash page is viewed
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': '{{ csrf_token }}'
},
body: JSON.stringify({
event_type: 'trash_view',
details: {
user_id: '{{ current_user.id }}',
timestamp: new Date().toISOString()
}
})
});
// Log when empty trash is clicked
const emptyTrashBtn = document.querySelector('.header-button');
if (emptyTrashBtn) {
emptyTrashBtn.addEventListener('click', function() {
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': '{{ csrf_token }}'
},
body: JSON.stringify({
event_type: 'trash_empty_click',
details: {
user_id: '{{ current_user.id }}',
timestamp: new Date().toISOString()
}
})
});
});
}
// Log when trash is actually emptied
const confirmEmptyTrashBtn = document.getElementById('confirmEmptyTrash');
if (confirmEmptyTrashBtn) {
confirmEmptyTrashBtn.addEventListener('click', function() {
fetch('/api/events/log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': '{{ csrf_token }}'
},
body: JSON.stringify({
event_type: 'trash_emptied',
details: {
user_id: '{{ current_user.id }}',
timestamp: new Date().toISOString()
}
})
});
});
}
});
</script>
{% endblock %}