Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New debug client #5334

Merged
merged 73 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f73f819
Initial commit of next debug client
testower Aug 29, 2023
c5b56a4
Add react-bootstrap framework
testower Aug 29, 2023
db741bf
Add map framework
testower Aug 29, 2023
6480b96
Basic setup of graphql integration
testower Aug 29, 2023
c8ca755
Add notes to readme and rename original readme for reference
testower Aug 29, 2023
d4fcce6
Rename to harmonize with type names
testower Aug 29, 2023
76239d6
Add variables to useCallback dependency list
testower Aug 29, 2023
5c5af9d
eslint: ignore generated types
testower Aug 30, 2023
1dda251
Configure linting and formatting
testower Aug 30, 2023
7dd851d
Apply formatting
testower Aug 30, 2023
9244bbb
Add temporary github workflow to verify build
testower Aug 30, 2023
e67a48a
Reorganize files
testower Sep 11, 2023
a27bcb4
Add container components
testower Sep 11, 2023
fd2e720
Set working directory for github workflow
testower Sep 11, 2023
b260fbd
Generate schema before running npm scripts
testower Sep 11, 2023
74f13d9
Schema is already checked into repo - this should not be necessary
testower Sep 11, 2023
cf70bd4
Codegen must run before linter
testower Sep 11, 2023
a5add6b
Fix type errors
testower Sep 11, 2023
79e6389
Revert "Fix type errors"
testower Sep 11, 2023
76ddaac
Fix type errors
testower Sep 11, 2023
e791dc1
No tests!
testower Sep 11, 2023
933c738
wip implement minimum search between coordinates
testower Sep 13, 2023
17b8ad1
Add marker icons and mode line colors
testower Sep 14, 2023
6ee77d4
Mostly refactoring1
testower Sep 21, 2023
cdde61d
Refactor search bar
testower Sep 22, 2023
53e8ce2
Silence eslint warning for named type imports
testower Sep 22, 2023
c1c4fce
Add DepartureArrivalSelect and refactor
testower Sep 25, 2023
1e1f84c
Itinerary list wip
testower Sep 26, 2023
acbf275
Add dynamic width for itinerary headers via hook
testower Sep 26, 2023
ccd7b85
Itinerary header wip
testower Sep 26, 2023
95c2c20
Fix overflow
testower Sep 26, 2023
0661d01
Use expected times
testower Sep 26, 2023
1c24cec
Refactor and fix type issues
testower Sep 27, 2023
dfa1c20
Leg content in itinerary headers
testower Sep 28, 2023
da6916a
Propagate itinerary selection to map view for leg lines
testower Oct 2, 2023
fec1a30
serve content from temporary path
testower Oct 2, 2023
b0ec42c
Refactor
testower Oct 2, 2023
4d8805c
Implement dateTime (time and date) search parameter
testower Oct 3, 2023
e2512ce
Implement searchWindow search parameter
testower Oct 3, 2023
29a2058
Style tweaks
testower Oct 5, 2023
d4d2a03
Add access and egress selects
testower Oct 5, 2023
f1189d2
Add direct mode and transit mode selects
testower Oct 30, 2023
b22af98
fix generic type
testower Oct 30, 2023
997f932
fix useCallback deps
testower Oct 30, 2023
bfb8c1f
tripPattern could be undefined when collapsing itinerary
testower Oct 30, 2023
ca43f3c
This TODO has been completed in a previous commit
testower Oct 31, 2023
22ed10e
Add numTripPatterns input
testower Oct 31, 2023
049cbbf
Fix searchwindow reset
testower Oct 31, 2023
9fbc722
Fix searchwindow reset
testower Oct 31, 2023
1a43790
Add itinerary filters debug input
testower Oct 31, 2023
ba58614
Misc fixes1
testower Oct 31, 2023
c80b685
Cleanup ci
testower Nov 20, 2023
07079d9
Add pagination and itinerary debug
testower Nov 20, 2023
80c528f
Remove detailsviewcontainer, to be added as modal
testower Nov 20, 2023
3a7ef03
Replace placeholder in search window input
testower Nov 20, 2023
ddafa45
Responsive search bar
testower Nov 20, 2023
cab5e4d
Add server info tooltip
testower Nov 21, 2023
88765aa
Fix compiler errors
testower Nov 21, 2023
1cc877e
Decouple access and egress mode selects
testower Nov 21, 2023
3803ada
Indicate whether non-delayed time has realtime info
testower Nov 21, 2023
4c36414
Remove console.log
testower Nov 22, 2023
6108e3e
Fire search query when flags are in position or moved
testower Nov 22, 2023
7e99d37
Add very ugly context menu for moving start/end locations from map
testower Nov 23, 2023
f34d91c
Build into ../src/client for web server access
testower Nov 23, 2023
fd552bc
Move ci to main config
testower Nov 23, 2023
f7570f8
Improve readme and add env for development api
testower Nov 23, 2023
1b50d5a
Formatting
testower Nov 23, 2023
89a8c44
Build client with docker image
testower Nov 23, 2023
f733ed2
Ignore Vite cache folder
testower Nov 24, 2023
d83ffd9
Extract context menu popup
testower Dec 13, 2023
447d94c
Named type for props
testower Dec 13, 2023
a827ea5
Empty outdir before build
testower Dec 13, 2023
2dbaa8b
Fix typo in readme
testower Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
distribution: temurin
cache: maven

- name: Build debug client
working-directory: ./client-next
run: |
npm install
npm run build

- name: Prepare coverage agent, build and test
# these are split into two steps because otherwise maven keeps long-running HTTP connections
# to Maven Central open which then hang during the package phase because the Azure (Github Actions)
Expand Down Expand Up @@ -208,6 +214,14 @@ jobs:
java-version: 17
distribution: temurin
cache: maven
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Build debug client
working-directory: ./client-next
run: |
npm install
npm run build
- name: Build container image with Jib, push to Dockerhub
env:
CONTAINER_REPO: docker.io/opentripplanner/opentripplanner
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ gen-py/
node_modules/
target/
/graphs
/src/client/debug-client-preview/

# for local dev only
/src/test/resources/speedtest/travelSearch-results-*.csv
Expand Down
1 change: 1 addition & 0 deletions client-next/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=/otp/routers/default/transmodel/index/graphql
1 change: 1 addition & 0 deletions client-next/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=http://localhost:8080/otp/routers/default/transmodel/index/graphql
42 changes: 42 additions & 0 deletions client-next/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:import/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/recommended',
'eslint-config-prettier',
],
ignorePatterns: ['node_modules', 'dist', '.prettierrc.js', '.eslintrc.cjs', 'src/gql/**/*'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
settings: {
react: {
// Tells eslint-plugin-react to automatically detect the version of React to use.
version: 'detect',
},
// Tells eslint how to resolve imports
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
'@typescript-eslint/ban-ts-comment': "off",

// TODO: this is a temporary fix for
// https://github.com/typescript-eslint/typescript-eslint/issues/154
"import/named": "off"
},
}
30 changes: 30 additions & 0 deletions client-next/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# generated code
src/gql/

# Vite cache folder
.vite/
3 changes: 3 additions & 0 deletions client-next/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
src/gql/
8 changes: 8 additions & 0 deletions client-next/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"printWidth": 120,
"bracketSpacing": true
}
27 changes: 27 additions & 0 deletions client-next/README-vite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
65 changes: 65 additions & 0 deletions client-next/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# OTP debug client (next)

This is the next version of the debug client, intended to replace `../src/client`.

It is designed to work with the Transmodel GraphQL API.

## Stack notes

This is a true Single Page Application (SPA) written in TypeScript on the React framework. It uses `vite` to run
(locally) and for building static assets. It requires no server runtime, and can be served from a CDN and run entirely
in the browser.

The design framework is Bootstrap with React support from `react-bootstrap`.

The map framework is MapLibre, using `MapLibre GL JS` with React support from `react-map-gl`.

GraphQL integration is provided by `graphql-request`, with type support added with `@graphql-codegen`. Types are
generated during build and are not checked into the repository.

## Prerequisites

Use latest LTS version of Node/npm (currently v18). Recommend using av version manager such as `nvm`.

The dev and production builds require graphql schema to be present at
`../src/ext/graphql/transmodelapi/schema.graphql`.

## Getting started (development)

Change directory to `client-next` (current) if you haven't already.

npm install

Then

npm run dev

The debug client will now be available at `http://localhost:5173/debug-client-preview`. It has
hot reloading enabled, so you don't have to restart it when you save files.

If you change graphql code during development you can issue the following command:

npm run codegen

You don't have to restart the development server for the changes to take effect.

## Build for production

Change directory to `client-next` (current) if you haven't already.

npm install

Then

npm run build

## Which OTP instance do I use?

In development mode, the debug client by default assumes you are running an OTP instance locally at
port 8080 (see `.env.development`). If you wish to point to a different OTP instance
(like a remote server), use the environment variable`VITE_API_URL`, either at the command line,
or add it to a new `.env.development.local` file (this file will be ignored by git).

In production mode, the default is to access OTP via the same origin as the client (see `.env`).
This behavior can also be modified by changing the previously mentioned environment variable at
build-time.
15 changes: 15 additions & 0 deletions client-next/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: '../src/ext/graphql/transmodelapi/schema.graphql',
documents: 'src/**/*.{ts,tsx}',
generates: {
'src/gql/': {
preset: 'client',
plugins: [],
},
},
};

export default config;
13 changes: 13 additions & 0 deletions client-next/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading