|
@ -1,20 +1,28 @@ |
|
|
package mx.gob.jumapacelaya.ui; |
|
|
package mx.gob.jumapacelaya.ui; |
|
|
|
|
|
|
|
|
|
|
|
import com.vaadin.flow.component.button.ButtonVariant; |
|
|
import com.vaadin.flow.component.checkbox.CheckboxGroup; |
|
|
import com.vaadin.flow.component.checkbox.CheckboxGroup; |
|
|
import com.vaadin.flow.component.combobox.ComboBox; |
|
|
import com.vaadin.flow.component.combobox.ComboBox; |
|
|
import com.vaadin.flow.component.datepicker.DatePicker; |
|
|
import com.vaadin.flow.component.datepicker.DatePicker; |
|
|
import com.vaadin.flow.component.dependency.CssImport; |
|
|
import com.vaadin.flow.component.dependency.CssImport; |
|
|
|
|
|
import com.vaadin.flow.component.html.H1; |
|
|
|
|
|
import com.vaadin.flow.component.html.H2; |
|
|
import com.vaadin.flow.component.html.Span; |
|
|
import com.vaadin.flow.component.html.Span; |
|
|
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
|
|
|
import com.vaadin.flow.component.icon.VaadinIcon; |
|
|
|
|
|
import com.vaadin.flow.component.notification.Notification; |
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
|
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
|
|
import com.vaadin.flow.component.radiobutton.RadioButtonGroup; |
|
|
import com.vaadin.flow.component.radiobutton.RadioButtonGroup; |
|
|
import com.vaadin.flow.component.textfield.TextArea; |
|
|
import com.vaadin.flow.component.textfield.TextArea; |
|
|
import com.vaadin.flow.component.textfield.TextField; |
|
|
import com.vaadin.flow.component.textfield.TextField; |
|
|
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
import com.vaadin.flow.router.PageTitle; |
|
|
import com.vaadin.flow.router.PageTitle; |
|
|
import com.vaadin.flow.router.Route; |
|
|
import com.vaadin.flow.router.Route; |
|
|
import jakarta.annotation.security.PermitAll; |
|
|
import jakarta.annotation.security.PermitAll; |
|
|
import mx.gob.jumapacelaya.services.DatabaseService; |
|
|
import mx.gob.jumapacelaya.services.DatabaseService; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
@ -25,9 +33,16 @@ import java.util.List; |
|
|
@CssImport("./themes/sistema-mantenimiento/styles.css") |
|
|
@CssImport("./themes/sistema-mantenimiento/styles.css") |
|
|
public class MantenimientoView extends VerticalLayout { |
|
|
public class MantenimientoView extends VerticalLayout { |
|
|
|
|
|
|
|
|
|
|
|
private final VerticalLayout controlsLayout; |
|
|
|
|
|
private final DatabaseService databaseService; |
|
|
|
|
|
private final VerticalLayout actualizacionesLayout; |
|
|
|
|
|
|
|
|
public MantenimientoView() { |
|
|
public MantenimientoView() { |
|
|
DatabaseService databaseService = new DatabaseService(); |
|
|
|
|
|
|
|
|
this.databaseService = new DatabaseService(); |
|
|
|
|
|
this.controlsLayout = new VerticalLayout(); |
|
|
|
|
|
this.actualizacionesLayout = new VerticalLayout(); |
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout fechaLayout = new HorizontalLayout(); |
|
|
//Componentes de texto |
|
|
//Componentes de texto |
|
|
TextField nomenclatura = new TextField("Nomenclatura"); |
|
|
TextField nomenclatura = new TextField("Nomenclatura"); |
|
|
nomenclatura.setReadOnly(true); |
|
|
nomenclatura.setReadOnly(true); |
|
@ -37,15 +52,11 @@ public class MantenimientoView extends VerticalLayout { |
|
|
otras.setEnabled(false); |
|
|
otras.setEnabled(false); |
|
|
otras.addClassName("mantenimiento-text-field"); |
|
|
otras.addClassName("mantenimiento-text-field"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Selector de fecha |
|
|
//Selector de fecha |
|
|
DatePicker fecha = new DatePicker("Fecha"); |
|
|
DatePicker fecha = new DatePicker("Fecha"); |
|
|
|
|
|
|
|
|
//ComboBox |
|
|
|
|
|
ComboBox<String> area = new ComboBox("Area o Departamento"); |
|
|
|
|
|
area.setItems("T.I", "Catastro", "Medicion"); //Areas de ejemplo |
|
|
|
|
|
area.addClassName("mantenimiento-combo"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ComboBox Tipo de Mantenimiento |
|
|
ComboBox<String> tipoMantt = new ComboBox<>("Tipo de Mantenimiento"); |
|
|
ComboBox<String> tipoMantt = new ComboBox<>("Tipo de Mantenimiento"); |
|
|
List<String> tiposDeMantenimiento = databaseService.getTiposDeMantenimientos(); |
|
|
List<String> tiposDeMantenimiento = databaseService.getTiposDeMantenimientos(); |
|
|
tipoMantt.setItems(tiposDeMantenimiento); |
|
|
tipoMantt.setItems(tiposDeMantenimiento); |
|
@ -68,82 +79,135 @@ public class MantenimientoView extends VerticalLayout { |
|
|
fecha.clear(); |
|
|
fecha.clear(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
fechaLayout.add(fecha); |
|
|
|
|
|
fechaLayout.addAndExpand(new HorizontalLayout()); |
|
|
|
|
|
fechaLayout.add(tipoMantt, nomenclatura); |
|
|
|
|
|
fechaLayout.setWidthFull(); |
|
|
|
|
|
|
|
|
ComboBox<String> usuario = new ComboBox("Usuario"); |
|
|
|
|
|
usuario.setItems("Usuario1", "Usuario2", "Usuario3"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CheckBoxes LIMPIEZA DE EQUIPO |
|
|
|
|
|
CheckboxGroup<String> limpiezaEq = new CheckboxGroup<>(); |
|
|
|
|
|
limpiezaEq.setWidthFull(); |
|
|
|
|
|
limpiezaEq.setLabel("LIMPIEZA DE EQUIPO REALIZDA"); |
|
|
|
|
|
limpiezaEq.setItems("CPU","Monitor","Laptop"); |
|
|
|
|
|
limpiezaEq.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
CheckboxGroup<String> escannerImp = new CheckboxGroup<>(); |
|
|
|
|
|
escannerImp.setItems("Escaner", "Impresora", "Otro"); |
|
|
|
|
|
escannerImp.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
//CheckBoxes ACTUALIZACIONES DE SEGURIDAD |
|
|
|
|
|
CheckboxGroup<String> actualiSeg = new CheckboxGroup(); |
|
|
|
|
|
Span etiqueta = new Span("ACTUALIZACIONES DE SEGURIDAD INFORMATICA"); |
|
|
|
|
|
actualiSeg.setLabel("Actualizaciones necesarias"); |
|
|
|
|
|
actualiSeg.setItems("S.O", "Antivirus", "Firewall"); |
|
|
|
|
|
|
|
|
|
|
|
RadioButtonGroup<String> forma = new RadioButtonGroup<>(); |
|
|
|
|
|
forma.setLabel("Actividad realizada de forma:"); |
|
|
|
|
|
forma.setItems("Remota", "Manual"); |
|
|
|
|
|
|
|
|
|
|
|
RadioButtonGroup<String> masActu = new RadioButtonGroup<>(); |
|
|
|
|
|
masActu.setLabel("¿Requiere mas actualizaciones?:"); |
|
|
|
|
|
masActu.setItems("Si", "No"); |
|
|
|
|
|
masActu.addValueChangeListener(event -> { |
|
|
|
|
|
if ("Si".equals(event.getValue())) { |
|
|
|
|
|
otras.setEnabled(true); |
|
|
|
|
|
} else { |
|
|
|
|
|
otras.setEnabled(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout departamentoLayout = new HorizontalLayout(); |
|
|
|
|
|
//ComboBox Area o Departamento |
|
|
|
|
|
ComboBox<String> area = new ComboBox<>("Area o Departamento"); |
|
|
|
|
|
List<String> areas = databaseService.getDepartamentos(); |
|
|
|
|
|
area.setItems(areas); |
|
|
|
|
|
|
|
|
|
|
|
ComboBox<String> usuario = new ComboBox<>("Usuario"); |
|
|
|
|
|
List<String> usuarios = databaseService.getUsuarios(); |
|
|
|
|
|
usuario.setItems(usuarios); |
|
|
|
|
|
|
|
|
|
|
|
departamentoLayout.add(area, usuario); |
|
|
|
|
|
departamentoLayout.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
createHardwareSection(databaseService); |
|
|
|
|
|
addActualizacionesSection(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add(fechaLayout, departamentoLayout, controlsLayout, actualizacionesLayout); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createHardwareSection(DatabaseService databaseService) { |
|
|
|
|
|
HorizontalLayout etiquetaLayout = new HorizontalLayout(); |
|
|
|
|
|
Span etiqueta = new Span("Limpieza de Equipo Realizada"); |
|
|
|
|
|
|
|
|
|
|
|
//Boton para agregar otro tipo de hardware |
|
|
|
|
|
Button btnAgregarTipo = new Button(new Icon(VaadinIcon.PLUS)); |
|
|
|
|
|
btnAgregarTipo.addThemeVariants(ButtonVariant.LUMO_ICON); |
|
|
|
|
|
btnAgregarTipo.setAriaLabel("Agregar Tipo"); |
|
|
|
|
|
|
|
|
|
|
|
//Listener del boton para agregar mas |
|
|
|
|
|
btnAgregarTipo.addClickListener(event -> { |
|
|
|
|
|
addNuevoTipo(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
etiquetaLayout.add(etiqueta, btnAgregarTipo); |
|
|
|
|
|
controlsLayout.add(etiquetaLayout); |
|
|
|
|
|
controlsLayout.setSpacing(false); |
|
|
|
|
|
|
|
|
|
|
|
addNuevoTipo(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//?Diseño del Layout de la fecha y la nomenclatura |
|
|
|
|
|
HorizontalLayout header = new HorizontalLayout(); |
|
|
|
|
|
header.setWidthFull(); |
|
|
|
|
|
header.add(fecha); |
|
|
|
|
|
header.addAndExpand(new HorizontalLayout()); |
|
|
|
|
|
header.add(tipoMantt); |
|
|
|
|
|
header.add(nomenclatura); |
|
|
|
|
|
|
|
|
//Metodo para agregar un nuevo ComboBox de tipo de hardware y campos de texto |
|
|
|
|
|
private void addNuevoTipo() { |
|
|
|
|
|
ComboBox<String> tipoHardware = new ComboBox<>(); |
|
|
|
|
|
List<String> tiposHardware = databaseService.getTiposHardware(); |
|
|
|
|
|
tipoHardware.setItems(tiposHardware); |
|
|
|
|
|
tipoHardware.setPlaceholder("Tipo de hardware"); |
|
|
|
|
|
|
|
|
|
|
|
TextField noSerie = new TextField(); |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
noSerie.setPlaceholder("No. Serie"); |
|
|
|
|
|
|
|
|
//?Diseño para los campos de area y el usuario |
|
|
|
|
|
HorizontalLayout usuarioLayout = new HorizontalLayout(area, usuario/*, tipoEquipo*/); |
|
|
|
|
|
|
|
|
TextField modelo = new TextField(); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
modelo.setPlaceholder("Modelo"); |
|
|
|
|
|
|
|
|
//?Alineacion de los checkBoxes |
|
|
|
|
|
HorizontalLayout checkboxLayout = new HorizontalLayout(forma, masActu, otras); |
|
|
|
|
|
|
|
|
TextField placa = new TextField(); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
placa.setPlaceholder("Placa"); |
|
|
|
|
|
|
|
|
|
|
|
tipoHardware.addValueChangeListener(event -> { |
|
|
|
|
|
String tipoSeleccionado = event.getValue(); |
|
|
|
|
|
|
|
|
//?Reparaciones realizadas |
|
|
|
|
|
VerticalLayout reparacionLayout = new VerticalLayout(); |
|
|
|
|
|
Span etiqueta2 = new Span("Reparación Realizada al Equipo"); |
|
|
|
|
|
TextField instalacion = new TextField("Instalacion de Software"); |
|
|
|
|
|
TextField reparacion = new TextField("Reparacion de Hardware"); |
|
|
|
|
|
TextField cambio = new TextField("Cambio de Dispositivo"); |
|
|
|
|
|
reparacionLayout.add(etiqueta2, instalacion, reparacion, cambio); |
|
|
|
|
|
reparacionLayout.setAlignItems(Alignment.STRETCH); |
|
|
|
|
|
reparacionLayout.setVisible(false); |
|
|
|
|
|
tipoMantt.addValueChangeListener(event -> { |
|
|
|
|
|
if ("Correctivo".equals(event.getValue())) { |
|
|
|
|
|
reparacionLayout.setVisible(true); |
|
|
|
|
|
|
|
|
if (tipoSeleccionado != null) { |
|
|
|
|
|
if ("MOUSE".equalsIgnoreCase(tipoSeleccionado) || "TECLADO".equalsIgnoreCase(tipoSeleccionado)) { |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
} else { |
|
|
|
|
|
noSerie.setEnabled(true); |
|
|
|
|
|
modelo.setEnabled(true); |
|
|
|
|
|
placa.setEnabled(true); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
reparacionLayout.setVisible(false); |
|
|
|
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Boton para eliminar ese conjunto de hardware |
|
|
|
|
|
Button btnEliminar = new Button(new Icon(VaadinIcon.TRASH)); |
|
|
|
|
|
btnEliminar.addThemeVariants(ButtonVariant.LUMO_ICON, ButtonVariant.LUMO_ERROR); |
|
|
|
|
|
btnEliminar.setAriaLabel("Eliminar Tipo"); |
|
|
|
|
|
|
|
|
|
|
|
//Crear nuevo layout horizontal con estos campos |
|
|
|
|
|
HorizontalLayout hardwareDetailsLayout = new HorizontalLayout(); |
|
|
|
|
|
hardwareDetailsLayout.add(tipoHardware, noSerie, modelo, placa, btnEliminar); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Listener para eliminar el tipo |
|
|
|
|
|
btnEliminar.addClickListener(event -> { |
|
|
|
|
|
controlsLayout.remove(hardwareDetailsLayout); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add(header, usuarioLayout, limpiezaEq, escannerImp, etiqueta, actualiSeg, checkboxLayout, reparacionLayout); |
|
|
|
|
|
|
|
|
controlsLayout.add(hardwareDetailsLayout); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addActualizacionesSection() { |
|
|
|
|
|
VerticalLayout etiquetaLayout = new VerticalLayout(); |
|
|
|
|
|
Span Titulo = new Span("Actualizaciones de Seguridad Informatica:"); |
|
|
|
|
|
etiquetaLayout.add(Titulo); |
|
|
|
|
|
|
|
|
|
|
|
CheckboxGroup<String> actualizaciones = new CheckboxGroup<>(); |
|
|
|
|
|
actualizaciones.setLabel("Actualizaciones Necesarias"); |
|
|
|
|
|
actualizaciones.setItems("S.O", "Antivirus", "Firewall"); |
|
|
|
|
|
|
|
|
|
|
|
RadioButtonGroup<String> formaGroup = new RadioButtonGroup<>(); |
|
|
|
|
|
formaGroup.setLabel("Actividad Realizada de Forma:"); |
|
|
|
|
|
formaGroup.setItems("Remota", "Manual"); |
|
|
|
|
|
|
|
|
|
|
|
VerticalLayout actualizacionesGroup = new VerticalLayout(); |
|
|
|
|
|
actualizacionesGroup.add(actualizaciones); |
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout formasLayout = new HorizontalLayout(); |
|
|
|
|
|
formasLayout.add(formaGroup); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actualizacionesLayout.add(Titulo, actualizacionesGroup, formasLayout); |
|
|
|
|
|
actualizacionesLayout.setSpacing(false); |
|
|
|
|
|
} |
|
|
} |
|
|
} |