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

100 lines
7.0 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('filename', 'a file') }}
{% elif event.event_type == 'file_download' %}
Downloaded {{ event.details.get('filename', 'a file') }}
{% elif event.event_type == 'file_delete' %}
Deleted {{ event.details.get('filename', 'a file') }}
{% elif event.event_type == 'file_star' %}
Starred {{ event.details.get('filename', 'a file') }}
{% elif event.event_type == 'file_unstar' %}
Unstarred {{ event.details.get('filename', 'a file') }}
{% elif event.event_type == 'file_move' %}
Moved {{ event.details.get('filename', 'a file') }}
{% elif event.event_type == 'file_rename' %}
Renamed {{ event.details.get('old_name', 'a file') }} to {{ event.details.get('new_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 == 'room_member_add' %}
Added {{ event.details.get('added_user_name', 'a user') }} {{ event.details.get('added_user_last_name', '') }} to room "{{ event.details.get('room_name', 'a room') }}"
{% elif event.event_type == 'room_member_remove' %}
Removed {{ event.details.get('removed_user_name', 'a user') }} {{ event.details.get('removed_user_last_name', '') }} from room "{{ event.details.get('room_name', 'a room') }}"
{% elif event.event_type == 'conversation_create' %}
Started conversation "{{ event.details.get('name', 'a conversation') }}"
{% elif event.event_type == 'conversation_open' %}
Opened conversation "{{ event.details.get('conversation_name', 'a conversation') }}"
{% elif event.event_type == 'conversation_update' %}
Updated conversation "{{ event.details.get('conversation_name', 'a conversation') }}"
{% elif event.event_type == 'conversation_member_add' %}
Added {{ event.details.get('added_user_name', 'a user') }} {{ event.details.get('added_user_last_name', '') }} to conversation "{{ event.details.get('conversation_name', 'a conversation') }}"
{% elif event.event_type == 'conversation_member_remove' %}
Removed {{ event.details.get('removed_user_name', 'a user') }} {{ event.details.get('removed_user_last_name', '') }} from conversation "{{ event.details.get('conversation_name', 'a conversation') }}"
{% elif event.event_type == 'message_create' %}
Sent a message in "{{ event.details.get('conversation_name', 'a conversation') }}"
{% elif event.event_type == 'user_create' %}
Created user account for {{ event.details.get('user_name', 'a user') }} {{ event.details.get('user_last_name', '') }}
{% elif event.event_type == 'user_update' %}
Updated user account for {{ event.details.get('user_name', 'a user') }} {{ event.details.get('user_last_name', '') }}
{% else %}
{{ event.event_type|replace('_', ' ')|title }}
{% endif %}
</div>
<small class="text-muted">
{% if is_admin %}
by {{ event.user.username }} {{ event.user.last_name }}
{% 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>
{% elif event.details.get('conversation_id') %}
<a href="{{ url_for('conversations.conversation', conversation_id=event.details.get('conversation_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>
{% elif event.event_type == 'user_create' or event.event_type == 'user_update' %}
<a href="{{ url_for('contacts.edit_contact', id=event.details.get('user_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 %}