- OperadorLoginPage con auth WebControl 2 pasos (empresas → login) - ShellPage: sidebar 220px + IndexedStack + header con estado API - DashboardPage: stat cards, feed alarmas, clientes, incidentes (timer 30s) - ApiAuthService: flujo real con email + paswd + dba → token + apiKey - DB SQLite v1: 7 tablas + 7 DAOs completos - theme.dart: AppColors, appHeadline (Manrope), appLabel (Inter) - Logo app: escudo radar neón (SVG + PNG 512px) en lib/recursos/ - desplegar.sh: build release Linux + upload a siax-system.net - agents.md: estado completo + objetivos futuros documentados Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.0 KiB
Dart
37 lines
1.0 KiB
Dart
import '../database_helper.dart';
|
|
|
|
class SesionesDao {
|
|
final _db = DatabaseHelper.instance;
|
|
|
|
Future<int> iniciarSesion(String nombre, String usuario) async {
|
|
final db = await _db.db;
|
|
await db.update('sesiones_operador', {'activa': 0});
|
|
return db.insert('sesiones_operador', {
|
|
'nombre': nombre,
|
|
'usuario': usuario,
|
|
'inicio': DateTime.now().toIso8601String(),
|
|
'activa': 1,
|
|
});
|
|
}
|
|
|
|
Future<void> cerrarSesion() async {
|
|
final db = await _db.db;
|
|
await db.update(
|
|
'sesiones_operador',
|
|
{'fin': DateTime.now().toIso8601String(), 'activa': 0},
|
|
where: 'activa = 1',
|
|
);
|
|
}
|
|
|
|
Future<Map<String, dynamic>?> getSesionActiva() async {
|
|
final db = await _db.db;
|
|
final rows = await db.query('sesiones_operador', where: 'activa = 1', limit: 1);
|
|
return rows.isEmpty ? null : rows.first;
|
|
}
|
|
|
|
Future<List<Map<String, dynamic>>> getRecientes({int limit = 10}) async {
|
|
final db = await _db.db;
|
|
return db.query('sesiones_operador', orderBy: 'inicio DESC', limit: limit);
|
|
}
|
|
}
|