feat(ui): add DHID/no DHID/ mixed DHID analysis to /:state route

This commit is contained in:
dancingCycle 2023-08-30 09:39:30 +02:00
parent 306aa0a6aa
commit c378219a18
7 changed files with 24 additions and 152 deletions

View File

@ -1,13 +1,11 @@
import React, { useState, useEffect } from 'react'
import { Link, BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
import Header from './components/header';
import Home from './pages/home';
import StopsNonConforming from './pages/stops-non-conforming';
import StopsRefined from './pages/stops-refined';
import StopNamesBb from './pages/stop-names-bb';
import StopNamesBy from './pages/stop-names-by';
import StopNamesNi from './pages/stop-names-ni';
import StopNames from './pages/stop-names';
import {
getGtfsStopsLastVacuum
@ -35,7 +33,6 @@ export default function App(){
return (
<div className='App'>
<Router>
<Header />
<h1>DELFI-Display</h1>
@ -66,11 +63,9 @@ export default function App(){
<Route exact path='/' element={<Home/>}/>
<Route exact path='/stops-non-compliant' element={<StopsNonConforming/>}/>
<Route exact path='/stops-refined' element={<StopsRefined/>}/>
<Route exact path='/stop-names-bb' element={<StopNamesBb/>}/>
<Route exact path='/stop-names-ni' element={<StopNamesNi/>}/>
<Route exact path='/stop-names-by' element={<StopNamesBy/>}/>
<Route path="/:state" element={<StopNames />} />
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</Router>
</div>
);
}

View File

@ -37,7 +37,7 @@ export default function State ({state}) {
}, []);
if (state !== undefined || state !== null || state === '') {
const linkStopNames = '/stop-names-' + state.toLowerCase();
const linkStopNames = '/' + state.toLowerCase();
//console.log('State: linkStopNames: ' + linkStopNames);
/*return a React element*/
return (

View File

@ -9,8 +9,10 @@ if (process.env.NODE_ENV !== 'production') {
//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(
<React.StrictMode>

View File

@ -1,66 +0,0 @@
import React, { useEffect, useState } from 'react';
import Table from '../components/table-stop-names';
import {get} from '../utils/request';
export default function StopNamesBy() {
const [countNoGi, setCountNoGi] = useState('loading...');
const [countPartGi, setCountPartGi] = useState('loading...');
const [namesNoGi, setNamesNoGi] = useState([]);
const [namesPartGi, setNamesPartGi] = useState([]);
useEffect(() => {
let address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-no-gi?state=by';
//console.log('StopNamesBy:useEffect() address: ' + address);
//get count no gi
get(address)
.then(data => {
setCountNoGi((countPartGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-part-gi?state=by';
//console.log('StopNamesBy:useEffect() address: ' + address);
//get count part gi
get(address)
.then(data => {
setCountPartGi((countNoGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-no-gi?state=by'
//console.log('StopNamesBy:useEffect() address: ' + address);
//get names no gi
get(address)
.then(data => {
setNamesNoGi((namesNoGi) => data);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-part-gi?state=by'
//console.log('StopNamesBy:useEffect() address: ' + address);
//get names part gi
get(address)
.then(data => {
setNamesPartGi((namesPartGi) => data);
});
}, []);
return (
<>
<p>
{countNoGi} stops do not use a Global ID as stop_name for any platform/ quay.
</p>
<Table array={namesNoGi} />
<p>
{countPartGi} stops use a Global ID as stop_name for some platforms/ quays.
</p>
<Table array={namesPartGi} />
</>
);
}

View File

@ -1,66 +0,0 @@
import React, { useEffect, useState } from 'react';
import Table from '../components/table-stop-names';
import {get} from '../utils/request';
export default function StopNamesNi() {
const [countNoGi, setCountNoGi] = useState('loading...');
const [countPartGi, setCountPartGi] = useState('loading...');
const [namesNoGi, setNamesNoGi] = useState([]);
const [namesPartGi, setNamesPartGi] = useState([]);
useEffect(() => {
let address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-no-gi?state=ni';
//console.log('StopNamesNi:useEffect() address: ' + address);
//get count no gi
get(address)
.then(data => {
setCountNoGi((countPartGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-part-gi?state=ni';
//console.log('StopNamesNi:useEffect() address: ' + address);
//get count part gi
get(address)
.then(data => {
setCountPartGi((countNoGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-no-gi?state=ni'
//console.log('StopNamesNi:useEffect() address: ' + address);
//get names no gi
get(address)
.then(data => {
setNamesNoGi((namesNoGi) => data);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-part-gi?state=ni'
//console.log('StopNamesNi:useEffect() address: ' + address);
//get names part gi
get(address)
.then(data => {
setNamesPartGi((namesPartGi) => data);
});
}, []);
return (
<>
<p>
{countNoGi} stops do not use a Global ID as stop_name for any platform/ quay.
</p>
<Table array={namesNoGi} />
<p>
{countPartGi} stops use a Global ID as stop_name for some platforms/ quays.
</p>
<Table array={namesPartGi} />
</>
);
}

View File

@ -1,9 +1,13 @@
import React, { useEffect, useState } from 'react';
import { useParams } from "react-router-dom";
import Table from '../components/table-stop-names';
import {get} from '../utils/request';
import Table from '../components/table-stop-names';
export default function StopNamesBb() {
export default function StopNames() {
// Get the userId param from the URL.
const { state } = useParams();
const [countNoGi, setCountNoGi] = useState('loading...');
const [countPartGi, setCountPartGi] = useState('loading...');
@ -11,9 +15,10 @@ export default function StopNamesBb() {
const [namesPartGi, setNamesPartGi] = useState([]);
useEffect(() => {
//console.log('StopNames:useEffect() state: ' + state);
let address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-no-gi?state=bb';
//console.log('StopNamesBb:useEffect() address: ' + address);
let address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-no-gi?state=' + state;
//console.log('StopNames:useEffect() address: ' + address);
//get count no gi
get(address)
@ -21,8 +26,8 @@ export default function StopNamesBb() {
setCountNoGi((countPartGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-part-gi?state=bb';
//console.log('StopNamesBb:useEffect() address: ' + address);
address = 'https://www.v1delfi.api.swingbe.de/stop-names-count-part-gi?state=' + state;
//console.log('StopNames:useEffect() address: ' + address);
//get count part gi
get(address)
@ -30,8 +35,8 @@ export default function StopNamesBb() {
setCountPartGi((countNoGi) => data[0].count);
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-no-gi?state=bb'
//console.log('StopNamesBb:useEffect() address: ' + address);
address = 'https://www.v1delfi.api.swingbe.de/stop-names-no-gi?state=' + state;
//console.log('StopNames:useEffect() address: ' + address);
//get names no gi
get(address)
@ -40,8 +45,8 @@ export default function StopNamesBb() {
});
address = 'https://www.v1delfi.api.swingbe.de/stop-names-part-gi?state=bb'
//console.log('StopNamesBb:useEffect() address: ' + address);
address = 'https://www.v1delfi.api.swingbe.de/stop-names-part-gi?state=' + state;
//console.log('StopNames:useEffect() address: ' + address);
//get names part gi
get(address)

View File

@ -10,5 +10,7 @@ module.exports = merge(common, {
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
//When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. Enable devServer.historyApiFallback by setting it to true.
historyApiFallback: true,
},
});