@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map ;
import java.util.Map ;
import com.vaadin.flow.component.UI ;
import com.vaadin.flow.component.UI ;
import com.vaadin.flow.component.html.Anchor ;
import com.vaadin.flow.component.html.* ;
import com.vaadin.flow.server.StreamRegistration ;
import com.vaadin.flow.server.StreamRegistration ;
import com.vaadin.flow.server.StreamResource ;
import com.vaadin.flow.server.StreamResource ;
import mx.gob.jumapacelaya.services.EmailService ;
import mx.gob.jumapacelaya.services.EmailService ;
@ -24,9 +24,6 @@ import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dialog.Dialog ;
import com.vaadin.flow.component.dialog.Dialog ;
import com.vaadin.flow.component.grid.GridVariant ;
import com.vaadin.flow.component.grid.GridVariant ;
import com.vaadin.flow.component.gridpro.GridPro ;
import com.vaadin.flow.component.gridpro.GridPro ;
import com.vaadin.flow.component.html.H3 ;
import com.vaadin.flow.component.html.Image ;
import com.vaadin.flow.component.html.Span ;
import com.vaadin.flow.component.icon.Icon ;
import com.vaadin.flow.component.icon.Icon ;
import com.vaadin.flow.component.icon.VaadinIcon ;
import com.vaadin.flow.component.icon.VaadinIcon ;
import com.vaadin.flow.component.notification.Notification ;
import com.vaadin.flow.component.notification.Notification ;
@ -88,6 +85,7 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser
private Image firmaUsuarioImg ;
private Image firmaUsuarioImg ;
private Image firmaSmtImg ;
private Image firmaSmtImg ;
private Image firmaGciaImg ;
private Image firmaGciaImg ;
Notification avisoEncuestaNtf ;
private VerticalLayout userSignLayout ;
private VerticalLayout userSignLayout ;
private VerticalLayout smtSignLayout ;
private VerticalLayout smtSignLayout ;
@ -304,7 +302,10 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser
} ) ;
} ) ;
btnEnviarEncuesta . addClickListener ( e - > enviarCorreo ( ) ) ;
btnEnviarEncuesta . addClickListener ( e - > {
avisoEncuestaNtf . close ( ) ;
enviarCorreo ( ) ;
} ) ;
/ / Se dispara el dialogo de confirmacion
/ / Se dispara el dialogo de confirmacion
@ -527,7 +528,8 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser
String destinatario = usuarioDestino . getEmail ( ) ;
String destinatario = usuarioDestino . getEmail ( ) ;
String asunto = "Encuesta de satisfacción -Mantenimiento #" + mantenimientoIdActual ;
String asunto = "Encuesta de satisfacción -Mantenimiento #" + mantenimientoIdActual ;
String linkEncuesta = baseUrl + "/encuesta?mantenimientoId=" + mantenimientoIdActual ;
String token = service . crearTokenEncuesta ( mantenimientoIdActual ) ;
String linkEncuesta = baseUrl + "/encuesta?token=" + token ;
String cuerpo = "<html>" +
String cuerpo = "<html>" +
"<body>" +
"<body>" +
@ -554,12 +556,40 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser
? event . getLocation ( ) . getQueryParameters ( ) . getParameters ( ) . get ( "id" ) . stream ( ) . findFirst ( ) . orElse ( null )
? event . getLocation ( ) . getQueryParameters ( ) . getParameters ( ) . get ( "id" ) . stream ( ) . findFirst ( ) . orElse ( null )
: null ;
: null ;
String encParam = event . getLocation ( ) . getQueryParameters ( ) . getParameters ( ) . getOrDefault ( "enc" , List . of ( ) )
. stream ( ) . findFirst ( ) . orElse ( "N" ) . toUpperCase ( ) ;
if ( idParam ! = null ) {
if ( idParam ! = null ) {
try {
try {
int planId = Integer . parseInt ( idParam ) ;
int planId = Integer . parseInt ( idParam ) ;
DetalleMantenimientoModel detalle = service . getDetalleMantenimientoPorPlanAnualId ( planId ) ;
DetalleMantenimientoModel detalle = service . getDetalleMantenimientoPorPlanAnualId ( planId ) ;
if ( encParam . equalsIgnoreCase ( "N" ) ) {
Icon icono = new Icon ( VaadinIcon . WARNING ) ;
icono . setSize ( "40px" ) ;
NativeLabel aviso = new NativeLabel ( "Aviso:" ) ;
aviso . getStyle ( ) . set ( "font-weight" , "bold" ) ;
NativeLabel label = new NativeLabel ( "¡No se ha respondido una encuesta para este mantenimiento!" ) ;
VerticalLayout textLyt = new VerticalLayout ( aviso , label ) ;
textLyt . setPadding ( false ) ;
textLyt . setSpacing ( false ) ;
HorizontalLayout layout = new HorizontalLayout ( icono , textLyt ) ;
layout . setJustifyContentMode ( JustifyContentMode . CENTER ) ;
layout . setAlignItems ( Alignment . CENTER ) ;
avisoEncuestaNtf = new Notification ( layout ) ;
avisoEncuestaNtf . setPosition ( Notification . Position . TOP_CENTER ) ;
avisoEncuestaNtf . addThemeVariants ( NotificationVariant . LUMO_WARNING ) ;
avisoEncuestaNtf . setDuration ( 5000 ) ;
avisoEncuestaNtf . open ( ) ;
} else {
btnEnviarEncuesta . setEnabled ( false ) ;
btnEnviarEncuesta . getStyle ( ) . set ( "opacity" , "0.5" ) ;
}
if ( detalle ! = null ) {
if ( detalle ! = null ) {
this . planAnualIdActual = detalle . getPlanAnualId ( ) ;
this . planAnualIdActual = detalle . getPlanAnualId ( ) ;
this . mantenimientoIdActual = detalle . getId ( ) ;
this . mantenimientoIdActual = detalle . getId ( ) ;