From 551b1fc8863adc705e8707a3ffe5a72d3b7ebc91 Mon Sep 17 00:00:00 2001 From: regeter <2320305+regeter@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:14:05 -0800 Subject: [PATCH] chore: prettier 120 characters formatting changes --- src/App.js | 166 +++++++++--------------------------- src/App.test.js | 2 + src/Dataframe.js | 2 +- src/HighVelocityJump.js | 25 ++---- src/LogTable.js | 115 +++++++------------------ src/MissingUpdate.js | 7 +- src/PolylineCreation.js | 23 ++--- src/ServeHome.js | 30 ++----- src/Stats.js | 5 +- src/Task.js | 39 ++++----- src/TaskLogs.js | 15 +--- src/TaskLogs.test.js | 26 ++---- src/TimeSlider.js | 18 +--- src/ToggleBar.js | 8 +- src/TrafficPolyline.js | 43 +++------- src/TrafficPolyline.test.js | 15 ++-- src/Trip.js | 2 +- src/TripLogs.test.js | 2 + src/Utils.js | 2 + src/global.css | 126 ++++++++++++++------------- src/index.js | 16 +--- src/localStorage.js | 20 ++--- src/localStorage.test.js | 33 ++----- src/queryString.js | 20 ++--- src/setupTests.js | 2 + src/vehicleData.js | 18 +--- 26 files changed, 234 insertions(+), 546 deletions(-) diff --git a/src/App.js b/src/App.js index 87f8c19..1c10d3c 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ /* - * App.js + * src/App.js * * Basic react app container. Handles state for the app and * propagation for state changes into the non-react map @@ -11,11 +11,7 @@ import TimeSlider from "./TimeSlider"; import LogTable from "./LogTable"; import ToggleBar from "./ToggleBar"; import TripLogs from "./TripLogs"; -import { - uploadFile, - getUploadedData, - deleteUploadedData, -} from "./localStorage"; +import { uploadFile, getUploadedData, deleteUploadedData } from "./localStorage"; import _ from "lodash"; import { getQueryStringValue, setQueryStringValue } from "./queryString"; import "./global.css"; @@ -41,9 +37,7 @@ class App extends React.Component { let urlMaxTime = getQueryStringValue("maxTime"); this.initialMinTime = urlMinTime ? parseInt(urlMinTime) : 0; // default max time to 1 year in the future - this.initialMaxTime = urlMaxTime - ? parseInt(urlMaxTime) - : nowDate.setFullYear(nowDate.getFullYear() + 1); + this.initialMaxTime = urlMaxTime ? parseInt(urlMaxTime) : nowDate.setFullYear(nowDate.getFullYear() + 1); this.focusOnRowFunction = null; this.state = { @@ -69,19 +63,13 @@ class App extends React.Component { showTasksAsCreated: getToggleDefault("showTasksAsCreated", false), showPlannedPaths: getToggleDefault("showPlannedPaths", false), showLiveJS: getToggleDefault("showLiveJS", false), - showClientServerTimeDeltas: getToggleDefault( - "showClientServerTimeDeltas", - false - ), + showClientServerTimeDeltas: getToggleDefault("showClientServerTimeDeltas", false), }, uploadedDatasets: [null, null, null], activeDatasetIndex: null, }; // Realtime updates are too heavy. There must be a better/ react way - this.onSliderChangeDebounced = _.debounce( - (timeRange) => this.onSliderChange(timeRange), - 25 - ); + this.onSliderChangeDebounced = _.debounce((timeRange) => this.onSliderChange(timeRange), 25); // TODO: refactor so that visualizations are registered // rather than enumerated here? @@ -90,126 +78,104 @@ class App extends React.Component { { id: "showGPSBubbles", name: "GPS Accuracy", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/GPSAccuracy.md", - columns: [ - "lastlocation.rawlocationaccuracy", - "lastlocation.locationsensor", - ], + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/GPSAccuracy.md", + columns: ["lastlocation.rawlocationaccuracy", "lastlocation.locationsensor"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showHeading", name: "Heading", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Heading.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Heading.md", columns: ["lastlocation.heading", "lastlocation.headingaccuracy"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showSpeed", name: "Speed", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Speed.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Speed.md", columns: ["lastlocation.speed"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showTripStatus", name: "Trip Status", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/TripStatus.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/TripStatus.md", columns: [], solutionTypes: ["ODRD"], }, { id: "showNavStatus", name: "Navigation Status", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/NavStatus.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/NavStatus.md", columns: [], solutionTypes: ["ODRD", "LMFS"], }, { id: "showTasksAsCreated", name: "Tasks", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Tasks.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/Tasks.md", columns: [], solutionTypes: ["LMFS"], }, { id: "showPlannedPaths", name: "Planned Paths", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/PlannedPaths.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/PlannedPaths.md", columns: [], solutionTypes: ["LMFS"], }, { id: "showDwellLocations", name: "Dwell Locations", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/DwellTimes.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/DwellTimes.md", columns: [], solutionTypes: ["ODRD", "LMFS"], }, { id: "showHighVelocityJumps", name: "Jumps (unrealistic velocity)", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/VelocityJumps.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/VelocityJumps.md", columns: ["lastlocation.speed"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showMissingUpdates", name: "Jumps (Temporal)", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/MissingUpdates.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/MissingUpdates.md", columns: ["temporal_gap"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showClientServerTimeDeltas", name: "Client/Server Time Deltas", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", - columns: [ - "response.laslLocation.rawlocationlime", - "response.laslLocation.serverlime", - ], + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", + columns: ["response.laslLocation.rawlocationlime", "response.laslLocation.serverlime"], solutionTypes: ["ODRD", "LMFS"], }, { id: "showETADeltas", name: "ETA Deltas", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/docs/EtaDeltas.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/EtaDeltas.md", columns: ["request.vehicle.etatofirstwaypoint"], solutionTypes: ["ODRD"], }, { id: "showTraffic", name: "Traffic", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", columns: [], solutionTypes: ["ODRD", "LMFS"], }, { id: "showLiveJS", name: "Start Live Journey Sharing for newest trip", - docLink: - "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", + docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/README.md", columns: [], solutionTypes: ["ODRD", "LMFS"], }, ], (toggle) => { - return ( - toggle.solutionTypes.indexOf(this.props.logData.solutionType) !== -1 - ); + return toggle.solutionTypes.indexOf(this.props.logData.solutionType) !== -1; } ); this.setFeaturedObject = this.setFeaturedObject.bind(this); @@ -225,10 +191,7 @@ class App extends React.Component { * changed. */ updateMapAndAssociatedData = () => { - this.setTimeRange( - this.state.timeRange.minTime, - this.state.timeRange.maxTime - ); + this.setTimeRange(this.state.timeRange.minTime, this.state.timeRange.maxTime); _.map(this.toggles, (toggle) => { const urlVal = getQueryStringValue(toggle.id); if (urlVal === "true") { @@ -344,9 +307,7 @@ class App extends React.Component { this.setState((prevState) => { const minDate = new Date(prevState.timeRange.minTime); const maxDate = new Date(prevState.timeRange.maxTime); - const logs = this.props.logData.tripLogs - .getLogs_(minDate, maxDate) - .value(); + const logs = this.props.logData.tripLogs.getLogs_(minDate, maxDate).value(); if (logs.length > 0) { const firstRow = logs[0]; @@ -354,9 +315,7 @@ class App extends React.Component { resolve(firstRow); return { featuredObject: firstRow }; } else { - console.log( - "selectFirstRow: No logs found in the current time range" - ); + console.log("selectFirstRow: No logs found in the current time range"); resolve(null); return null; } @@ -387,9 +346,7 @@ class App extends React.Component { let newFeaturedObject = featuredObject; - const currentIndex = logs.findIndex( - (log) => log.timestamp === featuredObject.timestamp - ); + const currentIndex = logs.findIndex((log) => log.timestamp === featuredObject.timestamp); if (direction === "next" && currentIndex < logs.length - 1) { newFeaturedObject = logs[currentIndex + 1]; } else if (direction === "previous" && currentIndex > 0) { @@ -448,9 +405,7 @@ class App extends React.Component { if (!response.ok) { return; } - console.log( - "data.json demo file found on the server root, saving it to Dataset 1" - ); + console.log("data.json demo file found on the server root, saving it to Dataset 1"); const blob = await response.blob(); const file = new File([blob], "data.json", { type: "application/json", @@ -464,10 +419,7 @@ class App extends React.Component { handleFileUpload = async (event, index) => { const file = event.target.files[0]; - log( - `Attempting to upload file for button ${index}:`, - file ? file.name : "No file selected" - ); + log(`Attempting to upload file for button ${index}:`, file ? file.name : "No file selected"); if (file) { try { log(`Uploading file ${file.name} for button ${index}`); @@ -496,12 +448,7 @@ class App extends React.Component { [0, 1, 2].map(async (index) => { const data = await getUploadedData(index); log(`Dataset ${index}:`, data); - if ( - data && - data.rawLogs && - Array.isArray(data.rawLogs) && - data.rawLogs.length > 0 - ) { + if (data && data.rawLogs && Array.isArray(data.rawLogs) && data.rawLogs.length > 0) { return { status: "Uploaded", index }; } return { status: null, index }; @@ -513,9 +460,7 @@ class App extends React.Component { }); if (this.state.activeDatasetIndex === null) { - const firstAvailableIndex = newUploadedDatasets.find( - (dataset) => dataset.status === "Uploaded" - )?.index; + const firstAvailableIndex = newUploadedDatasets.find((dataset) => dataset.status === "Uploaded")?.index; if (firstAvailableIndex !== undefined) { this.switchDataset(firstAvailableIndex); } @@ -531,16 +476,10 @@ class App extends React.Component { this.setState((prevState) => { const newUploadedDatasets = [...prevState.uploadedDatasets]; newUploadedDatasets[index] = null; - log( - `Updated state after deletion for button ${index}:`, - newUploadedDatasets - ); + log(`Updated state after deletion for button ${index}:`, newUploadedDatasets); return { uploadedDatasets: newUploadedDatasets, - activeDatasetIndex: - prevState.activeDatasetIndex === index - ? null - : prevState.activeDatasetIndex, + activeDatasetIndex: prevState.activeDatasetIndex === index ? null : prevState.activeDatasetIndex, }; }); } catch (error) { @@ -597,11 +536,7 @@ class App extends React.Component { - + - + setColor(e.target.value)} - /> + setColor(e.target.value)} />
@@ -133,11 +124,7 @@ Or paste an encoded S2 polyline string`; - diff --git a/src/ServeHome.js b/src/ServeHome.js index 2d582c6..c8b3f64 100644 --- a/src/ServeHome.js +++ b/src/ServeHome.js @@ -1,9 +1,5 @@ -/* - * App.js - * - * Basic react app container. Handles state for the app and - * propagation for state changes into the non-react map - */ +// src/ServeHome.js + import React from "react"; class ServeHome extends React.Component { @@ -19,9 +15,7 @@ class ServeHome extends React.Component { }; this.goVehicle = () => { - window.location.href = `/debugger?dataFile=/vehicles/${encodeURI( - this.state.vehicle - )}`; + window.location.href = `/debugger?dataFile=/vehicles/${encodeURI(this.state.vehicle)}`; }; this.handleTripChange = (event) => { @@ -29,9 +23,7 @@ class ServeHome extends React.Component { }; this.goTrip = () => { - window.location.href = `/debugger?dataFile=/trips/${encodeURI( - this.state.trip - )}`; + window.location.href = `/debugger?dataFile=/trips/${encodeURI(this.state.trip)}`; }; } @@ -40,21 +32,11 @@ class ServeHome extends React.Component {

Fleet Debugger Live Mode

-