- 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>
49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import '../database_helper.dart';
|
|
|
|
class OperadoresDao {
|
|
final _db = DatabaseHelper.instance;
|
|
|
|
Future<List<Map<String, dynamic>>> getTodos() async {
|
|
final db = await _db.db;
|
|
return db.query('operadores', where: 'activo = 1', orderBy: 'nombre ASC');
|
|
}
|
|
|
|
Future<List<Map<String, dynamic>>> getEnTurno() async {
|
|
final db = await _db.db;
|
|
return db.query('operadores', where: 'activo = 1 AND en_turno = 1');
|
|
}
|
|
|
|
Future<int> insertar(String nombre, int nivel) async {
|
|
final db = await _db.db;
|
|
final iniciales = _calcularIniciales(nombre);
|
|
return db.insert('operadores', {
|
|
'nombre': nombre,
|
|
'iniciales': iniciales,
|
|
'nivel': nivel,
|
|
'activo': 1,
|
|
'en_turno': 0,
|
|
});
|
|
}
|
|
|
|
Future<int> setEnTurno(int id, bool valor) async {
|
|
final db = await _db.db;
|
|
return db.update(
|
|
'operadores',
|
|
{'en_turno': valor ? 1 : 0},
|
|
where: 'id = ?',
|
|
whereArgs: [id],
|
|
);
|
|
}
|
|
|
|
Future<int> desactivar(int id) async {
|
|
final db = await _db.db;
|
|
return db.update('operadores', {'activo': 0}, where: 'id = ?', whereArgs: [id]);
|
|
}
|
|
|
|
String _calcularIniciales(String nombre) {
|
|
final p = nombre.trim().split(RegExp(r'\s+'));
|
|
if (p.length >= 2) return '${p.first[0]}${p.last[0]}'.toUpperCase();
|
|
return nombre.isNotEmpty ? nombre[0].toUpperCase() : '?';
|
|
}
|
|
}
|