Skip to content

Commit

Permalink
Merge branch 'mobility-profile-routing-2' into trusted-companions
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-willis-arcadis committed Oct 23, 2024
2 parents 600fd50 + c403cf0 commit 7349731
Show file tree
Hide file tree
Showing 66 changed files with 7,050 additions and 2,092 deletions.
5,656 changes: 4,779 additions & 877 deletions __tests__/components/viewers/__snapshots__/nearby-view.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ exports[`components > viewers > stop viewer should render with initial stop id a
>
<Styled(styled.span)>
<span
className="sc-jifHHV sc-hkwmXC frJUIW gWGcte"
className="sc-hkwmXC sc-bSFUlv eFsrhn gAUjbw"
>
<ArrowLeft>
<StyledIconBase
Expand Down Expand Up @@ -267,11 +267,11 @@ exports[`components > viewers > stop viewer should render with initial stop id a
</div>
<styled.div>
<div
className="sc-hJxDiT dbjOgr"
className="sc-cuWdqJ jtAZHv"
>
<styled.div>
<div
className="sc-jlIlqL sdJoA"
className="sc-iWRHom bUIXtU"
>
<h1>
<FormattedMessage
Expand Down
2 changes: 1 addition & 1 deletion a11y/a11y.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ beforeAll(async () => {
})
// Web security is disabled to allow requests to the mock OTP server
browser = await puppeteer.launch({
args: ['--disable-web-security']
args: ['--disable-web-security', '--no-sandbox']
})
})

Expand Down
28 changes: 27 additions & 1 deletion craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ module.exports = {
findBackwardsCompatibleEnvVar('JS_CONFIG')
backwardsCompatibleEnv.HTML_FILE =
findBackwardsCompatibleEnvVar('HTML_FILE')
backwardsCompatibleEnv.PLAN_QUERY_RESOURCE_URI =
findBackwardsCompatibleEnvVar('PLAN_QUERY_RESOURCE_URI')
backwardsCompatibleEnv.CUSTOM_CSS =
findBackwardsCompatibleEnvVar('CUSTOM_CSS')

Expand All @@ -65,6 +67,13 @@ module.exports = {
}
addBeforeLoader(webpackConfig, loaderByName('file-loader'), yamlLoader)

// Support YAML
const graphqlLoader = {
loader: ['raw-loader'],
test: /\.graphql$/
}
addBeforeLoader(webpackConfig, loaderByName('file-loader'), graphqlLoader)

// Support webfonts (for font awesome)
const webfontLoader = {
loader: ['url-loader'],
Expand All @@ -82,7 +91,7 @@ module.exports = {
loader.exclude = /node_modules/
})

// Gather the CSS, HTML, YAML, and JS override files.
// Gather the CSS, HTML, YAML, GraphQL, and JS override files.
const CUSTOM_CSS =
(process.env && process.env.CUSTOM_CSS) ||
backwardsCompatibleEnv.CUSTOM_CSS ||
Expand All @@ -91,6 +100,22 @@ module.exports = {
(process.env && process.env.HTML_FILE) ||
backwardsCompatibleEnv.HTML_FILE ||
'lib/index.tpl.html'
// resolve the custom GraphQL file. If it is present, copy the file to a
// temporary folder within this project so that it can be bundled and loaded at runtime.
let customPlanGraphQLFile = './planQuery.graphql'
const PLAN_QUERY_RESOURCE_URI =
(process.env && process.env.PLAN_QUERY_RESOURCE_URI) ||
backwardsCompatibleEnv.PLAN_QUERY_RESOURCE_URI ||
'node_modules/@opentripplanner/core-utils/src/planQuery.graphql'
if (PLAN_QUERY_RESOURCE_URI) {
const splitPath = PLAN_QUERY_RESOURCE_URI.split(path.sep)
customPlanGraphQLFile = `../tmp/${splitPath[splitPath.length - 1]}`
// copy location is relative to root, while js file for app is relative to lib
fs.copySync(
PLAN_QUERY_RESOURCE_URI,
`./tmp/${splitPath[splitPath.length - 1]}`
)
}
const YAML_CONFIG =
(process.env && process.env.YAML_CONFIG) ||
backwardsCompatibleEnv.YAML_CONFIG ||
Expand Down Expand Up @@ -143,6 +168,7 @@ module.exports = {
new webpack.DefinePlugin({
CSS: JSON.stringify(CUSTOM_CSS),
JS_CONFIG: JSON.stringify(customJsFile),
PLAN_QUERY_RESOURCE: JSON.stringify(customPlanGraphQLFile),
// Optionally override the default config files with some other
// files.
YAML_CONFIG: JSON.stringify(YAML_CONFIG)
Expand Down
12 changes: 12 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ persistence:
# iconUrl: ''
# href: ''

### These settings are only used for the field trip features.
dateTime:
timeFormat: h:mm a
dateFormat: MM/dd/yyyy

map:
initLat: 45.52
initLon: -122.682
Expand Down Expand Up @@ -411,6 +416,8 @@ itinerary:
displayA11yError: false
# Whether to display itinerary info in the side of the preview or next to the departure times
showInlineItinerarySummary: false
# Whether to sync the sort type with the depart/arrive time in the date/time modal
syncSortWithDepartArrive: true
# The sort option to use by default
# Available sort options: 'BEST', 'DURATION', 'ARRIVALTIME', 'WALKTIME', 'COST', 'DEPARTURETIME'
# defaultSort: "BEST" # Default
Expand All @@ -426,6 +433,11 @@ itinerary:
# - 'DEPARTURETIME'
# In the batch itinerary UI, this setting will always show both departure/arrival times
alwaysShowBothTimes: false
advancedSettingsPanel:
# Show button in advanced panel that allows users to save and return
saveAndReturnButton: true
# Prevent users from selecting a single day for saving trips.
disableSingleItineraryDays: false

# The transitOperators key is a list of transit operators that can be used to
# order transit agencies when sorting by route. Also, this can optionally
Expand Down
15 changes: 11 additions & 4 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ common:
submitting: Submitting…
"yes": "Yes"
itineraryDescriptions:
calories: "{calories, number} Cal"
fareUnknown: No fare information
noItineraryToDisplay: No itinerary to display.
relativeCo2: |
{co2} {isMore, select, true {more} other {less} } CO₂ than driving alone
timeStartEnd: "{start} – {end}"
transfers: "{transfers, plural, =0 {} one {# transfer} other {# transfers}}"
linkOpensNewWindow: (Opens new window)
modes:
bicycle_rent: Bikeshare
Expand Down Expand Up @@ -154,7 +152,6 @@ common:
enterStartLocation: Enter start location or {mapAction} on map…
tap: tap
time:
departureArrivalTimes: "{startTime, time, short}—{endTime, time, short}"
duration:
aFewSeconds: a few seconds
nDays: "{days, plural, =1 {one day} other {# days}}"
Expand Down Expand Up @@ -196,8 +193,15 @@ components:
BatchRoutingPanel:
shortTitle: Plan Trip
BatchSearchScreen:
advancedHeader: Advanced Preferences
header: Plan Your Trip
modeOptions: Mode Options
modeSelectorLabel: Select a travel mode
moreOptions: More options
saveAndReturn: Save and return
saved: Saved
submodeSelectorLabel: Select travel modes and submodes
tripOptions: Trip Options
BatchSettings:
destination: destination
invalidModeSelection: >-
Expand Down Expand Up @@ -276,7 +280,6 @@ components:
ariaLabel: Form navigation
ItinerarySummary:
itineraryDetails: Itinerary details
minMaxFare: "{minTotalFare} - {maxTotalFare}"
LocationSearch:
enterLocation: Enter location
setDestination: Set Destination
Expand Down Expand Up @@ -371,6 +374,7 @@ components:
distanceAway: "{localizedDistanceString} away"
error: An error occurred loading nearby amenities.
header: Nearby View
headsign: "{destination}"
nearbyListIntro: List of {count} nearby entities.
nothingNearby: There are no places nearby.
spacesAvailable: "{spacesAvailable} empty spaces available"
Expand Down Expand Up @@ -539,6 +543,7 @@ components:
SavedTripScreen:
itineraryLoaded: Itinerary loaded
itineraryLoading: Loading itinerary
selectAtLeastOneDay: Please select at least one day to monitor.
tooManyTrips: >
You already have reached the maximum of five saved trips. Please remove
unused trips from your saved trips, and try again.
Expand Down Expand Up @@ -640,6 +645,8 @@ components:
oneHour: 1 hour
realtimeAlertFlagged: There is a realtime alert flagged on my journey
timeBefore: "{time} before"
TripPreviewLayout:
previewTrip: Preview Trip
TripStatus:
alerts: "{alerts, plural, one {# alert!} other {# alerts!}}"
deleteTrip: Delete Trip
Expand Down
17 changes: 11 additions & 6 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ common:
submitting: Envoi en cours…
"yes": Oui
itineraryDescriptions:
calories: "{calories, number} kcal"
fareUnknown: Tarif inconnu
noItineraryToDisplay: Aucun trajet à afficher.
relativeCo2: |
{co2} de CO₂ en {isMore, select, true {plus} other {moins} } qu'en voiture
timeStartEnd: "{start} – {end}"
transfers: >-
{transfers, plural, =0 {} one {# correspondance} other {#
correspondances}}
linkOpensNewWindow: (Ouvre une nouvelle fenêtre)
modes:
bicycle_rent: En vélo en libre-service
Expand Down Expand Up @@ -165,7 +161,6 @@ common:
enterStartLocation: Entrez votre point de départ ou {mapAction} sur la carte…
tap: appuyez
time:
departureArrivalTimes: "{startTime, time, short}—{endTime, time, short}"
duration:
aFewSeconds: quelques secondes
nDays: "{days, plural, =1 {un jour} other {# jours}}"
Expand Down Expand Up @@ -209,8 +204,15 @@ components:
BatchRoutingPanel:
shortTitle: Planifier un trajet
BatchSearchScreen:
advancedHeader: Préférences avancées
header: Votre trajet
modeOptions: Choix du mode
modeSelectorLabel: Sélectionnez un mode de déplacement
moreOptions: Plus d'options
saveAndReturn: Enregistrer et fermer
saved: Enregistré
submodeSelectorLabel: Sélectionnez vos modes et sous-modes de déplacement
tripOptions: Options concernant le trajet
BatchSettings:
destination: destination
invalidModeSelection: >-
Expand Down Expand Up @@ -279,7 +281,6 @@ components:
ariaLabel: Navigation du formulaire
ItinerarySummary:
itineraryDetails: Détails du trajet
minMaxFare: "{minTotalFare} - {maxTotalFare}"
LocationSearch:
enterLocation: Entrez le lieu
setDestination: Destination
Expand Down Expand Up @@ -376,6 +377,7 @@ components:
distanceAway: à {localizedDistanceString}
error: Erreur lors du chargement des services à proximité.
header: À proximité
headsign: "{destination}"
nearbyListIntro: Liste de {count} entités à proximité.
nothingNearby: Aucun lieu à proximité.
spacesAvailable: "{spacesAvailable} emplacements libres disponibles"
Expand Down Expand Up @@ -549,6 +551,7 @@ components:
SavedTripScreen:
itineraryLoaded: Trajet chargé
itineraryLoading: Chargement du trajet
selectAtLeastOneDay: Veuillez choisir au moins un jour pour le suivi.
tooManyTrips: >
Vous avez déjà atteint le nombre maximum de 5 trajets enregistrés.
Veuillez supprimer les trajets enregistrés qui sont inutilisés, puis
Expand Down Expand Up @@ -660,6 +663,8 @@ components:
oneHour: 1 heure
realtimeAlertFlagged: Une alerte en temps réel affecte mon trajet
timeBefore: "{time} avant"
TripPreviewLayout:
previewTrip: Aperçu du trajet
TripStatus:
alerts: "{alerts, plural, =0 {# alerte !} one {# alerte !} other {# alertes !}}"
deleteTrip: Supprimer le trajet
Expand Down
62 changes: 54 additions & 8 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,13 @@ export const fetchNearby = (position, radius) => {
export const findStopTimesForStop = (params) =>
function (dispatch, getState) {
dispatch(fetchingStopTimesForStop(params))
const { date, stopId } = params
const { date, onlyRequestForOperators, stopId } = params
const timeZone = getState().otp.config.homeTimezone

// Create a service date timestamp from 3:30am local.
const serviceDay = getServiceStart(date, timeZone).getTime() / 1000

return dispatch(
createGraphQLQueryAction(
`query StopTimes(
const fullStopTimesQuery = `query StopTimes(
$serviceDay: Long!
$stopId: String!
) {
Expand Down Expand Up @@ -567,7 +565,48 @@ export const findStopTimesForStop = (params) =>
}
}
}
}`,
}`

const shorterStopTimesQueryForOperators = `query StopTimes(
$stopId: String!
) {
stop(id: $stopId) {
gtfsId
code
routes {
id: gtfsId
agency {
gtfsId
name
}
patterns {
id
headsign
}
}
stoptimesForPatterns(numberOfDepartures: 100, omitNonPickups: true, omitCanceled: false) {
pattern {
desc: name
headsign
id: code
route {
agency {
gtfsId
}
gtfsId
}
}
}
}
}`

const query = onlyRequestForOperators
? shorterStopTimesQueryForOperators
: fullStopTimesQuery

return dispatch(
createGraphQLQueryAction(
query,
{
serviceDay,
stopId
Expand Down Expand Up @@ -924,6 +963,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
return function (dispatch, getState) {
const state = getState()
const { config, currentQuery, modeSettingDefinitions } = state.otp
const { planQuery } = config.api
const { loggedInUser } = state.user
const persistenceMode = getPersistenceMode(config.persistence)
const activeItinerary =
Expand Down Expand Up @@ -999,7 +1039,6 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
},
date,
from: currentQuery.from,
mobilityProfile: loggedInUser?.mobilityProfile?.mobilityMode,
modes: modes || activeModes,
modeSettings,
time,
Expand All @@ -1009,6 +1048,9 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
...currentQuery,
numItineraries: numItineraries || getDefaultNumItineraries(config)
}
if (config.mobilityProfile) {
baseQuery.mobilityProfile = loggedInUser?.mobilityProfile?.mobilityMode
}
// Generate combinations if the modes for query are not specified in the query
// FIXME: BICYCLE_RENT does not appear in this list unless TRANSIT is also enabled.
// This is likely due to the fact that BICYCLE_RENT is treated as a transit submode.
Expand All @@ -1032,7 +1074,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
const query = generateOtp2Query(combo)
dispatch(
createGraphQLQueryAction(
query.query,
planQuery || query.query,
query.variables,
(response) => {
const dispatchedRoutingResponse = routingResponse(response)
Expand Down Expand Up @@ -1111,7 +1153,11 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
}
}
})
?.map(convertGraphQLResponseToLegacy)
?.map((leg) => ({
...convertGraphQLResponseToLegacy(leg),
route: leg.transitLeg ? leg.route : undefined
})),
otp2QueryParams: query.variables
})
)

Expand Down
Loading

0 comments on commit 7349731

Please sign in to comment.