@ -1,6 +1,7 @@
package mx.gob.jumapacelaya.ui ;
package mx.gob.jumapacelaya.ui ;
import com.vaadin.flow.component.Component ;
import com.vaadin.flow.component.Component ;
import com.vaadin.flow.component.UI ;
import com.vaadin.flow.component.button.Button ;
import com.vaadin.flow.component.button.Button ;
import com.vaadin.flow.component.button.ButtonVariant ;
import com.vaadin.flow.component.button.ButtonVariant ;
import com.vaadin.flow.component.checkbox.Checkbox ;
import com.vaadin.flow.component.checkbox.Checkbox ;
@ -33,6 +34,7 @@ import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.function.ValueProvider ;
import com.vaadin.flow.function.ValueProvider ;
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 com.vaadin.flow.server.StreamRegistration ;
import com.vaadin.flow.server.StreamResource ;
import com.vaadin.flow.server.StreamResource ;
import jakarta.annotation.security.PermitAll ;
import jakarta.annotation.security.PermitAll ;
import mx.gob.jumapacelaya.models.PlanAnual ;
import mx.gob.jumapacelaya.models.PlanAnual ;
@ -593,14 +595,17 @@ public class PlanAnualView extends VerticalLayout {
/ / Creando el recurso de descarga
/ / Creando el recurso de descarga
StreamResource resource = new StreamResource ( "reporte.pdf" , ( ) - > new ByteArrayInputStream ( pdf ) ) ;
StreamResource resource = new StreamResource ( "reporte.pdf" , ( ) - > new ByteArrayInputStream ( pdf ) ) ;
Anchor downloadLink = new Anchor ( resource , "Descargar Reporte" ) ;
/ * Anchor downloadLink = new Anchor ( resource , "Descargar Reporte" ) ;
downloadLink . setTarget ( "_blank" ) ;
downloadLink . setTarget ( "_blank" ) ;
downloadLink . setId ( "descargar-reporte-link" ) ;
downloadLink . setId ( "descargar-reporte-link" ) ;
add ( downloadLink ) ;
add ( downloadLink ) ;
getUI ( ) . ifPresent ( ui - >
getUI ( ) . ifPresent ( ui - >
ui . getPage ( ) . executeJs ( "document.getElementById('descargar-reporte-link').click();" )
ui . getPage ( ) . executeJs ( "document.getElementById('descargar-reporte-link').click();" )
) ;
) ; * /
StreamRegistration registration = UI . getCurrent ( ) . getSession ( ) . getResourceRegistry ( ) . registerResource ( resource ) ;
UI . getCurrent ( ) . getPage ( ) . executeJs ( "window.open('" + registration . getResourceUri ( ) . toString ( ) + "','_blank')" ) ;
} catch ( Exception ex ) {
} catch ( Exception ex ) {
@ -805,14 +810,17 @@ public class PlanAnualView extends VerticalLayout {
/ / Creando el recurso de descarga
/ / Creando el recurso de descarga
StreamResource resource = new StreamResource ( "listado_mantenimientos.pdf" , ( ) - > new ByteArrayInputStream ( pdf ) ) ;
StreamResource resource = new StreamResource ( "listado_mantenimientos.pdf" , ( ) - > new ByteArrayInputStream ( pdf ) ) ;
Anchor downloadLink = new Anchor ( resource , "Descargar Reporte" ) ;
/ * Anchor downloadLink = new Anchor ( resource , "Descargar Reporte" ) ;
downloadLink . setTarget ( "_blank" ) ;
downloadLink . setTarget ( "_blank" ) ;
downloadLink . setId ( "descargar-listado-link" ) ;
downloadLink . setId ( "descargar-listado-link" ) ;
add ( downloadLink ) ;
add ( downloadLink ) ;
getUI ( ) . ifPresent ( ui - >
getUI ( ) . ifPresent ( ui - >
ui . getPage ( ) . executeJs ( "document.getElementById('descargar-listado-link').click();" )
ui . getPage ( ) . executeJs ( "document.getElementById('descargar-listado-link').click();" )
) ;
) ; * /
StreamRegistration registration = UI . getCurrent ( ) . getSession ( ) . getResourceRegistry ( ) . registerResource ( resource ) ;
UI . getCurrent ( ) . getPage ( ) . executeJs ( "window.open('" + registration . getResourceUri ( ) . toString ( ) + "','_blank')" ) ;
} catch ( Exception ex ) {
} catch ( Exception ex ) {
Notification . show ( "Error al generar el reporte: " + ex . getMessage ( ) , 5000 , Notification . Position . MIDDLE )
Notification . show ( "Error al generar el reporte: " + ex . getMessage ( ) , 5000 , Notification . Position . MIDDLE )