Files
orion/app/templates/admin/settings.html
Samir Boulahtit 6d6c8b44d3 feat: add Notifications tab to Platform Settings
- Add Notifications tab to Settings > General page
- Include email, in-app, and critical-only notification toggles
- Add link to full Notifications page in Platform Monitoring
- Add notificationSettings state and saveNotificationSettings method

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 22:02:46 +01:00

270 lines
15 KiB
HTML

{# app/templates/admin/settings.html #}
{% extends "admin/base.html" %}
{% from 'shared/macros/alerts.html' import alert_dynamic, error_state %}
{% from 'shared/macros/headers.html' import page_header_refresh %}
{% from 'shared/macros/tabs.html' import tabs_nav, tab_button %}
{% from 'shared/macros/inputs.html' import number_stepper %}
{% block title %}Platform Settings{% endblock %}
{% block alpine_data %}adminSettings(){% endblock %}
{% block content %}
{{ page_header_refresh('Platform Settings') }}
{{ alert_dynamic(type='success', title='Success', message_var='successMessage', show_condition='successMessage') }}
{{ error_state('Error', show_condition='error') }}
<!-- Settings Categories Tabs -->
{% call tabs_nav() %}
{{ tab_button('logging', 'Logging', icon='document-text') }}
{{ tab_button('system', 'System', icon='cog') }}
{{ tab_button('security', 'Security', icon='shield-check') }}
{{ tab_button('notifications', 'Notifications', icon='bell') }}
{% endcall %}
<!-- Logging Settings Tab -->
<div x-show="activeTab === 'logging'" x-transition>
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200 mb-4">
Logging Configuration
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-6">
Configure application logging behavior, file rotation, and retention policies.
</p>
<!-- Log Level -->
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Log Level
</label>
<select
x-model="logSettings.log_level"
class="block w-full md:w-1/2 px-3 py-2 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-600"
>
<option value="DEBUG">DEBUG - Detailed information for diagnosing problems</option>
<option value="INFO">INFO - General informational messages</option>
<option value="WARNING">WARNING - Warning messages</option>
<option value="ERROR">ERROR - Error messages</option>
<option value="CRITICAL">CRITICAL - Critical errors only</option>
</select>
<p class="mt-2 text-xs text-gray-500 dark:text-gray-400">
Changes take effect immediately without restart.
</p>
</div>
<!-- File Rotation Settings -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Max File Size (MB)
</label>
{{ number_stepper(model='logSettings.log_file_max_size_mb', min=1, max=1000, step=10, label='Max File Size') }}
<p class="mt-2 text-xs text-gray-500 dark:text-gray-400">
Log file will rotate when it reaches this size.
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Backup File Count
</label>
{{ number_stepper(model='logSettings.log_file_backup_count', min=0, max=50, step=1, label='Backup File Count') }}
<p class="mt-2 text-xs text-gray-500 dark:text-gray-400">
Number of rotated backup files to keep.
</p>
</div>
</div>
<!-- Database Retention -->
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Database Log Retention (Days)
</label>
{{ number_stepper(model='logSettings.db_log_retention_days', min=1, max=365, step=7, label='Retention Days') }}
<p class="mt-2 text-xs text-gray-500 dark:text-gray-400">
Logs older than this will be automatically deleted from database.
</p>
</div>
<!-- Logging Toggles -->
<div class="space-y-4 mb-6">
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div>
<p class="font-medium text-gray-700 dark:text-gray-200">File Logging</p>
<p class="text-sm text-gray-500 dark:text-gray-400">Write logs to rotating files on disk</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" x-model="logSettings.file_logging_enabled" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div>
</label>
</div>
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div>
<p class="font-medium text-gray-700 dark:text-gray-200">Database Logging</p>
<p class="text-sm text-gray-500 dark:text-gray-400">Store WARNING/ERROR/CRITICAL logs in database for searching</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" x-model="logSettings.db_logging_enabled" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div>
</label>
</div>
</div>
<!-- Save Button -->
<div class="flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700">
<p class="text-sm text-gray-600 dark:text-gray-400">
<span x-html="$icon('information-circle', 'inline w-4 h-4 mr-1')"></span>
File rotation settings require application restart to take effect.
</p>
<button
@click="saveLogSettings()"
:disabled="saving"
class="px-6 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple disabled:opacity-50 disabled:cursor-not-allowed"
>
<span x-show="!saving">Save Logging Settings</span>
<span x-show="saving">Saving...</span>
</button>
</div>
</div>
<!-- Quick Actions -->
<div class="mt-8">
<div class="mb-8 p-6 bg-white rounded-lg shadow-xs dark:bg-gray-800">
<h4 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">
Quick Actions
</h4>
<div class="flex flex-wrap gap-3">
<a
href="/admin/logs"
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
>
<span x-html="$icon('document-text', 'w-4 h-4 mr-2')"></span>
View Logs
</a>
<button
@click="cleanupOldLogs()"
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:shadow-outline-gray"
>
<span x-html="$icon('delete', 'w-4 h-4 mr-2')"></span>
Cleanup Old Logs
</button>
</div>
</div>
</div>
</div>
<!-- System Settings Tab -->
<div x-show="activeTab === 'system'" x-transition>
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200 mb-4">
System Configuration
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-6">
General system settings and configuration options.
</p>
<div class="text-center py-12 text-gray-500 dark:text-gray-400">
<span x-html="$icon('cog', 'inline w-12 h-12 mb-4')"></span>
<p>System settings coming soon...</p>
</div>
</div>
</div>
<!-- Security Settings Tab -->
<div x-show="activeTab === 'security'" x-transition>
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200 mb-4">
Security Configuration
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-6">
Security and authentication settings.
</p>
<div class="text-center py-12 text-gray-500 dark:text-gray-400">
<span x-html="$icon('shield-check', 'inline w-12 h-12 mb-4')"></span>
<p>Security settings coming soon...</p>
</div>
</div>
</div>
<!-- Notifications Settings Tab -->
<div x-show="activeTab === 'notifications'" x-transition>
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200 mb-4">
Notification Settings
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-6">
Configure platform notification preferences and delivery channels.
</p>
<!-- Quick Link to Full Notifications Page -->
<div class="mb-6 p-4 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg">
<div class="flex items-start">
<span x-html="$icon('information-circle', 'w-5 h-5 text-purple-600 dark:text-purple-400 mt-0.5 mr-3 flex-shrink-0')"></span>
<div>
<p class="text-sm text-purple-800 dark:text-purple-200">
For detailed notification management including templates and delivery logs, visit the full
<a href="/admin/notifications-settings" class="font-medium underline hover:text-purple-600">Notifications page</a>
in Platform Monitoring.
</p>
</div>
</div>
</div>
<!-- Email Notifications Toggle -->
<div class="space-y-4 mb-6">
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div>
<p class="font-medium text-gray-700 dark:text-gray-200">Email Notifications</p>
<p class="text-sm text-gray-500 dark:text-gray-400">Send notification emails for important events</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" x-model="notificationSettings.email_enabled" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div>
</label>
</div>
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div>
<p class="font-medium text-gray-700 dark:text-gray-200">In-App Notifications</p>
<p class="text-sm text-gray-500 dark:text-gray-400">Show notifications in the admin interface</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" x-model="notificationSettings.in_app_enabled" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div>
</label>
</div>
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div>
<p class="font-medium text-gray-700 dark:text-gray-200">Critical Alerts Only</p>
<p class="text-sm text-gray-500 dark:text-gray-400">Only receive notifications for critical system events</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" x-model="notificationSettings.critical_only" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div>
</label>
</div>
</div>
<!-- Save Button -->
<div class="flex items-center justify-end pt-4 border-t border-gray-200 dark:border-gray-700">
<button
@click="saveNotificationSettings()"
:disabled="saving"
class="px-6 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple disabled:opacity-50 disabled:cursor-not-allowed"
>
<span x-show="!saving">Save Notification Settings</span>
<span x-show="saving">Saving...</span>
</button>
</div>
</div>
</div>
{% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('static', path='admin/js/settings.js') }}"></script>
{% endblock %}