@@ -4,7 +4,6 @@
|
||||
{% from "settings/tabs/company_info.html" import company_info_tab %}
|
||||
{% from "settings/tabs/security.html" import security_tab %}
|
||||
{% from "settings/tabs/debugging.html" import debugging_tab %}
|
||||
{% from "settings/tabs/events.html" import events_tab %}
|
||||
{% from "settings/components/reset_colors_modal.html" import reset_colors_modal %}
|
||||
|
||||
{% block title %}Settings - DocuPulse{% endblock %}
|
||||
@@ -37,11 +36,6 @@
|
||||
<i class="fas fa-building me-2"></i>Company Info
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link {% if active_tab == 'events' %}active{% endif %}" id="events-tab" data-bs-toggle="tab" data-bs-target="#events" type="button" role="tab" aria-controls="events" aria-selected="{{ 'true' if active_tab == 'events' else 'false' }}">
|
||||
<i class="fas fa-history me-2"></i>Event Log
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link {% if active_tab == 'security' %}active{% endif %}" id="security-tab" data-bs-toggle="tab" data-bs-target="#security" type="button" role="tab" aria-controls="security" aria-selected="{{ 'true' if active_tab == 'security' else 'false' }}">
|
||||
<i class="fas fa-shield-alt me-2"></i>Security
|
||||
@@ -66,11 +60,6 @@
|
||||
{{ company_info_tab(site_settings, csrf_token) }}
|
||||
</div>
|
||||
|
||||
<!-- Events Tab -->
|
||||
<div class="tab-pane fade {% if active_tab == 'events' %}show active{% endif %}" id="events" role="tabpanel" aria-labelledby="events-tab">
|
||||
{{ events_tab(events, csrf_token) }}
|
||||
</div>
|
||||
|
||||
<!-- Security Tab -->
|
||||
<div class="tab-pane fade {% if active_tab == 'security' %}show active{% endif %}" id="security" role="tabpanel" aria-labelledby="security-tab">
|
||||
{{ security_tab() }}
|
||||
@@ -91,6 +80,5 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/settings.js', v=config.JS_VERSION) }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/events.js', v=config.JS_VERSION) }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/settings.js', v=config.CSS_VERSION) }}"></script>
|
||||
{% endblock %}
|
||||
@@ -1,165 +0,0 @@
|
||||
{% macro events_tab(events, csrf_token) %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h5 class="card-title mb-0">Event Log</h5>
|
||||
<div class="d-flex gap-2">
|
||||
<select id="eventTypeFilter" class="form-select form-select-sm">
|
||||
<option value="">All Event Types</option>
|
||||
<option value="user_login">User Login</option>
|
||||
<option value="user_logout">User Logout</option>
|
||||
<option value="user_register">User Registration</option>
|
||||
<option value="user_update">User Update</option>
|
||||
<option value="file_upload">File Upload</option>
|
||||
<option value="file_delete">File Delete</option>
|
||||
<option value="file_download">File Download</option>
|
||||
<option value="file_restore">File Restore</option>
|
||||
<option value="file_move">File Move</option>
|
||||
<option value="file_rename">File Rename</option>
|
||||
<option value="file_star">File Star</option>
|
||||
<option value="file_unstar">File Unstar</option>
|
||||
<option value="file_delete_permanent">File Delete Permanent</option>
|
||||
<option value="room_create">Room Create</option>
|
||||
<option value="room_delete">Room Delete</option>
|
||||
<option value="room_update">Room Update</option>
|
||||
<option value="room_open">Room Open</option>
|
||||
<option value="room_list_view">Room List View</option>
|
||||
<option value="room_search">Room Search</option>
|
||||
<option value="room_join">Room Join</option>
|
||||
<option value="room_leave">Room Leave</option>
|
||||
<option value="room_member_permissions_update">Room Member Permissions Update</option>
|
||||
<option value="conversation_create">Conversation Create</option>
|
||||
<option value="conversation_delete">Conversation Delete</option>
|
||||
<option value="message_sent">Message Sent</option>
|
||||
<option value="attachment_download">Attachment Download</option>
|
||||
</select>
|
||||
<select id="dateRangeFilter" class="form-select form-select-sm">
|
||||
<option value="24h">Last 24 Hours</option>
|
||||
<option value="7d">Last 7 Days</option>
|
||||
<option value="30d">Last 30 Days</option>
|
||||
<option value="all">All Time</option>
|
||||
</select>
|
||||
<select id="userFilter" class="form-select form-select-sm">
|
||||
<option value="">All Users</option>
|
||||
</select>
|
||||
<button id="applyFilters" class="btn btn-primary btn-sm">Apply Filters</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Event Type</th>
|
||||
<th>User</th>
|
||||
<th>Details</th>
|
||||
<th>IP Address</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="eventsTableBody">
|
||||
{% for event in events %}
|
||||
<tr>
|
||||
<td>{{ event.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}</td>
|
||||
<td>
|
||||
{% if event.event_type == 'user_login' %}
|
||||
<span class="badge bg-success">User Login</span>
|
||||
{% elif event.event_type == 'user_logout' %}
|
||||
<span class="badge bg-secondary">User Logout</span>
|
||||
{% elif event.event_type == 'user_register' %}
|
||||
<span class="badge bg-info">User Registration</span>
|
||||
{% elif event.event_type == 'user_update' %}
|
||||
<span class="badge bg-primary">User Update</span>
|
||||
{% elif event.event_type == 'file_upload' %}
|
||||
<span class="badge bg-success">File Upload</span>
|
||||
{% elif event.event_type == 'file_delete' %}
|
||||
<span class="badge bg-danger">File Delete</span>
|
||||
{% elif event.event_type == 'file_download' %}
|
||||
<span class="badge bg-info">File Download</span>
|
||||
{% elif event.event_type == 'file_restore' %}
|
||||
<span class="badge bg-warning">File Restore</span>
|
||||
{% elif event.event_type == 'file_move' %}
|
||||
<span class="badge bg-primary">File Move</span>
|
||||
{% elif event.event_type == 'file_rename' %}
|
||||
<span class="badge bg-info">File Rename</span>
|
||||
{% elif event.event_type == 'file_star' %}
|
||||
<span class="badge bg-warning">File Star</span>
|
||||
{% elif event.event_type == 'file_unstar' %}
|
||||
<span class="badge bg-secondary">File Unstar</span>
|
||||
{% elif event.event_type == 'file_delete_permanent' %}
|
||||
<span class="badge bg-danger">File Delete Permanent</span>
|
||||
{% elif event.event_type == 'room_create' %}
|
||||
<span class="badge bg-success">Room Create</span>
|
||||
{% elif event.event_type == 'room_delete' %}
|
||||
<span class="badge bg-danger">Room Delete</span>
|
||||
{% elif event.event_type == 'room_update' %}
|
||||
<span class="badge bg-primary">Room Update</span>
|
||||
{% elif event.event_type == 'room_open' %}
|
||||
<span class="badge bg-info">Room Open</span>
|
||||
{% elif event.event_type == 'room_list_view' %}
|
||||
<span class="badge bg-secondary">Room List View</span>
|
||||
{% elif event.event_type == 'room_search' %}
|
||||
<span class="badge bg-info">Room Search</span>
|
||||
{% elif event.event_type == 'room_join' %}
|
||||
<span class="badge bg-info">Room Join</span>
|
||||
{% elif event.event_type == 'room_leave' %}
|
||||
<span class="badge bg-secondary">Room Leave</span>
|
||||
{% elif event.event_type == 'room_member_permissions_update' %}
|
||||
<span class="badge bg-primary">Room Member Permissions Update</span>
|
||||
{% elif event.event_type == 'conversation_create' %}
|
||||
<span class="badge bg-success">Conversation Create</span>
|
||||
{% elif event.event_type == 'conversation_delete' %}
|
||||
<span class="badge bg-danger">Conversation Delete</span>
|
||||
{% elif event.event_type == 'message_sent' %}
|
||||
<span class="badge bg-primary">Message Sent</span>
|
||||
{% elif event.event_type == 'attachment_download' %}
|
||||
<span class="badge bg-info">Attachment Download</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ event.event_type }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ event.user.username }} {% if event.user.last_name %}{{ event.user.last_name }}{% endif %}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#eventDetailsModal"
|
||||
data-event-id="{{ event.id }}">
|
||||
<i class="fas fa-info-circle"></i> View Details
|
||||
</button>
|
||||
</td>
|
||||
<td>{{ event.ip_address or '-' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||
<div>
|
||||
<button id="prevPage" class="btn btn-outline-primary btn-sm">Previous</button>
|
||||
<span class="mx-2">Page <span id="currentPage">1</span> of <span id="totalPages">1</span></span>
|
||||
<button id="nextPage" class="btn btn-outline-primary btn-sm">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Event Details Modal -->
|
||||
<div class="modal fade" id="eventDetailsModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Event Details</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre id="eventDetailsContent" class="bg-light p-3 rounded"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/events.js', v=config.JS_VERSION) }}"></script>
|
||||
{% endblock %}
|
||||
@@ -43,93 +43,4 @@
|
||||
{% 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/starred.js', v=config.CSS_VERSION) }}"></script>
|
||||
<script>
|
||||
// Add event logging for starred actions
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Log when starred page is viewed
|
||||
fetch('/api/events/log', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
event_type: 'starred_view',
|
||||
details: {
|
||||
user_id: '{{ current_user.id }}',
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Log when view is toggled
|
||||
const gridViewBtn = document.getElementById('gridViewBtn');
|
||||
const listViewBtn = document.getElementById('listViewBtn');
|
||||
|
||||
if (gridViewBtn && listViewBtn) {
|
||||
gridViewBtn.addEventListener('click', function() {
|
||||
logViewChange('grid');
|
||||
});
|
||||
|
||||
listViewBtn.addEventListener('click', function() {
|
||||
logViewChange('list');
|
||||
});
|
||||
}
|
||||
|
||||
function logViewChange(viewType) {
|
||||
fetch('/api/events/log', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
event_type: 'starred_view_change',
|
||||
details: {
|
||||
user_id: '{{ current_user.id }}',
|
||||
view_type: viewType,
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Log when search is performed
|
||||
const searchInput = document.querySelector('.search-input');
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', debounce(function(e) {
|
||||
if (e.target.value.length > 0) {
|
||||
fetch('/api/events/log', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
event_type: 'starred_search',
|
||||
details: {
|
||||
user_id: '{{ current_user.id }}',
|
||||
search_term: e.target.value,
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}, 500));
|
||||
}
|
||||
|
||||
// Debounce function to limit API calls
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function executedFunction(...args) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -49,66 +49,4 @@
|
||||
{% 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