// METODOS DE LECTURA DE LA API DE EMACENTER - (VUE) function Cargar_API_VUE() { //Si no esta cargada se carga. const Url = "https://emacenter.gugler.com.ar/api/station/"; var intensidad=0; API_EMA = new Vue( { el: '#app', data() { return { servidor_estado: false, servidor_error: false, tiempo_enlinea: 0, grafico: false, tabla: false, observaciones: [], datatable:[], estadisticas: [], estaciones: [], nombre: "", modelo: "", pais: "", ciudad: "", calle: "", latitud: "", longitud: "", altura: "", fecha_ultimo_registro: "", uptime: "", distancia: "", software: "", cargando: false, estacion_selecionada: false, } }, methods: { // API - Lectura Estaciones de emacenter ObtenerEstaciones() { console.log('Buscando estaciones...'); axios .get(Url) .then(response => ( this.estaciones = response.data, this.servidor_estado = true, this.servidor_error = false, MenuBuqueda(API_EMA.estaciones), //Carga el Menu Superior de Busqueda Con las Estaciones Obtener_Permisos_del_Navegador_GPS() // Busca la mas cercana y si no hay acceso al GPS, pone por default )) .catch(e => { this.servidor_estado = false, this.servidor_error = true }); }, // API - Lectura Registros de una estacion especifica. LeerRegistroEstacion(estacion, mostrar_grafico) { this.uptime = "Obteniendo datos.."; console.log(estacion); this.cargando = true; axios .get(Url + estacion + '/', { param: { 'estacion': estacion } }) .then(response => (moment.locale('es'), this.nombre = response.data.nombre, this.modelo = response.data.modelo, this.pais = response.data.pais, this.ciudad = response.data.ciudad, this.calle = response.data.calle, this.latitud = response.data.latitud, this.longitud = response.data.longitud, this.altura = Number(response.data.altura).toFixed(2), this.fecha_ultimo_registro = moment(response.data.fecha_ultimo_registro).format('DD/MM/YYYY H:mm:ss'), this.software = response.data.registros[0].software, this.observaciones = response.data.registros, intensidad = response.data.registros[0].luxer_intencidad, this.datatable = response.data.registros, this.estadisticas = response.data.estadisticas, this.uptime = moment(this.fecha_ultimo_registro, "DD/MM/YYYY h:mm:ss a").fromNow(), this.cargando = false, this.tiempo_enlinea = moment(moment(), "DD/MM/YYYY HH:mm:ss").diff(moment(this.fecha_ultimo_registro, "DD/MM/YYYY HH:mm:ss")) / 60000 )) .catch(e => { console.log(e) }) .then(function () { if (mostrar_grafico) Mostrar_Graficos(); ActualizarGraficos() ArmarDatatable() console.log(intensidad) CambiarFondo(intensidad) }) } }, created() { //Lectura Continua de una estacion desde la cookie console.log('API Cagarda.'); setInterval(function () { this.LeerRegistroEstacion(getCookie('estacion_seleccionada'), false); }.bind(this), 30000); }, }) }