1645 lines
52 KiB
Dart
1645 lines
52 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import '../../../../shared/design_system/unionflow_design_system.dart';
|
|
import '../../../../core/di/injection_container.dart';
|
|
import '../../../../features/authentication/presentation/bloc/auth_bloc.dart';
|
|
import '../../../../features/authentication/data/models/user_role.dart';
|
|
import '../../data/models/system_metrics_model.dart';
|
|
import '../bloc/system_settings_bloc.dart';
|
|
import '../bloc/system_settings_event.dart';
|
|
import '../bloc/system_settings_state.dart';
|
|
|
|
/// Page Paramètres Système - UnionFlow Mobile
|
|
///
|
|
/// Page complète de gestion des paramètres système avec configuration globale,
|
|
/// maintenance, monitoring, sécurité et administration avancée.
|
|
class SystemSettingsPage extends StatefulWidget {
|
|
const SystemSettingsPage({super.key});
|
|
|
|
@override
|
|
State<SystemSettingsPage> createState() => _SystemSettingsPageState();
|
|
}
|
|
|
|
class _SystemSettingsPageState extends State<SystemSettingsPage>
|
|
with TickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
|
|
// Métriques système en temps réel
|
|
SystemMetricsModel? _metrics;
|
|
|
|
// États des paramètres système
|
|
bool _maintenanceMode = false;
|
|
bool _debugMode = false;
|
|
bool _analyticsEnabled = true;
|
|
bool _crashReportingEnabled = true;
|
|
bool _autoBackupEnabled = true;
|
|
bool _sslEnforced = true;
|
|
bool _apiLoggingEnabled = false;
|
|
bool _performanceMonitoring = true;
|
|
|
|
String _selectedLogLevel = 'INFO';
|
|
String _selectedBackupFrequency = 'Quotidien';
|
|
String _selectedCacheStrategy = 'Intelligent';
|
|
|
|
final List<String> _logLevels = ['DEBUG', 'INFO', 'WARN', 'ERROR'];
|
|
final List<String> _backupFrequencies = ['Temps réel', 'Horaire', 'Quotidien', 'Hebdomadaire'];
|
|
final List<String> _cacheStrategies = ['Agressif', 'Intelligent', 'Conservateur', 'Désactivé'];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_tabController = TabController(length: 5, vsync: this);
|
|
_loadSystemSettings();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, authState) {
|
|
// Accès réservé aux super administrateurs (configuration système globale)
|
|
if (authState is! AuthAuthenticated || authState.effectiveRole != UserRole.superAdmin) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.lightBackground,
|
|
appBar: AppBar(
|
|
title: const Text('Paramètres Système'),
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
tooltip: 'Retour',
|
|
),
|
|
),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(Icons.lock_outline, size: 64, color: AppColors.textSecondaryLight.withOpacity(0.5)),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
'Accès réservé',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'Les paramètres système sont réservés aux administrateurs plateforme.',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.textSecondaryLight,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
return BlocProvider(
|
|
create: (_) => sl<SystemSettingsBloc>()
|
|
..add(LoadSystemConfig())
|
|
..add(LoadSystemMetrics()),
|
|
child: BlocConsumer<SystemSettingsBloc, SystemSettingsState>(
|
|
listener: (context, state) {
|
|
if (state is SystemMetricsLoaded) {
|
|
setState(() {
|
|
_metrics = state.metrics;
|
|
});
|
|
} else if (state is SystemSettingsSuccess) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(state.message),
|
|
backgroundColor: AppColors.success,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
} else if (state is SystemSettingsError) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(state.error),
|
|
backgroundColor: AppColors.error,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.lightBackground,
|
|
body: Column(
|
|
children: [
|
|
// Header harmonisé
|
|
_buildHeader(),
|
|
|
|
// Onglets
|
|
_buildTabBar(),
|
|
|
|
// Contenu des onglets
|
|
Expanded(
|
|
child: TabBarView(
|
|
controller: _tabController,
|
|
children: [
|
|
_buildGeneralTab(),
|
|
_buildSecurityTab(),
|
|
_buildPerformanceTab(),
|
|
_buildMaintenanceTab(),
|
|
_buildMonitoringTab(),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
/// Header harmonisé avec indicateurs système
|
|
Widget _buildHeader() {
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: SpacingTokens.sm, vertical: SpacingTokens.xs),
|
|
padding: const EdgeInsets.all(SpacingTokens.md),
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
colors: [AppColors.brandGreen, AppColors.primaryGreen],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(SpacingTokens.xl),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: AppColors.primaryGreen.withOpacity(0.3),
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 8),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.2),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.settings,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text(
|
|
'Paramètres Système',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
'Configuration globale et administration',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.white.withOpacity(0.8),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.2),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: IconButton(
|
|
onPressed: () => _showSystemStatus(),
|
|
icon: const Icon(
|
|
Icons.monitor_heart,
|
|
color: Colors.white,
|
|
),
|
|
tooltip: 'État du système',
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.2),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: IconButton(
|
|
onPressed: () => _exportSystemConfig(),
|
|
icon: const Icon(
|
|
Icons.download,
|
|
color: Colors.white,
|
|
),
|
|
tooltip: 'Exporter la configuration',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
|
|
// Indicateurs système
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: _buildSystemIndicator(
|
|
'Statut',
|
|
_metrics?.systemStatus ?? (_maintenanceMode ? 'MAINTENANCE' : 'OPERATIONAL'),
|
|
_maintenanceMode ? Icons.build : Icons.check_circle,
|
|
_maintenanceMode ? Colors.orange : Colors.green,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: _buildSystemIndicator(
|
|
'Charge CPU',
|
|
_metrics != null ? '${_metrics!.cpuUsagePercent?.toStringAsFixed(0) ?? '0'}%' : '-',
|
|
Icons.memory,
|
|
Colors.blue,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: _buildSystemIndicator(
|
|
'Utilisateurs',
|
|
_metrics?.activeUsersCount?.toString() ?? '-',
|
|
Icons.people,
|
|
Colors.purple,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Indicateur système
|
|
Widget _buildSystemIndicator(String label, String value, IconData icon, Color color) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
value,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
color: Colors.white.withOpacity(0.8),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Barre d'onglets
|
|
Widget _buildTabBar() {
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: TabBar(
|
|
controller: _tabController,
|
|
labelColor: AppColors.primaryGreen,
|
|
unselectedLabelColor: AppColors.textSecondaryLight,
|
|
indicatorColor: AppColors.primaryGreen,
|
|
indicatorWeight: 3,
|
|
indicatorSize: TabBarIndicatorSize.tab,
|
|
labelStyle: const TextStyle(
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 10,
|
|
),
|
|
unselectedLabelStyle: const TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 10,
|
|
),
|
|
tabs: const [
|
|
Tab(
|
|
icon: Icon(Icons.tune, size: 16),
|
|
text: 'Général',
|
|
),
|
|
Tab(
|
|
icon: Icon(Icons.security, size: 16),
|
|
text: 'Sécurité',
|
|
),
|
|
Tab(
|
|
icon: Icon(Icons.speed, size: 16),
|
|
text: 'Performance',
|
|
),
|
|
Tab(
|
|
icon: Icon(Icons.build, size: 16),
|
|
text: 'Maintenance',
|
|
),
|
|
Tab(
|
|
icon: Icon(Icons.analytics, size: 16),
|
|
text: 'Monitoring',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Onglet général
|
|
Widget _buildGeneralTab() {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 8),
|
|
|
|
// Configuration de base
|
|
_buildSettingsSection(
|
|
'Configuration de base',
|
|
'Paramètres fondamentaux du système',
|
|
Icons.settings,
|
|
[
|
|
_buildSwitchSetting(
|
|
'Mode maintenance',
|
|
'Désactiver l\'accès utilisateur pour maintenance',
|
|
_maintenanceMode,
|
|
(value) {
|
|
setState(() => _maintenanceMode = value);
|
|
_showMaintenanceModeDialog(value);
|
|
},
|
|
isWarning: true,
|
|
),
|
|
_buildSwitchSetting(
|
|
'Mode debug',
|
|
'Activer les logs détaillés et outils de débogage',
|
|
_debugMode,
|
|
(value) {
|
|
setState(() => _debugMode = value);
|
|
_showSuccessSnackBar('Mode debug ${value ? 'activé' : 'désactivé'}');
|
|
},
|
|
),
|
|
_buildDropdownSetting(
|
|
'Niveau de logs',
|
|
'Détail des informations enregistrées',
|
|
_selectedLogLevel,
|
|
_logLevels,
|
|
(value) => setState(() => _selectedLogLevel = value!),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Gestion des données
|
|
_buildSettingsSection(
|
|
'Gestion des données',
|
|
'Configuration du stockage et cache',
|
|
Icons.storage,
|
|
[
|
|
_buildDropdownSetting(
|
|
'Stratégie de cache',
|
|
'Politique de mise en cache des données',
|
|
_selectedCacheStrategy,
|
|
_cacheStrategies,
|
|
(value) => setState(() => _selectedCacheStrategy = value!),
|
|
),
|
|
_buildActionSetting(
|
|
'Vider le cache système',
|
|
_metrics != null
|
|
? 'Supprimer tous les fichiers temporaires (${_metrics!.totalCacheSizeFormatted ?? "0 B"})'
|
|
: 'Supprimer tous les fichiers temporaires',
|
|
Icons.delete_sweep,
|
|
AppColors.warning,
|
|
() => _clearSystemCache(),
|
|
),
|
|
_buildActionSetting(
|
|
'Optimiser la base de données',
|
|
'Réorganiser et compacter la base de données',
|
|
Icons.tune,
|
|
AppColors.primaryGreen,
|
|
() => _optimizeDatabase(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Configuration réseau
|
|
_buildSettingsSection(
|
|
'Configuration réseau',
|
|
'Paramètres de connectivité',
|
|
Icons.network_check,
|
|
[
|
|
_buildInfoSetting('Serveur API', _metrics?.apiBaseUrl ?? 'Non configuré'),
|
|
_buildInfoSetting('Serveur d\'authentification', _metrics?.authServerUrl ?? 'Non configuré'),
|
|
_buildInfoSetting('CDN Assets', _metrics?.cdnUrl ?? 'Non configuré'),
|
|
_buildActionSetting(
|
|
'Tester la connectivité',
|
|
'Vérifier la connexion aux services',
|
|
Icons.network_ping,
|
|
AppColors.success,
|
|
() => _testConnectivity(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 80),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Onglet sécurité
|
|
Widget _buildSecurityTab() {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
|
|
// Sécurité réseau
|
|
_buildSettingsSection(
|
|
'Sécurité réseau',
|
|
'Protection des communications',
|
|
Icons.security,
|
|
[
|
|
_buildSwitchSetting(
|
|
'Forcer HTTPS/SSL',
|
|
'Obliger les connexions sécurisées',
|
|
_sslEnforced,
|
|
(value) {
|
|
setState(() => _sslEnforced = value);
|
|
_showSuccessSnackBar('SSL ${value ? 'obligatoire' : 'optionnel'}');
|
|
},
|
|
),
|
|
_buildSwitchSetting(
|
|
'Logs des API',
|
|
'Enregistrer toutes les requêtes API',
|
|
_apiLoggingEnabled,
|
|
(value) {
|
|
setState(() => _apiLoggingEnabled = value);
|
|
_showSuccessSnackBar('Logs API ${value ? 'activés' : 'désactivés'}');
|
|
},
|
|
),
|
|
_buildActionSetting(
|
|
'Régénérer les clés API',
|
|
'Créer de nouvelles clés d\'authentification',
|
|
Icons.vpn_key,
|
|
AppColors.warning,
|
|
() => _regenerateApiKeys(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Authentification
|
|
_buildSettingsSection(
|
|
'Authentification',
|
|
'Gestion des accès utilisateurs',
|
|
Icons.login,
|
|
[
|
|
_buildInfoSetting(
|
|
'Sessions actives',
|
|
_metrics != null ? '${_metrics!.activeSessionsCount ?? 0} sessions actives' : 'Chargement...',
|
|
),
|
|
_buildInfoSetting(
|
|
'Tentatives échouées',
|
|
_metrics != null ? '${_metrics!.failedLoginAttempts24h ?? 0} dans les dernières 24h' : 'Chargement...',
|
|
),
|
|
_buildActionSetting(
|
|
'Forcer la déconnexion globale',
|
|
'Déconnecter tous les utilisateurs',
|
|
Icons.logout,
|
|
Colors.red,
|
|
() => _forceGlobalLogout(),
|
|
),
|
|
_buildActionSetting(
|
|
'Réinitialiser les sessions',
|
|
'Nettoyer les sessions expirées',
|
|
Icons.refresh,
|
|
AppColors.primaryGreen,
|
|
() => _resetSessions(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Audit et conformité
|
|
_buildSettingsSection(
|
|
'Audit et conformité',
|
|
'Traçabilité et réglementation',
|
|
Icons.fact_check,
|
|
[
|
|
_buildActionSetting(
|
|
'Générer rapport d\'audit',
|
|
'Créer un rapport complet des activités',
|
|
Icons.assessment,
|
|
AppColors.primaryGreen,
|
|
() => _generateAuditReport(),
|
|
),
|
|
_buildActionSetting(
|
|
'Export RGPD',
|
|
'Exporter toutes les données utilisateurs',
|
|
Icons.download,
|
|
AppColors.success,
|
|
() => _exportGDPRData(),
|
|
),
|
|
_buildActionSetting(
|
|
'Purge des données',
|
|
'Supprimer les données expirées (RGPD)',
|
|
Icons.auto_delete,
|
|
AppColors.warning,
|
|
() => _purgeExpiredData(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 80),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Onglet performance
|
|
Widget _buildPerformanceTab() {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
|
|
// Monitoring système
|
|
_buildSettingsSection(
|
|
'Monitoring système',
|
|
'Surveillance des performances',
|
|
Icons.monitor,
|
|
[
|
|
_buildSwitchSetting(
|
|
'Monitoring des performances',
|
|
'Surveiller CPU, mémoire et réseau',
|
|
_performanceMonitoring,
|
|
(value) {
|
|
setState(() => _performanceMonitoring = value);
|
|
_showSuccessSnackBar('Monitoring ${value ? 'activé' : 'désactivé'}');
|
|
},
|
|
),
|
|
_buildSwitchSetting(
|
|
'Rapports de crash',
|
|
'Envoyer automatiquement les rapports d\'erreur',
|
|
_crashReportingEnabled,
|
|
(value) {
|
|
setState(() => _crashReportingEnabled = value);
|
|
_showSuccessSnackBar('Rapports de crash ${value ? 'activés' : 'désactivés'}');
|
|
},
|
|
),
|
|
_buildSwitchSetting(
|
|
'Analytics système',
|
|
'Collecter des données d\'utilisation anonymes',
|
|
_analyticsEnabled,
|
|
(value) {
|
|
setState(() => _analyticsEnabled = value);
|
|
_showSuccessSnackBar('Analytics ${value ? 'activées' : 'désactivées'}');
|
|
},
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Métriques en temps réel
|
|
_buildSettingsSection(
|
|
'Métriques en temps réel',
|
|
'État actuel du système',
|
|
Icons.speed,
|
|
[
|
|
_buildMetricItem(
|
|
'CPU',
|
|
_metrics != null ? '${_metrics!.cpuUsagePercent?.toStringAsFixed(1) ?? '0'}%' : '-',
|
|
Icons.memory,
|
|
Colors.blue,
|
|
),
|
|
_buildMetricItem(
|
|
'RAM',
|
|
_metrics != null ? '${_metrics!.memoryUsagePercent?.toStringAsFixed(1) ?? '0'}%' : '-',
|
|
Icons.storage,
|
|
Colors.green,
|
|
),
|
|
_buildMetricItem(
|
|
'Disque',
|
|
_metrics != null ? '${_metrics!.diskUsagePercent?.toStringAsFixed(1) ?? '0'}%' : '-',
|
|
Icons.storage,
|
|
Colors.orange,
|
|
),
|
|
_buildMetricItem(
|
|
'Réseau',
|
|
_metrics?.networkInFormatted ?? '0 B/s',
|
|
Icons.network_check,
|
|
Colors.purple,
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Optimisation
|
|
_buildSettingsSection(
|
|
'Optimisation',
|
|
'Améliorer les performances',
|
|
Icons.tune,
|
|
[
|
|
_buildActionSetting(
|
|
'Analyser les performances',
|
|
'Scanner les goulots d\'étranglement',
|
|
Icons.analytics,
|
|
AppColors.primaryGreen,
|
|
() => _analyzePerformance(),
|
|
),
|
|
_buildActionSetting(
|
|
'Nettoyer les logs anciens',
|
|
'Supprimer les logs de plus de 30 jours',
|
|
Icons.cleaning_services,
|
|
AppColors.warning,
|
|
() => _cleanOldLogs(),
|
|
),
|
|
_buildActionSetting(
|
|
'Redémarrer les services',
|
|
'Relancer tous les services système',
|
|
Icons.restart_alt,
|
|
Colors.red,
|
|
() => _restartServices(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 80),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Onglet maintenance
|
|
Widget _buildMaintenanceTab() {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
|
|
// Sauvegarde et restauration
|
|
_buildSettingsSection(
|
|
'Sauvegarde et restauration',
|
|
'Gestion des données critiques',
|
|
Icons.backup,
|
|
[
|
|
_buildSwitchSetting(
|
|
'Sauvegarde automatique',
|
|
'Sauvegarder automatiquement les données',
|
|
_autoBackupEnabled,
|
|
(value) {
|
|
setState(() => _autoBackupEnabled = value);
|
|
_showSuccessSnackBar('Sauvegarde auto ${value ? 'activée' : 'désactivée'}');
|
|
},
|
|
),
|
|
_buildDropdownSetting(
|
|
'Fréquence de sauvegarde',
|
|
'Intervalle entre les sauvegardes',
|
|
_selectedBackupFrequency,
|
|
_backupFrequencies,
|
|
(value) => setState(() => _selectedBackupFrequency = value!),
|
|
),
|
|
_buildActionSetting(
|
|
'Créer une sauvegarde maintenant',
|
|
'Sauvegarder immédiatement toutes les données',
|
|
Icons.save,
|
|
AppColors.success,
|
|
() => _createBackup(),
|
|
),
|
|
_buildActionSetting(
|
|
'Restaurer depuis une sauvegarde',
|
|
'Récupérer des données depuis un fichier',
|
|
Icons.restore,
|
|
AppColors.primaryGreen,
|
|
() => _restoreFromBackup(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Maintenance système
|
|
_buildSettingsSection(
|
|
'Maintenance système',
|
|
'Opérations de maintenance',
|
|
Icons.build,
|
|
[
|
|
_buildInfoSetting(
|
|
'Dernière maintenance',
|
|
_metrics?.lastMaintenance ?? 'Aucune maintenance récente',
|
|
),
|
|
_buildInfoSetting(
|
|
'Prochaine maintenance',
|
|
_metrics?.nextScheduledMaintenance ?? 'Non planifiée',
|
|
),
|
|
_buildActionSetting(
|
|
'Planifier une maintenance',
|
|
'Programmer une fenêtre de maintenance',
|
|
Icons.schedule,
|
|
AppColors.primaryGreen,
|
|
() => _scheduleMaintenance(),
|
|
),
|
|
_buildActionSetting(
|
|
'Maintenance d\'urgence',
|
|
'Lancer immédiatement une maintenance',
|
|
Icons.warning,
|
|
Colors.red,
|
|
() => _emergencyMaintenance(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Mise à jour système
|
|
_buildSettingsSection(
|
|
'Mise à jour système',
|
|
'Gestion des versions',
|
|
Icons.system_update,
|
|
[
|
|
_buildInfoSetting(
|
|
'Version actuelle',
|
|
_metrics != null ? 'UnionFlow Server ${_metrics!.applicationVersion ?? "N/A"}' : 'Chargement...',
|
|
),
|
|
_buildInfoSetting(
|
|
'Uptime',
|
|
_metrics?.uptimeFormatted ?? 'Chargement...',
|
|
),
|
|
_buildActionSetting(
|
|
'Vérifier les mises à jour',
|
|
'Rechercher les nouvelles versions',
|
|
Icons.refresh,
|
|
AppColors.primaryGreen,
|
|
() => _checkUpdates(),
|
|
),
|
|
_buildActionSetting(
|
|
'Historique des mises à jour',
|
|
'Voir les versions précédentes',
|
|
Icons.history,
|
|
AppColors.primaryGreen,
|
|
() => _showUpdateHistory(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 80),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Onglet monitoring
|
|
Widget _buildMonitoringTab() {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
|
|
// Alertes système
|
|
_buildSettingsSection(
|
|
'Alertes système',
|
|
'Notifications d\'état critique',
|
|
Icons.notifications_active,
|
|
[
|
|
_buildAlertItem(
|
|
'CPU élevé',
|
|
'Alerte si CPU > 80% pendant 5 min',
|
|
true,
|
|
AppColors.warning,
|
|
),
|
|
_buildAlertItem(
|
|
'Mémoire faible',
|
|
'Alerte si RAM < 20% disponible',
|
|
true,
|
|
AppColors.warning,
|
|
),
|
|
_buildAlertItem(
|
|
'Disque plein',
|
|
'Alerte si stockage > 90%',
|
|
true,
|
|
Colors.red,
|
|
),
|
|
_buildAlertItem(
|
|
'Connexions échouées',
|
|
'Alerte si > 100 échecs/min',
|
|
false,
|
|
AppColors.primaryGreen,
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Logs système
|
|
_buildSettingsSection(
|
|
'Logs système',
|
|
'Journaux d\'activité',
|
|
Icons.article,
|
|
[
|
|
_buildLogItem(
|
|
'Erreurs critiques',
|
|
_metrics?.criticalErrorsCount?.toString() ?? '0',
|
|
Colors.red,
|
|
),
|
|
_buildLogItem(
|
|
'Avertissements',
|
|
_metrics?.warningsCount?.toString() ?? '0',
|
|
Colors.orange,
|
|
),
|
|
_buildLogItem(
|
|
'Informations',
|
|
_metrics?.infoLogsCount?.toString() ?? '0',
|
|
Colors.blue,
|
|
),
|
|
_buildLogItem(
|
|
'Debug',
|
|
_metrics?.debugLogsCount?.toString() ?? '0',
|
|
Colors.grey,
|
|
),
|
|
_buildActionSetting(
|
|
'Voir tous les logs',
|
|
'Ouvrir la console de logs complète',
|
|
Icons.terminal,
|
|
AppColors.primaryGreen,
|
|
() => _viewAllLogs(),
|
|
),
|
|
_buildActionSetting(
|
|
'Exporter les logs',
|
|
'Télécharger les logs pour analyse',
|
|
Icons.download,
|
|
AppColors.success,
|
|
() => _exportLogs(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Statistiques d'utilisation
|
|
_buildSettingsSection(
|
|
'Statistiques d\'utilisation',
|
|
'Métriques d\'activité',
|
|
Icons.bar_chart,
|
|
[
|
|
_buildStatItem(
|
|
'Utilisateurs actifs (24h)',
|
|
_metrics?.activeUsersCount?.toString() ?? '0',
|
|
),
|
|
_buildStatItem(
|
|
'Requêtes API (1h)',
|
|
_metrics?.apiRequestsLastHour?.toString() ?? '0',
|
|
),
|
|
_buildStatItem(
|
|
'Mémoire utilisée',
|
|
_metrics?.usedMemoryFormatted ?? '0 B',
|
|
),
|
|
_buildStatItem(
|
|
'Temps de réponse moyen',
|
|
_metrics != null ? '${_metrics!.averageResponseTimeMs?.toStringAsFixed(0) ?? "0"}ms' : '0ms',
|
|
),
|
|
_buildActionSetting(
|
|
'Rapport détaillé',
|
|
'Générer un rapport complet d\'utilisation',
|
|
Icons.assessment,
|
|
AppColors.primaryGreen,
|
|
() => _generateUsageReport(),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 80),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// ==================== MÉTHODES DE CONSTRUCTION DES COMPOSANTS ====================
|
|
|
|
/// Section de paramètres
|
|
Widget _buildSettingsSection(
|
|
String title,
|
|
String subtitle,
|
|
IconData icon,
|
|
List<Widget> children,
|
|
) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(icon, color: Colors.grey[600], size: 20),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.grey[800],
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
...children.map((child) => Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: child,
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Paramètre avec switch
|
|
Widget _buildSwitchSetting(
|
|
String title,
|
|
String subtitle,
|
|
bool value,
|
|
Function(bool) onChanged, {
|
|
bool isWarning = false,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: isWarning ? Colors.orange.withOpacity(0.05) : Colors.grey[50],
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: isWarning ? Border.all(color: Colors.orange.withOpacity(0.3)) : null,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
if (isWarning)
|
|
const Icon(Icons.warning, color: AppColors.warning, size: 20)
|
|
else
|
|
const Icon(Icons.toggle_on, color: AppColors.primaryGreen, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: isWarning ? AppColors.warning : AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Switch(
|
|
value: value,
|
|
onChanged: onChanged,
|
|
activeColor: isWarning ? AppColors.warning : AppColors.primaryGreen,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Paramètre avec dropdown
|
|
Widget _buildDropdownSetting(
|
|
String title,
|
|
String subtitle,
|
|
String value,
|
|
List<String> options,
|
|
Function(String?) onChanged,
|
|
) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[50],
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.arrow_drop_down, color: AppColors.primaryGreen, size: 20),
|
|
const SizedBox(width: SpacingTokens.lg),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: Colors.grey[300]!),
|
|
),
|
|
child: DropdownButtonHideUnderline(
|
|
child: DropdownButton<String>(
|
|
value: value,
|
|
isExpanded: true,
|
|
onChanged: onChanged,
|
|
items: options.map((option) {
|
|
return DropdownMenuItem<String>(
|
|
value: option,
|
|
child: Text(option),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Paramètre d'action
|
|
Widget _buildActionSetting(
|
|
String title,
|
|
String subtitle,
|
|
IconData icon,
|
|
Color color,
|
|
VoidCallback onTap,
|
|
) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: color.withOpacity(0.05),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: color.withOpacity(0.1)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, color: color, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: color,
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Icon(Icons.arrow_forward_ios, color: Colors.grey[400], size: 16),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Paramètre d'information
|
|
Widget _buildInfoSetting(String title, String value) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[50],
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.info_outline, color: Colors.grey[600], size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Élément de métrique
|
|
Widget _buildMetricItem(String title, String value, IconData icon, Color color) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: color.withOpacity(0.05),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: color.withOpacity(0.1)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, color: color, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Text(
|
|
value,
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Élément d'alerte
|
|
Widget _buildAlertItem(String title, String subtitle, bool enabled, Color color) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: enabled ? color.withOpacity(0.05) : Colors.grey[50],
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(
|
|
color: enabled ? color.withOpacity(0.3) : Colors.grey[300]!,
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
enabled ? Icons.notifications_active : Icons.notifications_off,
|
|
color: enabled ? color : Colors.grey[600],
|
|
size: 20,
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: enabled ? color : Colors.grey[700],
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Switch(
|
|
value: enabled,
|
|
onChanged: (value) => _showSuccessSnackBar('Alerte ${value ? 'activée' : 'désactivée'}'),
|
|
activeColor: color,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Élément de log
|
|
Widget _buildLogItem(String title, String count, Color color) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: color.withOpacity(0.05),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: color.withOpacity(0.1)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.circle, color: color, size: 12),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Text(
|
|
count,
|
|
style: const TextStyle(
|
|
fontSize: 11,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Élément de statistique
|
|
Widget _buildStatItem(String title, String value) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[50],
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.bar_chart, color: AppColors.primaryGreen, size: 20),
|
|
const SizedBox(width: SpacingTokens.lg),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimaryLight,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// ==================== MÉTHODES D'ACTION ====================
|
|
|
|
/// Charger les paramètres système
|
|
void _loadSystemSettings() {
|
|
// Simuler le chargement des paramètres depuis le serveur
|
|
// En production, ceci ferait appel à l'API
|
|
}
|
|
|
|
/// Afficher l'état du système
|
|
void _showSystemStatus() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('État du système'),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildStatusItem('Serveur API', 'Opérationnel', Colors.green),
|
|
_buildStatusItem('Base de données', 'Opérationnel', Colors.green),
|
|
_buildStatusItem('Authentification', 'Opérationnel', Colors.green),
|
|
_buildStatusItem('CDN', 'Dégradé', Colors.orange),
|
|
_buildStatusItem('Monitoring', 'Opérationnel', Colors.green),
|
|
],
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Fermer'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_showSuccessSnackBar('État du système actualisé');
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppColors.primaryGreen,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
child: const Text('Actualiser'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Élément de statut
|
|
Widget _buildStatusItem(String service, String status, Color color) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.circle, color: color, size: 12),
|
|
const SizedBox(width: 8),
|
|
Expanded(child: Text(service)),
|
|
Text(
|
|
status,
|
|
style: TextStyle(
|
|
color: color,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Exporter la configuration système
|
|
void _exportSystemConfig() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Exporter la configuration'),
|
|
content: const Text(
|
|
'La configuration système sera exportée dans un fichier JSON. '
|
|
'Ce fichier contient tous les paramètres actuels du système.',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Annuler'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_showSuccessSnackBar('Configuration exportée avec succès');
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppColors.primaryGreen,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
child: const Text('Exporter'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Dialogue de mode maintenance
|
|
void _showMaintenanceModeDialog(bool enabled) {
|
|
if (enabled) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Mode maintenance activé'),
|
|
content: const Text(
|
|
'ATTENTION : Le mode maintenance va bloquer l\'accès à tous les utilisateurs. '
|
|
'Seuls les administrateurs système pourront accéder à l\'application.',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
setState(() => _maintenanceMode = false);
|
|
},
|
|
child: const Text('Annuler'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_showSuccessSnackBar('Mode maintenance activé - Utilisateurs bloqués');
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.orange,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
child: const Text('Confirmer'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
_showSuccessSnackBar('Mode maintenance désactivé - Accès restauré');
|
|
}
|
|
}
|
|
|
|
// Actions générales
|
|
void _clearSystemCache() {
|
|
context.read<SystemSettingsBloc>().add(ClearCache());
|
|
}
|
|
|
|
void _optimizeDatabase() => _showSuccessSnackBar('Base de données optimisée');
|
|
|
|
void _testConnectivity() {
|
|
context.read<SystemSettingsBloc>().add(TestDatabaseConnection());
|
|
}
|
|
|
|
// Actions de sécurité
|
|
void _regenerateApiKeys() => _showWarningDialog('Régénérer les clés API', 'Cette action invalidera toutes les clés existantes.');
|
|
void _forceGlobalLogout() => _showWarningDialog('Déconnexion globale', 'Tous les utilisateurs seront déconnectés immédiatement.');
|
|
void _resetSessions() => _showSuccessSnackBar('Sessions expirées nettoyées');
|
|
void _generateAuditReport() => _showSuccessSnackBar('Rapport d\'audit généré et envoyé par email');
|
|
void _exportGDPRData() => _showSuccessSnackBar('Export RGPD lancé - Vous recevrez un email');
|
|
void _purgeExpiredData() => _showWarningDialog('Purge des données', 'Les données expirées seront définitivement supprimées.');
|
|
|
|
// Actions de performance
|
|
void _analyzePerformance() => _showSuccessSnackBar('Analyse des performances lancée');
|
|
void _cleanOldLogs() => _showSuccessSnackBar('Logs anciens supprimés (450 MB libérés)');
|
|
void _restartServices() => _showWarningDialog('Redémarrer les services', 'Cette action causera une interruption temporaire.');
|
|
|
|
// Actions de maintenance
|
|
void _createBackup() => _showSuccessSnackBar('Sauvegarde créée avec succès');
|
|
void _restoreFromBackup() => _showWarningDialog('Restaurer une sauvegarde', 'Cette action remplacera toutes les données actuelles.');
|
|
void _scheduleMaintenance() => _showSuccessSnackBar('Fenêtre de maintenance programmée');
|
|
void _emergencyMaintenance() => _showWarningDialog('Maintenance d\'urgence', 'Le système sera immédiatement mis en maintenance.');
|
|
void _checkUpdates() => _showSuccessSnackBar('Aucune mise à jour disponible');
|
|
void _showUpdateHistory() => _showSuccessSnackBar('Historique des mises à jour affiché');
|
|
|
|
// Actions de monitoring
|
|
void _viewAllLogs() => _showSuccessSnackBar('Console de logs ouverte');
|
|
void _exportLogs() => _showSuccessSnackBar('Logs exportés pour analyse');
|
|
void _generateUsageReport() => _showSuccessSnackBar('Rapport d\'utilisation généré');
|
|
|
|
/// Dialogue d'avertissement générique
|
|
void _showWarningDialog(String title, String message) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(title),
|
|
content: Text(message),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Annuler'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_showSuccessSnackBar('Action exécutée avec succès');
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.red,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
child: const Text('Confirmer'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Afficher un message de succès
|
|
void _showSuccessSnackBar(String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(message),
|
|
backgroundColor: AppColors.success,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Afficher un message d'erreur
|
|
void _showErrorSnackBar(String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(message),
|
|
backgroundColor: AppColors.error,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
}
|