diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index 249de6a..b122c38 100644 Binary files a/routes/__pycache__/main.cpython-313.pyc and b/routes/__pycache__/main.cpython-313.pyc differ diff --git a/routes/main.py b/routes/main.py index 2f426f8..328db53 100644 --- a/routes/main.py +++ b/routes/main.py @@ -45,6 +45,12 @@ def init_routes(main_bp): active_count = User.query.filter_by(is_active=True).count() inactive_count = User.query.filter_by(is_active=False).count() + # Get recent events (last 7) + if current_user.is_admin: + recent_events = Event.query.order_by(Event.timestamp.desc()).limit(7).all() + else: + recent_events = Event.query.filter_by(user_id=current_user.id).order_by(Event.timestamp.desc()).limit(7).all() + # Room count and size logic if current_user.is_admin: logger.info("Loading admin dashboard...") @@ -261,7 +267,9 @@ def init_routes(main_bp): oldest_trash_date=oldest_trash_date, trash_size=trash_size, pending_deletion=pending_deletion, - trash_by_type=trash_by_type) + trash_by_type=trash_by_type, + recent_events=recent_events, + is_admin=current_user.is_admin) UPLOAD_FOLDER = os.path.join(os.getcwd(), 'uploads', 'profile_pics') if not os.path.exists(UPLOAD_FOLDER): diff --git a/templates/components/recent_activity.html b/templates/components/recent_activity.html index bbb32e3..94ceb3e 100644 --- a/templates/components/recent_activity.html +++ b/templates/components/recent_activity.html @@ -1,58 +1,71 @@ -{% macro recent_activity(activities) %} +{% macro recent_activity(events, is_admin=False) %}
-
-
-
-
Recent Activity
- View All -
-
+
+
+
+ + {% if is_admin %}Recent Activity{% else %}Your Recent Actions{% endif %} +
+ {% if is_admin %} + View All + {% endif %} +
+ + {% if events %}
- {% for activity in activities %} -
-
-
- {% if activity.type == 'folder' %} - - {% else %} - - {% endif %} -
-
-
-
-
-
{{ activity.name }}
- {% if activity.is_starred %} - - Starred - - {% endif %} - {% if activity.is_deleted %} - - Trash - - {% endif %} -
- - {{ activity.room.name }} • - {{ activity.uploader.username }} {{ activity.uploader.last_name }} • - {% if activity.uploaded_at %}{{ activity.uploaded_at|timeago }}{% else %}Unknown{% endif %} - + {% for event in events %} +
+
+
+
+
+ {% 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 %}
- {% if activity.type == 'file' and activity.can_download %} - - - - {% endif %} + + {% if is_admin %} + by {{ event.user.username }} + {% endif %} + {{ event.timestamp.strftime('%Y-%m-%d %H:%M') }} +
+ + {% if event.details.get('room_id') %} + + + + {% endif %}
{% endfor %}
+ {% else %} +
+ +

No recent activity

+
+ {% endif %}
diff --git a/templates/components/storage_overview.html b/templates/components/storage_overview.html index 07aabf4..549f8ec 100644 --- a/templates/components/storage_overview.html +++ b/templates/components/storage_overview.html @@ -5,7 +5,7 @@
-
Storage Overview
+
Room Storage Overview
Browse
diff --git a/templates/components/trash.html b/templates/components/trash.html index c68fd69..77943da 100644 --- a/templates/components/trash.html +++ b/templates/components/trash.html @@ -5,7 +5,7 @@
-
Trash
+
Trash Storage Overview
View All
diff --git a/templates/dashboard/dashboard.html b/templates/dashboard/dashboard.html index e0e9dbd..d8ee6e7 100644 --- a/templates/dashboard/dashboard.html +++ b/templates/dashboard/dashboard.html @@ -23,6 +23,7 @@ {% from 'components/starred_files.html' import starred_files %} {% from 'components/trash.html' import trash %} {% from 'components/trash_type.html' import trash_type %} +{% from 'components/recent_activity.html' import recent_activity %}