From 5ced7f916d94e86e9a7ec164bee56f9a8e3a2a3a Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 26 May 2025 10:48:43 +0200 Subject: Replace Azure SWA with custom server --- src/pages/Estimates.tsx | 99 ----------------------------------- src/pages/Map.tsx | 75 --------------------------- src/pages/Settings.tsx | 65 ----------------------- src/pages/StopList.tsx | 135 ------------------------------------------------ 4 files changed, 374 deletions(-) delete mode 100644 src/pages/Estimates.tsx delete mode 100644 src/pages/Map.tsx delete mode 100644 src/pages/Settings.tsx delete mode 100644 src/pages/StopList.tsx (limited to 'src/pages') diff --git a/src/pages/Estimates.tsx b/src/pages/Estimates.tsx deleted file mode 100644 index 7cf941a..0000000 --- a/src/pages/Estimates.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { JSX, useEffect, useState } from "react"; -import { useParams } from "react-router"; -import StopDataProvider from "../data/StopDataProvider"; -import { Star, Edit2 } from 'lucide-react'; -import "../styles/Estimates.css"; -import { RegularTable } from "../components/RegularTable"; -import { useApp } from "../AppContext"; -import { GroupedTable } from "../components/GroupedTable"; - -export interface StopDetails { - stop: { - id: number; - name: string; - latitude: number; - longitude: number; - } - estimates: { - line: string; - route: string; - minutes: number; - meters: number; - }[] -} - -const loadData = async (stopId: string) => { - const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`); - return await resp.json(); -}; - -export function Estimates(): JSX.Element { - const params = useParams(); - const stopIdNum = parseInt(params.stopId ?? ""); - const [customName, setCustomName] = useState(undefined); - const [data, setData] = useState(null); - const [dataDate, setDataDate] = useState(null); - const [favourited, setFavourited] = useState(false); - const { tableStyle } = useApp(); - - useEffect(() => { - loadData(params.stopId!) - .then((body: StopDetails) => { - setData(body); - setDataDate(new Date()); - setCustomName(StopDataProvider.getCustomName(stopIdNum)); - }) - - - StopDataProvider.pushRecent(parseInt(params.stopId ?? "")); - - setFavourited( - StopDataProvider.isFavourite(parseInt(params.stopId ?? "")) - ); - }, [params.stopId]); - - - const toggleFavourite = () => { - if (favourited) { - StopDataProvider.removeFavourite(stopIdNum); - setFavourited(false); - } else { - StopDataProvider.addFavourite(stopIdNum); - setFavourited(true); - } - } - - const handleRename = () => { - const current = customName ?? data?.stop.name; - const input = window.prompt('Custom name for this stop:', current); - if (input === null) return; // cancelled - const trimmed = input.trim(); - if (trimmed === '') { - StopDataProvider.removeCustomName(stopIdNum); - setCustomName(undefined); - } else { - StopDataProvider.setCustomName(stopIdNum, trimmed); - setCustomName(trimmed); - } - }; - - if (data === null) return

Cargando datos en tiempo real...

- - return ( -
-
-

- - - {(customName ?? data.stop.name)} ({data.stop.id}) -

-
- -
- {tableStyle === 'grouped' ? - : - } -
-
- ) -} diff --git a/src/pages/Map.tsx b/src/pages/Map.tsx deleted file mode 100644 index 1f0a9e0..0000000 --- a/src/pages/Map.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import StopDataProvider, { Stop } from "../data/StopDataProvider"; - -import 'leaflet/dist/leaflet.css' -import 'react-leaflet-markercluster/styles' - -import { useEffect, useState } from 'react'; -import LineIcon from '../components/LineIcon'; -import { Link } from 'react-router'; -import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from "react-leaflet"; -import MarkerClusterGroup from "react-leaflet-markercluster"; -import { Icon, LatLngTuple } from "leaflet"; -import { EnhancedLocateControl } from "../controls/LocateControl"; -import { useApp } from "../AppContext"; - -const icon = new Icon({ - iconUrl: '/map-pin-icon.png', - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - shadowSize: [41, 41] -}); - -// Componente auxiliar para detectar cambios en el mapa -const MapEventHandler = () => { - const { updateMapState } = useApp(); - - const map = useMapEvents({ - moveend: () => { - const center = map.getCenter(); - const zoom = map.getZoom(); - updateMapState([center.lat, center.lng], zoom); - } - }); - - return null; -}; - -// Componente principal del mapa -export function StopMap() { - const [stops, setStops] = useState([]); - const { mapState } = useApp(); - - useEffect(() => { - StopDataProvider.getStops().then(setStops); - }, []); - - return ( - - - - - - {stops.map(stop => ( - - - {StopDataProvider.getDisplayName(stop)} -
- {stop.lines.map((line) => ( - - ))} -
-
- ))} -
-
- ); -} diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx deleted file mode 100644 index 1ad15ab..0000000 --- a/src/pages/Settings.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { useApp } from "../AppContext"; -import "../styles/Settings.css"; - -export function Settings() { - const { theme, setTheme, tableStyle, setTableStyle, mapPositionMode, setMapPositionMode } = useApp(); - - return ( -
-

Sobre UrbanoVigo Web

-

- Aplicación web para encontrar paradas y tiempos de llegada de los autobuses - urbanos de Vigo, España. -

-
-

Ajustes

-
- - -
-
- - -
-
- - -
-
- ¿Qué significa esto? -

- La tabla de horarios puede mostrarse de dos formas: -

-
-
Mostrar por orden
-
Las paradas se muestran en el orden en que se visitan. Aplicaciones como Infobus (Vitrasa) usan este estilo.
-
Agrupar por línea
-
Las paradas se agrupan por la línea de autobús. Aplicaciones como iTranvias (A Coruña) o Moovit (más o menos) usan este estilo.
-
-
-
-

Créditos

-

- - Código en GitHub - - - Desarrollado por - Ariel Costas - -

-

- Datos obtenidos de datos.vigo.org bajo - licencia Open Data Commons Attribution License -

-
- ) -} \ No newline at end of file diff --git a/src/pages/StopList.tsx b/src/pages/StopList.tsx deleted file mode 100644 index b965456..0000000 --- a/src/pages/StopList.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import { useEffect, useMemo, useRef, useState } from "react"; -import StopDataProvider, { Stop } from "../data/StopDataProvider"; -import StopItem from "../components/StopItem"; -import Fuse from "fuse.js"; - -const placeholders = [ - "Urzaiz", - "Gran Vía", - "Castelao", - "García Barbón", - "Valladares", - "Florida", - "Pizarro", - "Estrada Madrid", - "Sanjurjo Badía" -]; - -export function StopList() { - const [data, setData] = useState(null) - const [searchResults, setSearchResults] = useState(null); - const searchTimeout = useRef(null); - - const randomPlaceholder = useMemo(() => placeholders[Math.floor(Math.random() * placeholders.length)], []); - const fuse = useMemo(() => new Fuse(data || [], { threshold: 0.3, keys: ['name.original'] }), [data]); - - useEffect(() => { - StopDataProvider.getStops().then((stops: Stop[]) => setData(stops)) - }, []); - - const handleStopSearch = (event: React.ChangeEvent) => { - const stopName = event.target.value || ""; - - if (searchTimeout.current) { - clearTimeout(searchTimeout.current); - } - - searchTimeout.current = setTimeout(() => { - if (stopName.length === 0) { - setSearchResults(null); - return; - } - - if (!data) { - console.error("No data available for search"); - return; - } - - const results = fuse.search(stopName); - const items = results.map(result => result.item); - setSearchResults(items); - }, 300); - } - - const favouritedStops = useMemo(() => { - return data?.filter(stop => stop.favourite) ?? [] - }, [data]) - - const recentStops = useMemo(() => { - // no recent items if data not loaded - if (!data) return null; - const recentIds = StopDataProvider.getRecent(); - if (recentIds.length === 0) return null; - // map and filter out missing entries - const stopsList = recentIds - .map(id => data.find(stop => stop.stopId === id)) - .filter((s): s is Stop => Boolean(s)); - return stopsList.reverse(); - }, [data]); - - if (data === null) return

Loading...

- - return ( -
-

UrbanoVigo Web

- -
-
- - -
-
- - {searchResults && searchResults.length > 0 && ( -
-

Resultados de la búsqueda

-
    - {searchResults.map((stop: Stop) => ( - - ))} -
-
- )} - -
-

Paradas favoritas

- - {favouritedStops?.length === 0 && ( -

- Accede a una parada y márcala como favorita para verla aquí. -

- )} - -
    - {favouritedStops?.sort((a, b) => a.stopId - b.stopId).map((stop: Stop) => ( - - ))} -
-
- - {recentStops && recentStops.length > 0 && ( -
-

Recientes

- -
    - {recentStops.map((stop: Stop) => ( - - ))} -
-
- )} - -
-

Paradas

- -
    - {data?.sort((a, b) => a.stopId - b.stopId).map((stop: Stop) => ( - - ))} -
-
-
- ) -} -- cgit v1.3