Added events system
This commit is contained in:
@@ -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 %}
|
||||
Reference in New Issue
Block a user