Compare commits
6 Commits
266d1605d4
...
master
Author | SHA1 | Date | |
---|---|---|---|
b15207d18d | |||
7468d74b92 | |||
d6fe70b38e | |||
5405e93d27 | |||
b24b59f619 | |||
a551d70bd4 |
20
Dockerfile
20
Dockerfile
@ -1,13 +1,21 @@
|
|||||||
FROM alpine:3.14
|
# Usar la versión más reciente de Node.js sobre Alpine
|
||||||
|
FROM node:current-alpine
|
||||||
RUN apk update && apk add --no-cache nodejs npm make g++
|
|
||||||
|
|
||||||
|
# Establecer el directorio de trabajo dentro del contenedor
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
# Copiar los archivos necesarios
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Instalar las dependencias
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
CMD ["npm", "run", "build"]
|
# Copiar el resto del código fuente
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Exponer el puerto que Vite utiliza (5173)
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
# Comando para iniciar el servidor de desarrollo
|
||||||
|
CMD ["npm", "run", "dev"]
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite --host",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
@ -2,20 +2,42 @@ import ApiResponse from "../interfaces/ApiResponse";
|
|||||||
import Embalse from "../interfaces/Embalse";
|
import Embalse from "../interfaces/Embalse";
|
||||||
import Env from "./Env";
|
import Env from "./Env";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper API de la REST de Oracle DB
|
||||||
|
*/
|
||||||
export default class Api {
|
export default class Api {
|
||||||
|
/**
|
||||||
|
* Conseguir todos los embalses
|
||||||
|
*/
|
||||||
static async embalses(): Promise<Embalse[]> {
|
static async embalses(): Promise<Embalse[]> {
|
||||||
return Api._makeReq('/embalses');
|
return Api._makeReq('/embalses');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conseguir embalse a partir de su id
|
||||||
|
* @param id ID del embalse
|
||||||
|
* @returns Lista de embalses que coinciden con la búsqueda
|
||||||
|
*/
|
||||||
static async embalseById(id: string): Promise<Embalse[]> {
|
static async embalseById(id: string): Promise<Embalse[]> {
|
||||||
return Api._makeReq(`/embalses/${id}`);
|
return Api._makeReq(`/embalses/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conseguir todos los embalses cercanos
|
||||||
|
* @param lat Latitud
|
||||||
|
* @param lon Longitud
|
||||||
|
* @returns Lista de embalses cercanos
|
||||||
|
*/
|
||||||
static async embalsesNearby(lat: string, lon: string): Promise<Embalse[]> {
|
static async embalsesNearby(lat: string, lon: string): Promise<Embalse[]> {
|
||||||
return Api._makeReq(`/embalsesCercanos/${lat}/${lon}`);
|
return Api._makeReq(`/embalsesCercanos/${lat}/${lon}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async _makeReq<T>(endpoint: string): Promise<T[]> {
|
/**
|
||||||
|
* Método privado para enviar solicitudes
|
||||||
|
* @param endpoint Endpoint requerido
|
||||||
|
* @returns Lista de elementos
|
||||||
|
*/
|
||||||
|
private static async _makeReq<T>(endpoint: string): Promise<T[]> {
|
||||||
let hasMore = true;
|
let hasMore = true;
|
||||||
|
|
||||||
let url = Env.api_base() + endpoint;
|
let url = Env.api_base() + endpoint;
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Helper para conseguir las variables del entorno
|
||||||
|
*/
|
||||||
export default class Env {
|
export default class Env {
|
||||||
|
/**
|
||||||
|
* Base de API
|
||||||
|
*/
|
||||||
static api_base(): string {
|
static api_base(): string {
|
||||||
return import.meta.env.VITE_API_BASE;
|
return import.meta.env.VITE_API_BASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clave API de OpenWeatherMap
|
||||||
|
*/
|
||||||
|
static owm_key(): string {
|
||||||
|
return import.meta.env.VITE_OWM_KEY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Respuesta de Oracle DB
|
||||||
|
*/
|
||||||
export default interface ApiResponse<T> {
|
export default interface ApiResponse<T> {
|
||||||
items: T[];
|
items: T[];
|
||||||
hasMore: boolean;
|
hasMore: boolean;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Datos del embalse
|
||||||
|
*/
|
||||||
export default interface Embalse {
|
export default interface Embalse {
|
||||||
id: number
|
id: number
|
||||||
ambito_nombre: string
|
ambito_nombre: string
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Respuesta de la API OpenWeatherMap
|
||||||
|
*/
|
||||||
export default interface OWMResponse {
|
export default interface OWMResponse {
|
||||||
cod: string
|
cod: string
|
||||||
message: number
|
message: number
|
||||||
@ -32,7 +35,7 @@ export interface Main {
|
|||||||
|
|
||||||
export interface Weather {
|
export interface Weather {
|
||||||
id: number
|
id: number
|
||||||
main: string
|
main: Main
|
||||||
description: string
|
description: string
|
||||||
icon: string
|
icon: string
|
||||||
}
|
}
|
||||||
|
2
src/styles/bulma.scss
vendored
2
src/styles/bulma.scss
vendored
@ -1,3 +1,5 @@
|
|||||||
@charset 'utf8';
|
@charset 'utf8';
|
||||||
|
|
||||||
|
// TODO: MODULAR
|
||||||
|
|
||||||
@forward 'bulma/sass';
|
@forward 'bulma/sass';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/** Spinner */
|
||||||
|
|
||||||
.loader {
|
.loader {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { createSignal, onCleanup, onMount } from "solid-js";
|
import { createSignal, onCleanup, onMount } from "solid-js";
|
||||||
import { useNavigate } from "@solidjs/router";
|
import { useNavigate } from "@solidjs/router";
|
||||||
import L, { Icon } from 'leaflet';
|
import L from 'leaflet';
|
||||||
import { FaSolidLocationPin } from "solid-icons/fa";
|
import { FaSolidLocationPin } from "solid-icons/fa";
|
||||||
import Navbar from "../partials/Navbar";
|
import Navbar from "../partials/Navbar";
|
||||||
import Api from "../helpers/Api";
|
import Api from "../helpers/Api";
|
||||||
|
@ -17,27 +17,17 @@ function Home() {
|
|||||||
<div class="columns is-centered">
|
<div class="columns is-centered">
|
||||||
<div class="column is-half">
|
<div class="column is-half">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="columns is-centered is-vcentered is-mobile">
|
<p class="title">
|
||||||
<div class="column is-4">
|
<span class="icon-text">
|
||||||
<figure class="image is-128x128">
|
<span class="icon">
|
||||||
{/* TODO: Agregar icono */}
|
<FaSolidGlassWaterDroplet />
|
||||||
<img src="https://bulma.io/assets/images/placeholders/128x128.png" />
|
</span>
|
||||||
</figure>
|
<span>Malackathon</span>
|
||||||
</div>
|
</span>
|
||||||
<div class="column is-8">
|
</p>
|
||||||
<p class="title">
|
<div class="buttons is-centered">
|
||||||
<span class="icon-text">
|
<A class="button is-primary" href="/embalses">Todos los embalses</A>
|
||||||
<span class="icon">
|
<A class="button is-primary" href="/embalses/nearby">Buscar</A>
|
||||||
<FaSolidGlassWaterDroplet />
|
|
||||||
</span>
|
|
||||||
<span>Malackathon</span>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<div class="buttons">
|
|
||||||
<A class="button is-primary" href="/embalses">Todos los embalses</A>
|
|
||||||
<A class="button is-primary" href="/embalses/nearby">Buscar</A>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,8 +2,11 @@ import { onMount } from "solid-js";
|
|||||||
import L from 'leaflet';
|
import L from 'leaflet';
|
||||||
import Embalse from "../interfaces/Embalse";
|
import Embalse from "../interfaces/Embalse";
|
||||||
import Api from "../helpers/Api";
|
import Api from "../helpers/Api";
|
||||||
|
import { useNavigate } from "@solidjs/router";
|
||||||
|
import Navbar from "../partials/Navbar";
|
||||||
|
|
||||||
function Viewer() {
|
function Viewer() {
|
||||||
|
const navigate = useNavigate();
|
||||||
let map: L.Map;
|
let map: L.Map;
|
||||||
|
|
||||||
let embalses: Embalse[] = [];
|
let embalses: Embalse[] = [];
|
||||||
@ -21,17 +24,20 @@ function Viewer() {
|
|||||||
const getEmbalses = async () => {
|
const getEmbalses = async () => {
|
||||||
embalses = await Api.embalses();
|
embalses = await Api.embalses();
|
||||||
|
|
||||||
embalses.forEach(embalse => {
|
embalses.forEach(c => {
|
||||||
L.marker([parseFloat(embalse.x), parseFloat(embalse.y)]).addTo(map);
|
L.marker([parseFloat(c.x), parseFloat(c.y)]).on('click', () => navigate('/embalses/' + c.id)).addTo(map);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="container">
|
<>
|
||||||
<div id="map" style={{
|
<Navbar />
|
||||||
height: '70vh'
|
<div class="container has-text-centered">
|
||||||
}}></div>
|
<div id="map" style={{
|
||||||
</div>
|
height: '70vh'
|
||||||
|
}}></div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user