diff --git a/lib/admin/actions/admin.js b/lib/admin/actions/admin.js index d7dcdb78e..cfb17a104 100644 --- a/lib/admin/actions/admin.js +++ b/lib/admin/actions/admin.js @@ -22,11 +22,11 @@ export const receiveUsers = createAction( export const requestingUsers = createVoidPayloadAction('REQUESTING_USERS') export const setUserPage = createAction( 'SET_USER_PAGE', - (payload: number /* page */) => payload + (payload: number) => payload ) export const setUserQueryString = createAction( 'SET_USER_QUERY_STRING', - (payload: string /* queryString */) => payload + (payload: string) => payload ) export type AdminActions = ActionType | diff --git a/lib/alerts/actions/alerts.js b/lib/alerts/actions/alerts.js index b8787576c..be17fae6f 100644 --- a/lib/alerts/actions/alerts.js +++ b/lib/alerts/actions/alerts.js @@ -79,6 +79,8 @@ export function setActiveAlert (alertId: number) { const alert = getState().alerts.all.find(a => a.id === alertId) if (alert) { dispatch(updateActiveAlert(alert)) + } else { + console.warn(`Could not find alert with id: ${alertId}`) } } } diff --git a/lib/editor/actions/editor.js b/lib/editor/actions/editor.js index 857891270..db7de941d 100644 --- a/lib/editor/actions/editor.js +++ b/lib/editor/actions/editor.js @@ -51,7 +51,10 @@ function getCloneProps (entityId: string, component: string, state: AppState) { const activeTable = getTableById(tables, component) switch (component) { case 'trippattern': - if (!active.entity) return + if (!active.entity) { + console.warn('no entity is active, unable to get clone props') + return + } const pattern = active.entity.tripPatterns.find(tp => tp.id === entityId) const newPatternId = generateUID() const newShapeId = generateUID() diff --git a/lib/gtfs/components/GtfsMap.js b/lib/gtfs/components/GtfsMap.js index 0c3f28f51..88a7df07f 100644 --- a/lib/gtfs/components/GtfsMap.js +++ b/lib/gtfs/components/GtfsMap.js @@ -199,7 +199,7 @@ export default class GtfsMap extends Component { const zoomLevel: number = this.refs.map.leafletElement.getZoom() const feedsToSearch = feeds || this.props.feeds || [] const ents = entities || this.props.entities - if ((feedsToSearch && feedsToSearch.length === 0) || zoomLevel > 13) { + if (feedsToSearch.length === 0 || zoomLevel > 13) { refreshGtfsElements(feedsToSearch, ents) } } diff --git a/lib/gtfs/components/PatternGeoJson.js b/lib/gtfs/components/PatternGeoJson.js index 1fec31255..78f8a5f69 100644 --- a/lib/gtfs/components/PatternGeoJson.js +++ b/lib/gtfs/components/PatternGeoJson.js @@ -26,9 +26,7 @@ export default class PatternGeoJson extends Component { _onClickAction = () => { const {onRouteClick, newEntityId, pattern} = this.props const {feed, route} = pattern - if (onRouteClick) { - onRouteClick(route, feed, newEntityId) - } + onRouteClick && onRouteClick(route, feed, newEntityId) } render () { diff --git a/lib/gtfs/components/StopMarker.js b/lib/gtfs/components/StopMarker.js index 6d765849f..7700d2336 100644 --- a/lib/gtfs/components/StopMarker.js +++ b/lib/gtfs/components/StopMarker.js @@ -23,9 +23,7 @@ export default class StopMarker extends Component { _onClick = () => { const {newEntityId, onStopClick, stop} = this.props const {feed} = stop - if (onStopClick) { - onStopClick(stop, feed, newEntityId) - } + onStopClick && onStopClick(stop, feed, newEntityId) } render () { diff --git a/lib/index.css b/lib/index.css index 34b3c8af3..33e55ca6f 100644 --- a/lib/index.css +++ b/lib/index.css @@ -1,6 +1,6 @@ @import url(node_modules/font-awesome/css/font-awesome.css); -@import url(https://unpkg.com/leaflet@1.0.3/dist/leaflet.css); +@import url(node_modules/leaflet/dist/leaflet.css); @import url(node_modules/bootstrap/dist/css/bootstrap.min.css); @import url(node_modules/react-bootstrap-table/dist/react-bootstrap-table.min.css); diff --git a/lib/manager/actions/deployments.js b/lib/manager/actions/deployments.js index a9f2c3408..e1036c504 100644 --- a/lib/manager/actions/deployments.js +++ b/lib/manager/actions/deployments.js @@ -16,7 +16,7 @@ const DEPLOYMENT_URL = `/api/manager/secure/deployments` // Deployment Actions export const createDeployment = createAction( 'CREATE_DEPLOYMENT', - (payload: string /* project id */) => payload + (payload: string) => payload ) const receiveDeployment = createAction( 'RECEIVE_DEPLOYMENT', diff --git a/lib/manager/actions/feeds.js b/lib/manager/actions/feeds.js index 7be5dd58c..bfded3016 100644 --- a/lib/manager/actions/feeds.js +++ b/lib/manager/actions/feeds.js @@ -35,7 +35,7 @@ export const receiveFeedSource = createAction( ) export const createFeedSource = createAction( 'CREATE_FEEDSOURCE', - (payload: string /* project id */) => payload + (payload: string) => payload ) export type FeedActions = ActionType | diff --git a/lib/manager/actions/languages.js b/lib/manager/actions/languages.js index 6e00db7db..59682cd4b 100644 --- a/lib/manager/actions/languages.js +++ b/lib/manager/actions/languages.js @@ -4,7 +4,7 @@ import {createAction, type ActionType} from 'redux-actions' export const setActiveLanguage = createAction( 'SET_ACTIVE_LANGUAGE', - (payload: string /* languageId */) => payload + (payload: string) => payload ) export type LanguageActions = ActionType diff --git a/lib/manager/components/validation/ServicePerModeChart.js b/lib/manager/components/validation/ServicePerModeChart.js index 5feec3570..2a23980d9 100644 --- a/lib/manager/components/validation/ServicePerModeChart.js +++ b/lib/manager/components/validation/ServicePerModeChart.js @@ -14,6 +14,8 @@ type Props = { validationResult: ValidationResult } +const maxDaysToShow = 500 + export default class ServicePerModeChart extends Component { _getData = (validationResult: ValidationResult) => { const {dailyBusSeconds, dailyTramSeconds, dailyMetroSeconds, dailyRailSeconds, dailyTotalSeconds, firstCalendarDate} = validationResult @@ -24,7 +26,8 @@ export default class ServicePerModeChart extends Component { const hasRail = dailyRailSeconds.filter(s => s > 0).length > 0 let hasOther = false const data = [] - for (let i = 0; i < dailyTotalSeconds.length; i++) { + const limit = Math.min(dailyTotalSeconds.length, maxDaysToShow) + for (let i = 0; i < limit; i++) { const column = {} column.date = firstDate.clone().add(i, 'days') let other = dailyTotalSeconds[i] @@ -84,6 +87,7 @@ export default class ServicePerModeChart extends Component { for (let i = yAxisPeriod; i <= yAxisMax; i += yAxisPeriod) { yAxisLabels.push(i) } + const curtailed = maxDaysToShow < validationResult.dailyTotalSeconds.length return (
{ ))} + {curtailed && + + * only first 500 days of service shown + + }
) diff --git a/lib/manager/components/validation/TripsChart.js b/lib/manager/components/validation/TripsChart.js index c80776500..8e29beb2d 100644 --- a/lib/manager/components/validation/TripsChart.js +++ b/lib/manager/components/validation/TripsChart.js @@ -18,6 +18,7 @@ const COLORS = { SATURDAY: '#66c2a5', SUNDAY: '#fc8d62' } +const maxDaysToShow = 500 export default class TripsChart extends Component { render () { @@ -27,8 +28,9 @@ export default class TripsChart extends Component { } const {dailyTripCounts, firstCalendarDate} = validationResult const firstDate = moment(firstCalendarDate) - const data = dailyTripCounts.map((count, index) => - [firstDate.clone().add(index, 'days'), count]) + const data = dailyTripCounts + .slice(0, maxDaysToShow) + .map((count, index) => [firstDate.clone().add(index, 'days'), count]) const graphHeight = 300 const spacing = 8 const leftMargin = 50 @@ -43,6 +45,7 @@ export default class TripsChart extends Component { for (var i = yAxisPeriod; i <= yAxisMax; i += yAxisPeriod) { yAxisLabels.push(i) } + const curtailed = maxDaysToShow < dailyTripCounts.length return (
{ ))} + {curtailed && + + * only first 500 days of service shown + + }
) diff --git a/lib/manager/reducers/projects.js b/lib/manager/reducers/projects.js index 88760e982..b196a6a1e 100644 --- a/lib/manager/reducers/projects.js +++ b/lib/manager/reducers/projects.js @@ -3,8 +3,8 @@ import update from 'react-addons-update' import {getConfigProperty} from '../../common/util/config' import {defaultSorter} from '../../common/util/util' +import {getIndexesFromFeed} from '../util' -import type {FeedVersion} from '../../types' import type {Action} from '../../types/actions' import type {ProjectsState} from '../../types/reducers' @@ -458,50 +458,4 @@ const projects = (state: ProjectsState = defaultState, action: Action): Projects } } -// helper function to get indexes -function getIndexesFromFeed ({ - errorType, - feedSourceId, - feedVersionId, - projectId, - state -}: { - errorType?: string, - feedSourceId?: string, - feedVersionId?: FeedVersion, - projectId: string, - state: ProjectsState -}): { - errorIndex: number, - projectIndex: number, - sourceIndex: number, - versionIndex: number -} { - const projectIndex = state.all.findIndex(p => p.id === projectId) - if (!feedSourceId || projectIndex < 0) { - return { projectIndex, sourceIndex: -2, versionIndex: -2, errorIndex: -2 } - } - const project = state.all[projectIndex] - if (!project.feedSources) { - return { projectIndex, sourceIndex: -2, versionIndex: -2, errorIndex: -2 } - } - const sourceIndex = project.feedSources.findIndex(s => s.id === feedSourceId) - if (!feedVersionId || sourceIndex < 0 || !project.feedSources) { - return { projectIndex, sourceIndex, versionIndex: -2, errorIndex: -2 } - } - const feedSource = project.feedSources[sourceIndex] - if (!feedSource.feedVersions) { - return { projectIndex, sourceIndex, versionIndex: -2, errorIndex: -2 } - } - const versionIndex = feedSource.feedVersions.findIndex(v => v.id === feedVersionId) - if (!errorType || !feedSource.feedVersions || versionIndex < 0) { - return { projectIndex, sourceIndex, versionIndex, errorIndex: -2 } - } - const feedVersion = feedSource.feedVersions[versionIndex] - const errorIndex = feedVersion.validationResult.error_counts.findIndex( - e => e.type === errorType - ) - return { errorIndex, projectIndex, sourceIndex, versionIndex } -} - export default projects diff --git a/lib/manager/util/index.js b/lib/manager/util/index.js index d3c73a9fe..a5238ca79 100644 --- a/lib/manager/util/index.js +++ b/lib/manager/util/index.js @@ -1,7 +1,6 @@ // @flow - -import type {Feed, Project} from '../../types' -import type {ManagerUserState} from '../../types/reducers' +import type {Feed, FeedVersion, Project} from '../../types' +import type {ManagerUserState, ProjectsState} from '../../types/reducers' export function findProjectByFeedSource ( allProjects: ?Array, @@ -55,3 +54,51 @@ export function isEditingDisabled ( ) ) } + +/** + * Helper function to get the index of various things from the project state. + */ +export function getIndexesFromFeed ({ + errorType, + feedSourceId, + feedVersionId, + projectId, + state +}: { + errorType?: string, + feedSourceId?: string, + feedVersionId?: FeedVersion, + projectId: string, + state: ProjectsState +}): { + errorIndex: number, + projectIndex: number, + sourceIndex: number, + versionIndex: number +} { + const projectIndex = state.all.findIndex(p => p.id === projectId) + if (!feedSourceId || projectIndex < 0) { + return { projectIndex, sourceIndex: -2, versionIndex: -2, errorIndex: -2 } + } + const project = state.all[projectIndex] + if (!project.feedSources) { + return { projectIndex, sourceIndex: -2, versionIndex: -2, errorIndex: -2 } + } + const sourceIndex = project.feedSources.findIndex(s => s.id === feedSourceId) + if (!feedVersionId || sourceIndex < 0 || !project.feedSources) { + return { projectIndex, sourceIndex, versionIndex: -2, errorIndex: -2 } + } + const feedSource = project.feedSources[sourceIndex] + if (!feedSource.feedVersions) { + return { projectIndex, sourceIndex, versionIndex: -2, errorIndex: -2 } + } + const versionIndex = feedSource.feedVersions.findIndex(v => v.id === feedVersionId) + if (!errorType || !feedSource.feedVersions || versionIndex < 0) { + return { projectIndex, sourceIndex, versionIndex, errorIndex: -2 } + } + const feedVersion = feedSource.feedVersions[versionIndex] + const errorIndex = feedVersion.validationResult.error_counts.findIndex( + e => e.type === errorType + ) + return { errorIndex, projectIndex, sourceIndex, versionIndex } +} diff --git a/package.json b/package.json index d428a6531..16e8d640b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "isomorphic-fetch": "^2.2.1", "jszip": "^3.0.0", "jwt-decode": "^2.1.0", - "leaflet": "1.0.3", + "leaflet": "^1.3.4", "lodash": "^4.17.10", "moment": "^2.11.2", "numeral": "2.0.4", diff --git a/yarn.lock b/yarn.lock index 6782ecacc..bf8466c88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5400,9 +5400,9 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" -leaflet@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.0.3.tgz#1f401b98b45c8192134c6c8d69686253805007c8" +leaflet@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.3.4.tgz#7f006ea5832603b53d7269ef5c595fd773060a40" left-pad@^1.2.0: version "1.3.0"