package mx.gob.jumapacelaya;

import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.html.Main;
import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.server.PWA;
import com.vaadin.flow.theme.Theme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;

/**
 * The entry point of the Spring Boot application.
 *
 * Use the @PWA annotation make the application installable on phones, tablets
 * and some desktop browsers.
 *
 */
@SpringBootApplication(exclude = ErrorMvcAutoConfiguration.class)
@Theme(value = "soportet.iv1.2")
@JsModule("@vaadin/vaadin-lumo-styles/presets/compact.js")
@PWA(name = "Sistema de Soporte Técnico", shortName = "Soporte T.I", iconPath = "images/960x960recortado.png")
public class Application implements AppShellConfigurator {

    private static final Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

        logger.info("Inicio de la aplicacion");

        conectToService("localhost:8080");

        logger.info("Aplicacion iniciada con exito");

    }

    private static void conectToService(String url) {
        logger.debug("Intentando conectar la aplicacion a {} ", url);

        try {
            Thread.sleep(2000);
            logger.debug("Conexion exitosa a {}", url);
        } catch (InterruptedException e) {
            logger.error("Error en la conexion a {}", url, e);
        }
    }
}
