-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5918 from leonardehrenfried/debug-itinerary
Prettify leg view in debug client
- Loading branch information
Showing
11 changed files
with
97 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_API_URL=/otp/routers/default/transmodel/index/graphql | ||
VITE_API_URL=/otp/transmodel/v3 | ||
VITE_DEBUG_STYLE_URL=/otp/routers/default/inspector/vectortile/style.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_API_URL=http://localhost:8080/otp/routers/default/transmodel/index/graphql | ||
VITE_API_URL=http://localhost:8080/otp/transmodel/v3 | ||
VITE_DEBUG_STYLE_URL=http://localhost:8080/otp/routers/default/inspector/vectortile/style.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { TripQueryVariables } from '../gql/graphql.ts'; | ||
|
||
const DEFAULT_VARIABLES: TripQueryVariables = { | ||
from: {}, | ||
to: {}, | ||
dateTime: new Date().toISOString(), | ||
}; | ||
|
||
const getInitialVariables = () => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const variablesJson = urlParams.get('variables'); | ||
return variablesJson ? JSON.parse(decodeURIComponent(variablesJson)) : DEFAULT_VARIABLES; | ||
}; | ||
|
||
const updateUrlWithVariables = (variables: TripQueryVariables) => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
urlParams.set('variables', encodeURIComponent(JSON.stringify(variables))); | ||
history.pushState({}, '', '?' + urlParams.toString() + window.location.hash); | ||
}; | ||
|
||
export const useTripQueryVariables = () => { | ||
const [tripQueryVariables, setTripQueryVariables] = useState<TripQueryVariables>(getInitialVariables()); | ||
|
||
useEffect(() => { | ||
updateUrlWithVariables(tripQueryVariables); | ||
}, [tripQueryVariables]); | ||
|
||
return { | ||
tripQueryVariables, | ||
setTripQueryVariables, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters