Files
docupulse/templates/components/recent_activity.html
2025-06-02 14:36:34 +02:00

72 lines
3.5 KiB
HTML

{% macro recent_activity(events, is_admin=False) %}
<div class="masonry-card">
<div class="card shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h5 class="card-title mb-0">
<i class="fas fa-history me-2"></i>
{% if is_admin %}Recent Activity{% else %}Your Recent Actions{% endif %}
</h5>
{% if is_admin %}
<a href="{{ url_for('main.settings', tab='events', page=1, event_type='', date_range='24h', user_id='') }}" class="btn btn-primary btn-sm" onclick="localStorage.setItem('settingsActiveTab', 'events')">View All</a>
{% endif %}
</div>
{% if events %}
<div class="list-group list-group-flush">
{% for event in events %}
<div class="list-group-item px-0">
<div class="d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center">
<div>
<div class="fw-bold text-primary">
{% if event.event_type == 'file_upload' %}
Uploaded {{ event.details.get('file_name', 'a file') }}
{% elif event.event_type == 'file_download' %}
Downloaded {{ event.details.get('file_name', 'a file') }}
{% elif event.event_type == 'file_delete' %}
Deleted {{ event.details.get('file_name', 'a file') }}
{% elif event.event_type == 'file_star' %}
Starred {{ event.details.get('file_name', 'a file') }}
{% elif event.event_type == 'file_unstar' %}
Unstarred {{ event.details.get('file_name', 'a file') }}
{% elif event.event_type == 'room_create' %}
Created room "{{ event.details.get('room_name', 'a room') }}"
{% elif event.event_type == 'room_update' %}
Updated room "{{ event.details.get('room_name', 'a room') }}"
{% elif event.event_type == 'conversation_create' %}
Started a conversation
{% elif event.event_type == 'message_create' %}
Sent a message
{% else %}
{{ event.event_type|replace('_', ' ')|title }}
{% endif %}
</div>
<small class="text-muted">
{% if is_admin %}
by {{ event.user.username }}
{% endif %}
{{ event.timestamp.strftime('%Y-%m-%d %H:%M') }}
</small>
</div>
</div>
{% if event.details.get('room_id') %}
<a href="{{ url_for('rooms.room', room_id=event.details.get('room_id')) }}" class="btn btn-sm btn-outline-primary" style="background-color: white; border: 1px solid var(--primary-color); color: var(--primary-color);" onmouseover="this.style.backgroundColor='var(--primary-color)'; this.querySelector('i').style.color='white'" onmouseout="this.style.backgroundColor='white'; this.querySelector('i').style.color='var(--primary-color)'">
<i class="fas fa-external-link-alt"></i>
</a>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center text-muted py-3">
<i class="fas fa-info-circle mb-2"></i>
<p class="mb-0">No recent activity</p>
</div>
{% endif %}
</div>
</div>
</div>
{% endmacro %}