Message sent history

This commit is contained in:
Eduardo Silva 2024-04-25 10:32:21 -03:00
parent 2edae835ad
commit 33a959b95d
8 changed files with 91 additions and 15 deletions

View file

@ -10,6 +10,7 @@ from backup_data.models import RouterBackup
from message_center.functions import notify_backup_fail
from router_manager.models import Router, BackupSchedule, RouterStatus
from routerlib.backup_functions import perform_backup
from message_center.models import Message
def next_weekday(now, weekday, hour):
@ -242,7 +243,8 @@ def view_housekeeping(requests):
max_backup_task_age = timezone.now() - timedelta(hours=18)
data = {
'backup_tasks_expired': 0,
'backup_locks_removed': 0
'backup_locks_removed': 0,
'messages_removed': 0,
}
for backup in RouterBackup.objects.filter(created__lt=max_backup_task_age, success=False, error=False):
backup.error = True
@ -278,4 +280,8 @@ def view_housekeeping(requests):
backup_list.filter(schedule_type='weekly', created__lt=timezone.now() - timedelta(days=backup_profile.weekly_retention)).delete()
backup_list.filter(schedule_type='daily', created__lt=timezone.now() - timedelta(days=backup_profile.daily_retention)).delete()
expired_messages = Message.objects.filter(created__lt=timezone.now() - timedelta(days=30))
data['messages_removed'] = expired_messages.count()
expired_messages.delete()
return JsonResponse(data)

View file

@ -186,6 +186,19 @@ def view_message_channel_list(request):
return render(request, 'message_center/message_channel_list.html', context=context)
@login_required()
def view_message_history(request):
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=20).exists():
return render(request, 'access_denied.html', {'page_title': 'Access Denied'})
message_settings, _ = MessageSettings.objects.get_or_create(name='message_settings')
message_list = Message.objects.all().order_by('-created')
context = {
'message_settings': message_settings,
'message_list': message_list,
}
return render(request, 'message_center/message_history.html', context=context)
@login_required()
def view_manage_message_settings(request):
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=40).exists():

View file

@ -141,6 +141,6 @@ STATICFILES_DIRS = [
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_ROOT = '/var/lib/routerfleet/'
ROUTERFLEET_VERSION = 7017
ROUTERFLEET_VERSION = 7019
from routerfleet.production_settings import *

View file

@ -9,7 +9,7 @@ from backup.views import view_backup_profile_list, view_manage_backup_profile, v
from monitoring.views import view_export_router_list, view_update_router_status, view_router_config_timestamp, view_router_last_status_change
from backup_data.views import view_generate_backup_schedule, view_create_backup_tasks, view_perform_backup_tasks, view_housekeeping
from routerfleet_tools.views import cron_check_updates
from message_center.views import view_message_channel_list, view_manage_message_settings, view_manage_message_channel, view_debug_test_messages, view_cron_concatenate_notifications, view_cron_send_messages, view_cron_daily_reports
from message_center.views import view_message_channel_list, view_manage_message_settings, view_manage_message_channel, view_debug_test_messages, view_cron_concatenate_notifications, view_cron_send_messages, view_cron_daily_reports, view_message_history
urlpatterns = [
@ -57,4 +57,5 @@ urlpatterns = [
path('message_center/channel_list/', view_message_channel_list, name='message_channel_list'),
path('message_center/manage_settings/', view_manage_message_settings, name='manage_message_settings'),
path('message_center/manage_channel/', view_manage_message_channel, name='manage_message_channel'),
path('message_center/message_history/', view_message_history, name='message_history'),
]

View file

@ -11,16 +11,9 @@
<div class="card-body row">
<div class="col-lg-12">
<p>Greetings! I'm thrilled to introduce you to RouterFleet, a newly launched open source project aimed at revolutionizing the way we manage backups for routers and network equipment. I've dedicated countless hours to developing a system that simplifies and secures network management tasks, specifically tailored for those who manage a fleet of devices.</p>
<p>At this initial stage, RouterFleet's compatibility is focused on <strong>Mikrotik devices</strong>. My commitment to you is to not only enhance the system for these devices but also to expand our compatibility list based on the community's needs. Your feedback and requests are crucial for guiding the future development of RouterFleet.</p>
<p>Being at the forefront of RouterFleet, I am on a continuous journey to improve and evolve the platform. You can expect <strong>regular updates featuring new functionalities, performance enhancements, and bug fixes</strong>. To make the most out of RouterFleet, I recommend keeping your system up to date with the latest releases.</p>
<p>As RouterFleet is an open source project, I warmly invite you to join the journey—whether it's through contributing code, providing feedback, or sharing your network management experiences. Every bit of support helps in building a robust community around RouterFleet. For more information, updates, and to get involved, please visit our <a href="https://github.com/eduardogsilva/routerfleet" target="_blank"><i class="fab fa-github"></i> GitHub page</a>.</p>
<p>Your support and involvement are what will shape the future of RouterFleet!</p>
<p>Hello! Welcome to RouterFleet, an open source project designed to simplify router backups. We currently support <strong>Mikrotik and OpenWRT</strong> devices, and we're excited to expand this list soon.</p>
<p>If you have a specific device you would like supported or suggestions for improvement, please visit our <a href="https://github.com/eduardogsilva/routerfleet" target="_blank"><i class="fab fa-github"></i> GitHub page</a> to share your thoughts. Your contributions help us enhance and evolve RouterFleet for all users.</p>
<p>Thank you for your support and involvement in making RouterFleet better for everyone!</p>
</div>
</div>
</div>

View file

@ -0,0 +1,12 @@
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link {% if request.path == '/message_center/channel_list/' %}active{% endif %}" href="/message_center/channel_list/" role="tab">
Channel List
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.path == '/message_center/message_history/' %}active{% endif %}" href="/message_center/message_history/" role="tab">
Message History
</a>
</li>
</ul>

View file

@ -9,7 +9,9 @@
<h3 class="card-title">Notification Channels</h3>
</div>
<div class="card-body row">
<div class="card-body">
{% include 'message_center/message_center_nav_tabs.html' %}
<div class="row">
<div class="col-lg-12">
<table class="table table-hover datatables-no-export">
<thead>
@ -88,12 +90,14 @@
</div>
</div>
<div class="row">
<div class="col-lg-12">
<a href="/message_center/manage_channel/" class="btn btn-primary">Create Channel</a>
<a href="/message_center/manage_settings/" class="btn btn-primary">Message Settings</a>
</div>
</div>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,47 @@
{% extends 'base.html' %}
{% block content %}
<div class='row'>
<div class='col-lg-12'>
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">Message History</h3>
</div>
<div class="card-body">
{% include 'message_center/message_center_nav_tabs.html' %}
<div class="row">
<div class="col-lg-12">
<table class="table table-hover datatables-no-export">
<thead>
<tr>
<th>Channel</th>
<th>Status</th>
<th>Subject</th>
<th>Error</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{% for message in message_list %}
<tr>
<td>{{ message.channel }}</td>
<td>{{ message.get_status_display }}</td>
<td><u title="{{ message.message }}">{{ message.subject }}</u></td>
<td>
{% if message.error_message %}
<u title="{{ message.error_message }}">Error code: {{ message.error_status_code|default_if_none:"" }}</u>
{% endif %}
</td>
<td>{{ message.created }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<p class="small" style="text-align: right; font-style: italic">Showing messages sent in the last 30 days. Older messages are automatically removed.</p>
</div>
</div>
{% endblock %}