datos invocados correctamente, falta que se hagan visibles
This commit is contained in:
@@ -23,6 +23,7 @@ class Componente {
|
||||
this.ubicacion,
|
||||
this.imagenUrl,
|
||||
required this.fechaRegistro,
|
||||
String? distribucionId,
|
||||
});
|
||||
|
||||
factory Componente.fromMap(Map<String, dynamic> map) {
|
||||
|
||||
141
lib/models/nethive/vista_conexiones_por_cables_model.dart
Normal file
141
lib/models/nethive/vista_conexiones_por_cables_model.dart
Normal file
@@ -0,0 +1,141 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class VistaConexionesPorCables {
|
||||
final String conexionId;
|
||||
final String? descripcion;
|
||||
final bool activo;
|
||||
final String origenId;
|
||||
final String componenteOrigen;
|
||||
final String destinoId;
|
||||
final String componenteDestino;
|
||||
final String? cableId;
|
||||
final String? cableUsado;
|
||||
final String? tipoCable;
|
||||
final String? color;
|
||||
final double? tamano;
|
||||
final String? tipoConector;
|
||||
|
||||
VistaConexionesPorCables({
|
||||
required this.conexionId,
|
||||
this.descripcion,
|
||||
required this.activo,
|
||||
required this.origenId,
|
||||
required this.componenteOrigen,
|
||||
required this.destinoId,
|
||||
required this.componenteDestino,
|
||||
this.cableId,
|
||||
this.cableUsado,
|
||||
this.tipoCable,
|
||||
this.color,
|
||||
this.tamano,
|
||||
this.tipoConector,
|
||||
});
|
||||
|
||||
factory VistaConexionesPorCables.fromMap(Map<String, dynamic> map) {
|
||||
return VistaConexionesPorCables(
|
||||
conexionId: map['conexion_id']?.toString() ?? '',
|
||||
descripcion: map['descripcion']?.toString(),
|
||||
activo: map['activo'] == true,
|
||||
origenId: map['origen_id']?.toString() ?? '',
|
||||
componenteOrigen: map['componente_origen']?.toString() ?? '',
|
||||
destinoId: map['destino_id']?.toString() ?? '',
|
||||
componenteDestino: map['componente_destino']?.toString() ?? '',
|
||||
cableId: map['cable_id']?.toString(),
|
||||
cableUsado: map['cable_usado']?.toString(),
|
||||
tipoCable: map['tipo_cable']?.toString(),
|
||||
color: map['color']?.toString(),
|
||||
tamano: map['tamaño']?.toDouble(),
|
||||
tipoConector: map['tipo_conector']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'conexion_id': conexionId,
|
||||
'descripcion': descripcion,
|
||||
'activo': activo,
|
||||
'origen_id': origenId,
|
||||
'componente_origen': componenteOrigen,
|
||||
'destino_id': destinoId,
|
||||
'componente_destino': componenteDestino,
|
||||
'cable_id': cableId,
|
||||
'cable_usado': cableUsado,
|
||||
'tipo_cable': tipoCable,
|
||||
'color': color,
|
||||
'tamaño': tamano,
|
||||
'tipo_conector': tipoConector,
|
||||
};
|
||||
}
|
||||
|
||||
factory VistaConexionesPorCables.fromJson(String source) =>
|
||||
VistaConexionesPorCables.fromMap(json.decode(source));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
// Método para obtener el color del cable para visualización
|
||||
String getColorForVisualization() {
|
||||
if (color == null || color!.isEmpty) {
|
||||
// Color por defecto basado en tipo de cable
|
||||
switch (tipoCable?.toLowerCase()) {
|
||||
case 'fibra':
|
||||
case 'fibra optica':
|
||||
return '#00BCD4'; // Cyan
|
||||
case 'utp':
|
||||
case 'cat6':
|
||||
case 'cat5e':
|
||||
return '#FFEB3B'; // Yellow
|
||||
case 'coaxial':
|
||||
return '#FF9800'; // Orange
|
||||
default:
|
||||
return '#2196F3'; // Blue por defecto
|
||||
}
|
||||
}
|
||||
|
||||
// Convertir nombre de color a código hex
|
||||
switch (color!.toLowerCase()) {
|
||||
case 'azul':
|
||||
case 'blue':
|
||||
return '#2196F3';
|
||||
case 'rojo':
|
||||
case 'red':
|
||||
return '#F44336';
|
||||
case 'verde':
|
||||
case 'green':
|
||||
return '#4CAF50';
|
||||
case 'amarillo':
|
||||
case 'yellow':
|
||||
return '#FFEB3B';
|
||||
case 'naranja':
|
||||
case 'orange':
|
||||
return '#FF9800';
|
||||
case 'morado':
|
||||
case 'purple':
|
||||
return '#9C27B0';
|
||||
case 'cyan':
|
||||
return '#00BCD4';
|
||||
case 'gris':
|
||||
case 'gray':
|
||||
return '#757575';
|
||||
default:
|
||||
return '#2196F3';
|
||||
}
|
||||
}
|
||||
|
||||
// Método para determinar el grosor de línea basado en el tipo de cable
|
||||
double getThicknessForVisualization() {
|
||||
switch (tipoCable?.toLowerCase()) {
|
||||
case 'fibra':
|
||||
case 'fibra optica':
|
||||
return 5.0; // Más grueso para backbone
|
||||
case 'utp':
|
||||
case 'cat6':
|
||||
return 4.0;
|
||||
case 'cat5e':
|
||||
return 3.0;
|
||||
case 'coaxial':
|
||||
return 3.5;
|
||||
default:
|
||||
return 3.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
183
lib/models/nethive/vista_topologia_por_negocio_model.dart
Normal file
183
lib/models/nethive/vista_topologia_por_negocio_model.dart
Normal file
@@ -0,0 +1,183 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class VistaTopologiaPorNegocio {
|
||||
final String negocioId;
|
||||
final String nombreNegocio;
|
||||
final String? distribucionId;
|
||||
final String? tipoDistribucion;
|
||||
final String? distribucionNombre;
|
||||
final String componenteId;
|
||||
final String componenteNombre;
|
||||
final String? descripcion;
|
||||
final String categoriaComponente;
|
||||
final bool enUso;
|
||||
final bool activo;
|
||||
final String? ubicacion;
|
||||
final String? imagenUrl;
|
||||
final DateTime fechaRegistro;
|
||||
|
||||
VistaTopologiaPorNegocio({
|
||||
required this.negocioId,
|
||||
required this.nombreNegocio,
|
||||
this.distribucionId,
|
||||
this.tipoDistribucion,
|
||||
this.distribucionNombre,
|
||||
required this.componenteId,
|
||||
required this.componenteNombre,
|
||||
this.descripcion,
|
||||
required this.categoriaComponente,
|
||||
required this.enUso,
|
||||
required this.activo,
|
||||
this.ubicacion,
|
||||
this.imagenUrl,
|
||||
required this.fechaRegistro,
|
||||
});
|
||||
|
||||
factory VistaTopologiaPorNegocio.fromMap(Map<String, dynamic> map) {
|
||||
return VistaTopologiaPorNegocio(
|
||||
negocioId: map['negocio_id']?.toString() ?? '',
|
||||
nombreNegocio: map['nombre_negocio']?.toString() ?? '',
|
||||
distribucionId: map['distribucion_id']?.toString(),
|
||||
tipoDistribucion: map['tipo_distribucion']?.toString(),
|
||||
distribucionNombre: map['distribucion_nombre']?.toString(),
|
||||
componenteId: map['componente_id']?.toString() ?? '',
|
||||
componenteNombre: map['componente_nombre']?.toString() ?? '',
|
||||
descripcion: map['descripcion']?.toString(),
|
||||
categoriaComponente: map['categoria_componente']?.toString() ?? '',
|
||||
enUso: map['en_uso'] == true,
|
||||
activo: map['activo'] == true,
|
||||
ubicacion: map['ubicacion']?.toString(),
|
||||
imagenUrl: map['imagen_url']?.toString(),
|
||||
fechaRegistro:
|
||||
DateTime.tryParse(map['fecha_registro']?.toString() ?? '') ??
|
||||
DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'negocio_id': negocioId,
|
||||
'nombre_negocio': nombreNegocio,
|
||||
'distribucion_id': distribucionId,
|
||||
'tipo_distribucion': tipoDistribucion,
|
||||
'distribucion_nombre': distribucionNombre,
|
||||
'componente_id': componenteId,
|
||||
'componente_nombre': componenteNombre,
|
||||
'descripcion': descripcion,
|
||||
'categoria_componente': categoriaComponente,
|
||||
'en_uso': enUso,
|
||||
'activo': activo,
|
||||
'ubicacion': ubicacion,
|
||||
'imagen_url': imagenUrl,
|
||||
'fecha_registro': fechaRegistro.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory VistaTopologiaPorNegocio.fromJson(String source) =>
|
||||
VistaTopologiaPorNegocio.fromMap(json.decode(source));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
// Método para obtener el tipo de componente principal basado en IDs
|
||||
String get tipoComponentePrincipal {
|
||||
final categoria = categoriaComponente.toLowerCase();
|
||||
|
||||
// Clasificación basada en los nombres de categorías exactos
|
||||
if (categoria == 'cable') return 'cable';
|
||||
if (categoria == 'switch') return 'switch';
|
||||
if (categoria == 'patch panel') return 'patch_panel';
|
||||
if (categoria == 'rack') return 'rack';
|
||||
if (categoria == 'ups') return 'ups';
|
||||
if (categoria == 'mdf') return 'mdf';
|
||||
if (categoria == 'idf') return 'idf';
|
||||
|
||||
// Clasificación por contenido para compatibilidad
|
||||
if (categoria.contains('switch')) return 'switch';
|
||||
if (categoria.contains('router') || categoria.contains('firewall'))
|
||||
return 'router';
|
||||
if (categoria.contains('servidor') || categoria.contains('server'))
|
||||
return 'servidor';
|
||||
if (categoria.contains('cable')) return 'cable';
|
||||
if (categoria.contains('patch') || categoria.contains('panel'))
|
||||
return 'patch_panel';
|
||||
if (categoria.contains('rack')) return 'rack';
|
||||
if (categoria.contains('ups')) return 'ups';
|
||||
if (categoria.contains('organizador')) return 'organizador';
|
||||
|
||||
return 'otro';
|
||||
}
|
||||
|
||||
// Método mejorado para determinar si es MDF
|
||||
bool get esMDF {
|
||||
final categoria = categoriaComponente.toLowerCase();
|
||||
return categoria == 'mdf' ||
|
||||
tipoDistribucion?.toUpperCase() == 'MDF' ||
|
||||
ubicacion?.toLowerCase().contains('mdf') == true;
|
||||
}
|
||||
|
||||
// Método mejorado para determinar si es IDF
|
||||
bool get esIDF {
|
||||
final categoria = categoriaComponente.toLowerCase();
|
||||
return categoria == 'idf' ||
|
||||
tipoDistribucion?.toUpperCase() == 'IDF' ||
|
||||
ubicacion?.toLowerCase().contains('idf') == true;
|
||||
}
|
||||
|
||||
// Método para obtener el nivel de prioridad del componente (para ordenamiento en topología)
|
||||
int get prioridadTopologia {
|
||||
if (esMDF) return 1; // Máxima prioridad para MDF
|
||||
if (esIDF) return 2; // Segunda prioridad para IDF
|
||||
|
||||
switch (tipoComponentePrincipal) {
|
||||
case 'router':
|
||||
return 3;
|
||||
case 'switch':
|
||||
return 4;
|
||||
case 'servidor':
|
||||
return 5;
|
||||
case 'patch_panel':
|
||||
return 6;
|
||||
case 'rack':
|
||||
return 7;
|
||||
case 'ups':
|
||||
return 8;
|
||||
case 'cable':
|
||||
return 9;
|
||||
case 'organizador':
|
||||
return 10;
|
||||
default:
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
|
||||
// Método para determinar el color del componente en el diagrama
|
||||
String getColorForDiagram() {
|
||||
if (esMDF) return '#2196F3'; // Azul para MDF
|
||||
if (esIDF) {
|
||||
return enUso
|
||||
? '#4CAF50'
|
||||
: '#FF9800'; // Verde si está en uso, naranja si no
|
||||
}
|
||||
|
||||
switch (tipoComponentePrincipal) {
|
||||
case 'router':
|
||||
return '#FF5722'; // Naranja rojizo
|
||||
case 'switch':
|
||||
return '#9C27B0'; // Morado
|
||||
case 'servidor':
|
||||
return '#E91E63'; // Rosa
|
||||
case 'patch_panel':
|
||||
return '#607D8B'; // Azul gris
|
||||
case 'rack':
|
||||
return '#795548'; // Marrón
|
||||
case 'ups':
|
||||
return '#FFC107'; // Ámbar
|
||||
case 'cable':
|
||||
return '#4CAF50'; // Verde
|
||||
case 'organizador':
|
||||
return '#9E9E9E'; // Gris
|
||||
default:
|
||||
return activo ? '#2196F3' : '#757575';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user