diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index d533e842..fb1296d7 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -37,7 +37,6 @@ const database = (config: any, name: string) => { serveRoot: '/cdn/', }), ], - controllers: [ AppController, RCController, diff --git a/backend/src/images/image.service.ts b/backend/src/images/image.service.ts index 1d6864bf..09693f2e 100644 --- a/backend/src/images/image.service.ts +++ b/backend/src/images/image.service.ts @@ -61,6 +61,8 @@ export class ImageService { * * @param wayId the way id * @param isDashCam boolean to indicate if the images are dash camera images or road surface images + * + * @author Kerbourc'h */ async getWayImages( wayId: OSMWayId, diff --git a/backend/src/models.ts b/backend/src/models.ts index d4117a22..49a10263 100644 --- a/backend/src/models.ts +++ b/backend/src/models.ts @@ -6,6 +6,16 @@ export interface LatLng { lng: number; } +/** + * Used in the data plot to show the condition of a road. + * The way_dist is the distance from the start of the way. It will be the x-axis in the plot. + * The value is the condition value. It will be the y-axis in the plot. + */ +export interface Condition { + way_dist: number; + value: number; +} + /** * Type of answer from backend for a survey. */ diff --git a/backend/src/roads/road.service.ts b/backend/src/roads/road.service.ts index 17c57957..3bb846eb 100644 --- a/backend/src/roads/road.service.ts +++ b/backend/src/roads/road.service.ts @@ -51,8 +51,6 @@ export class RoadService { * This executes the queries sequentially to avoid useless queries to OSM * and the database. This is especially useful when the ways are in the same road. * - * // TODO: change this a nest queue - * * @param wayIds * * @author Kerbourc'h @@ -79,8 +77,6 @@ export class RoadService { * Will get the Way corresponding to the OSMWayId either from the database if * available or from OSM and insert the whole road containing it in the database. * - * // TODO: change this a nest queue - * * @param OSMWayId the osm id of a way in the road * * @author Kerbourc'h diff --git a/backend/src/surveys/survey.controller.ts b/backend/src/surveys/survey.controller.ts index 1360cac9..42faa589 100644 --- a/backend/src/surveys/survey.controller.ts +++ b/backend/src/surveys/survey.controller.ts @@ -7,6 +7,9 @@ import { SurveyService } from './survey.service'; export class SurveyController { constructor(private readonly service: SurveyService) {} + /** + * @author Muro + */ @Get('') getWayConditions(@Query() query: { surveyId: string }): Promise { const { surveyId } = query; diff --git a/backend/src/surveys/survey.service.ts b/backend/src/surveys/survey.service.ts index 49a7e7cf..d910d264 100644 --- a/backend/src/surveys/survey.service.ts +++ b/backend/src/surveys/survey.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectConnection, Knex } from 'nestjs-knex'; import { Measurement, Survey } from '../tables'; -import { MeasurementType, ISurvey } from '../models'; +import { ISurvey, MeasurementType } from '../models'; @Injectable() export class SurveyService { @@ -57,11 +57,11 @@ export class SurveyService { } /** - *Asynchronously retrieves all surveys from the database, including their IDs and timestamps. + * Asynchronously retrieves all surveys from the database, including their IDs and timestamps. * * @author Lyons */ async getAllSurveys(): Promise { - return await Survey(this.knex_group_d).select('id', 'timestamp'); + return Survey(this.knex_group_d).select('id', 'timestamp'); } } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 6db5704c..e0df0a95 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,6 +13,8 @@ import Main from './pages/Main'; /** * Component rendering the whole application + * + * @author LiraVis, Muro, Kerbourc'h */ const App: FC = () => { return ( diff --git a/frontend/src/Components/Conditions/ConditionsMap.tsx b/frontend/src/Components/Conditions/ConditionsMap.tsx index 271646ab..df0ff768 100644 --- a/frontend/src/Components/Conditions/ConditionsMap.tsx +++ b/frontend/src/Components/Conditions/ConditionsMap.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect, useRef } from 'react'; +import React, { FC, useCallback, useEffect, useMemo, useRef } from 'react'; import { GeoJSON } from 'react-leaflet'; import L, { CircleMarkerOptions } from 'leaflet'; import { FeatureCollection } from 'geojson'; @@ -147,13 +147,12 @@ const severityThreshold = ( const isMedium = severity.mode.includes('Medium'); const isLow = severity.mode.includes('Low'); - const meetsSeverityConditions = + return ( (isLow && (value <= thresholds[0] || value < thresholds[1])) || (isMedium && thresholds[1] <= value && value <= thresholds[2]) || (isHigh && thresholds[2] < value && value <= thresholds[3]) || - (isCritical && thresholds[3] < value); - - return meetsSeverityConditions; + (isCritical && thresholds[3] < value) + ); } } return false; @@ -190,10 +189,12 @@ const ConditionsMap: FC = ({ const geoJsonRef = useRef(); // The default data to show in the GeoJSON component - const defaultData: FeatureCollection = { - type: 'FeatureCollection', - features: [], - }; + const defaultData: FeatureCollection = useMemo(() => { + return { + type: 'FeatureCollection', + features: [], + }; + }, []); const setStyle = useCallback( ( diff --git a/frontend/src/Components/Conditions/InfoButton.tsx b/frontend/src/Components/Conditions/InfoButton.tsx index 1f94ef4c..c80effca 100644 --- a/frontend/src/Components/Conditions/InfoButton.tsx +++ b/frontend/src/Components/Conditions/InfoButton.tsx @@ -1,29 +1,30 @@ -import React, { useState, useEffect, useRef } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import '../../css/InfoButton.css'; /** * A small button showing information and instructions to use the webapp. + * + * @author Lyons, Chen, Muro */ - const InfoButton: React.FC = () => { const [showInfo, setShowInfo] = useState(false); const infoButtonRef = useRef(null); // Toggle the visibility of the info box - const handleInfoToggle = () => { + const handleInfoToggle = useCallback(() => { setShowInfo(!showInfo); - }; + }, [showInfo]); // Close the info box if clicking outside - const handleClickOutside = (event: MouseEvent) => { + const handleClickOutside = useCallback((event: MouseEvent) => { if ( infoButtonRef.current && !infoButtonRef.current.contains(event.target as Node) ) { setShowInfo(false); } - }; + }, []); useEffect(() => { // Add event listener for the click when the component is mounted @@ -36,9 +37,9 @@ const InfoButton: React.FC = () => { }, []); // Stop the propagation of the click event to prevent handleClickOutside from being triggered - const stopPropagation = (event: React.MouseEvent) => { + const stopPropagation = useCallback((event: React.MouseEvent) => { event.stopPropagation(); - }; + }, []); return ( <> diff --git a/frontend/src/Components/Conditions/UploadPanel.tsx b/frontend/src/Components/Conditions/UploadPanel.tsx index 5baad312..ec953b4c 100644 --- a/frontend/src/Components/Conditions/UploadPanel.tsx +++ b/frontend/src/Components/Conditions/UploadPanel.tsx @@ -11,6 +11,8 @@ interface Props { /** * Create a panel where the user can upload a zip file + * + * @author Kerbourc'h */ const UploadPanel: FC = ({ close }) => { const [state, setState] = useState< @@ -57,7 +59,7 @@ const UploadPanel: FC = ({ close }) => { } else { setState('sent-error'); } - console.warn(error); + console.warn('Error while uploading new survey: ', error); setTimeout(() => setState('waiting'), 3000); }, ); diff --git a/frontend/src/Components/Inputs/SingleFileInput.tsx b/frontend/src/Components/Inputs/SingleFileInput.tsx index 5b553b2e..de7166ac 100644 --- a/frontend/src/Components/Inputs/SingleFileInput.tsx +++ b/frontend/src/Components/Inputs/SingleFileInput.tsx @@ -14,6 +14,8 @@ interface Props { /** * Create a file input (either using the default file selector or using drag 'n' drop) + * + * @author Kerbourc'h */ const SingleFileInput: FC = ({ displayName, diff --git a/frontend/src/Components/Map/GradientLine.tsx b/frontend/src/Components/Map/GradientLine.tsx index 0a0c4274..b54c0b1e 100644 --- a/frontend/src/Components/Map/GradientLine.tsx +++ b/frontend/src/Components/Map/GradientLine.tsx @@ -27,8 +27,7 @@ interface Props { * GradientLine component to render the path on the map. This path is colored * using a palette and the data provided. * - * - * @author LiRA Map (Called Ways), Kerbourc'h + * @author Kerbourc'h */ const GradientLine: FC = ({ geometry, diff --git a/frontend/src/Components/Map/DetectMapClick.tsx b/frontend/src/Components/Map/Hooks/DetectMapClick.tsx similarity index 100% rename from frontend/src/Components/Map/DetectMapClick.tsx rename to frontend/src/Components/Map/Hooks/DetectMapClick.tsx diff --git a/frontend/src/Components/Map/ForceMapUpdate.tsx b/frontend/src/Components/Map/Hooks/ForceMapUpdate.tsx similarity index 93% rename from frontend/src/Components/Map/ForceMapUpdate.tsx rename to frontend/src/Components/Map/Hooks/ForceMapUpdate.tsx index 4fd0e898..1fc1b4c8 100644 --- a/frontend/src/Components/Map/ForceMapUpdate.tsx +++ b/frontend/src/Components/Map/Hooks/ForceMapUpdate.tsx @@ -1,4 +1,4 @@ -import { LatLng } from '../../models/models'; +import { LatLng } from '../../../models/models'; import { useMap } from 'react-leaflet'; import React, { useEffect } from 'react'; diff --git a/frontend/src/Components/Map/Hooks/useMapBounds.tsx b/frontend/src/Components/Map/Hooks/useMapBounds.tsx deleted file mode 100644 index 0539ed0b..00000000 --- a/frontend/src/Components/Map/Hooks/useMapBounds.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { LatLngBounds } from 'leaflet'; -import { useState } from 'react'; -import { useMapEvents } from 'react-leaflet'; - -const useMapBounds = (): LatLngBounds => { - const map = useMapEvents({ - moveend: () => setBounds(map.getBounds()), - }); - - const [bounds, setBounds] = useState(map.getBounds()); - - return bounds; -}; - -export default useMapBounds; diff --git a/frontend/src/Components/Map/Hooks/useZoom.tsx b/frontend/src/Components/Map/Hooks/useZoom.tsx index 58756119..c07428fb 100644 --- a/frontend/src/Components/Map/Hooks/useZoom.tsx +++ b/frontend/src/Components/Map/Hooks/useZoom.tsx @@ -3,6 +3,8 @@ import { useMapEvents } from 'react-leaflet'; /** * Zoom implementation on map events + * + * @author LiraVis */ const useZoom = () => { const [zoom, setZoom] = useState(); diff --git a/frontend/src/Components/Map/InfoCard.tsx b/frontend/src/Components/Map/InfoCard.tsx index 5f596c17..d2ca428a 100644 --- a/frontend/src/Components/Map/InfoCard.tsx +++ b/frontend/src/Components/Map/InfoCard.tsx @@ -1,10 +1,12 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import '../../css/roadinfo_card.css'; import { IRoad } from '../../models/path'; interface Props { - hidden: boolean; // Prop to control visibility + /** To control visibility */ + hidden: boolean; + /** The road data to display */ roadData?: IRoad; } /** @@ -16,14 +18,14 @@ const InfoCard: React.FC = ({ hidden, roadData }) => { const navigate = useNavigate(); // Get the navigate function // Navigate to the "Inspect" page - const handleInspect = () => { + const handleInspect = useCallback(() => { if (!roadData) return; const biggestBranch = roadData?.branches.reduce((prev, curr) => prev.length > curr.length ? prev : curr, ); navigate('/inspect/paths/' + biggestBranch.join(',')); - }; + }, [roadData, navigate]); if (hidden || !roadData) { return null; // Don't render anything if hidden is true diff --git a/frontend/src/Components/Map/Inputs/Hamburger.tsx b/frontend/src/Components/Map/Inputs/Hamburger.tsx index 518a2aa8..520df932 100644 --- a/frontend/src/Components/Map/Inputs/Hamburger.tsx +++ b/frontend/src/Components/Map/Inputs/Hamburger.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import '../../../css/Sidebar.css'; import { getAllSurveyData } from '../../../queries/conditions'; @@ -26,15 +26,17 @@ const Hamburger: React.FC = ({ isOpen, toggle }) => { useEffect(() => { getAllSurveyData((data: SurveyList) => { - console.log('Received survey data:', data); setSurveys(data); }); }, []); - const handleSurveyClick = (surveyId: string, _index: number) => { - const path = `/inspect/surveys/${surveyId}`; - navigate(path); - }; + const handleSurveyClick = useCallback( + (surveyId: string, _index: number) => { + const path = `/inspect/surveys/${surveyId}`; + navigate(path); + }, + [navigate], + ); return ( <> diff --git a/frontend/src/Components/Map/Inputs/MonthFilter.tsx b/frontend/src/Components/Map/Inputs/MonthFilter.tsx index 7fd490dd..a141aa3f 100644 --- a/frontend/src/Components/Map/Inputs/MonthFilter.tsx +++ b/frontend/src/Components/Map/Inputs/MonthFilter.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import DatePicker from 'react-datepicker'; import '../../../css/month_filter.css'; import 'react-datepicker/dist/react-datepicker.css'; @@ -36,8 +36,9 @@ interface MonthFilterProps { onStartChange: (date: any) => void; /** function taking argument "date" for End date **/ onEndChange: (date: any) => void; - /** The minimum & maximum date possible **/ + /** The minimum date possible **/ minDate: Date; + /** The maximum date possible **/ maxDate: Date; } diff --git a/frontend/src/Components/Map/Inputs/MultiSelector.tsx b/frontend/src/Components/Map/Inputs/MultiSelector.tsx index acb258aa..5133ce99 100644 --- a/frontend/src/Components/Map/Inputs/MultiSelector.tsx +++ b/frontend/src/Components/Map/Inputs/MultiSelector.tsx @@ -24,7 +24,6 @@ interface MultiSelectProps { * * @author Hansen */ - const MultiSelector: React.FC = ({ handleSelectionChange, children, diff --git a/frontend/src/Components/Map/Inputs/Search.tsx b/frontend/src/Components/Map/Inputs/Search.tsx index dc35237c..e7e54ebd 100644 --- a/frontend/src/Components/Map/Inputs/Search.tsx +++ b/frontend/src/Components/Map/Inputs/Search.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { - GeoapifyGeocoderAutocomplete, GeoapifyContext, + GeoapifyGeocoderAutocomplete, } from '@geoapify/react-geocoder-autocomplete'; import '@geoapify/geocoder-autocomplete/styles/minimal.css'; import '../../../css/search.css'; @@ -12,7 +12,6 @@ interface Props { * value: text input in the search bar * onPlaceSelect: function taking argument "value" */ - onPlaceSelect: (value: any) => void; } @@ -21,12 +20,7 @@ interface Props { * * @author Hansen */ - const Search: React.FC = ({ onPlaceSelect }) => { - function onSuggestionChange(value: any) { - console.log(value); - } - return ( = ({ onPlaceSelect }) => { type={'street'} filterByCountryCode={['dk', 'sa']} // Denmark and Saudi Arabia placeSelect={onPlaceSelect} - suggestionsChange={onSuggestionChange} /> ); diff --git a/frontend/src/Components/Map/MapWrapper.tsx b/frontend/src/Components/Map/MapWrapper.tsx index e8fb28ac..e8b3db3a 100644 --- a/frontend/src/Components/Map/MapWrapper.tsx +++ b/frontend/src/Components/Map/MapWrapper.tsx @@ -19,6 +19,8 @@ interface IMapWrapper { /** * MapWrapper is the component to show a map. + * + * @author LiraVis, Kerbourc'h, Hansen, Muro */ const MapWrapper: FC = ({ children }) => { const { center, zoom, minZoom, maxZoom, scaleWidth } = MAP_OPTIONS; diff --git a/frontend/src/Components/Map/Renderers/DistHotline.tsx b/frontend/src/Components/Map/Renderers/DistHotline.tsx index 42cbe8bb..adbe70cc 100644 --- a/frontend/src/Components/Map/Renderers/DistHotline.tsx +++ b/frontend/src/Components/Map/Renderers/DistHotline.tsx @@ -39,6 +39,8 @@ interface IDistHotline { * @param eventHandlers the default event handlers * @param event the event to handle * @param opacity the opacity to set to the line + * + * @author LiraVis */ const handler = ( eventHandlers: HotlineEventHandlers | undefined, @@ -57,6 +59,8 @@ const handler = ( * data in function of the distance of the beginning of a path. * * It uses the react-leaflet-hotline library. + * + * @author LiraVis, Kerbourc'h */ const DistHotline: FC = ({ geometry, diff --git a/frontend/src/Components/RoadDetails/ConditionsGraph.tsx b/frontend/src/Components/RoadDetails/ConditionsGraph.tsx index f980aa16..3f395a06 100644 --- a/frontend/src/Components/RoadDetails/ConditionsGraph.tsx +++ b/frontend/src/Components/RoadDetails/ConditionsGraph.tsx @@ -1,12 +1,9 @@ import { FC, useEffect, useMemo, useRef, useState } from 'react'; import { - ActiveElement, CategoryScale, Chart, ChartData, - ChartEvent, ChartOptions, - ChartTypeRegistry, Legend, LinearScale, LineElement, @@ -297,16 +294,6 @@ const ConditionsGraph: FC = ({ data, inspectedRoadDistanceArea }) => { return { ...options(data, scales.scales), - onClick: ( - event: ChartEvent, - elts: ActiveElement[], - _chart: Chart, - ) => { - if (elts.length === 0) return; - const elt = elts[0]; // doesnt work if multiple datasets - const pointIndex = elt.index; - console.log(pointIndex, event, elts); - }, }; }, [data]); // don't update when previousTypes changes, bacause it's only use to store the previous show axis @@ -320,7 +307,6 @@ const ConditionsGraph: FC = ({ data, inspectedRoadDistanceArea }) => { useEffect(() => { if (ref.current === null) return; - console.log(graphOptions); const chart = ref.current; chart.update(); }, [ref, graphLines]); diff --git a/frontend/src/Components/RoadDetails/ImageAbleZoom.tsx b/frontend/src/Components/RoadDetails/ImageAbleZoom.tsx index c6dec84c..d0197909 100644 --- a/frontend/src/Components/RoadDetails/ImageAbleZoom.tsx +++ b/frontend/src/Components/RoadDetails/ImageAbleZoom.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useCallback, useEffect } from 'react'; interface ImageZoom { /** The URL of the image to display in the zoomed view. */ @@ -52,11 +52,14 @@ const ImageZoom: React.FC = ({ isRightDisabled, ]); - const handleClickOutside = (e: React.MouseEvent) => { - if (e.target === e.currentTarget) { - onClose(); - } - }; + const handleClickOutside = useCallback( + (e: React.MouseEvent) => { + if (e.target === e.currentTarget) { + onClose(); + } + }, + [onClose], + ); return (
diff --git a/frontend/src/Components/RoadDetails/ImageGallery.tsx b/frontend/src/Components/RoadDetails/ImageGallery.tsx index ee8c728c..7db6b9ad 100644 --- a/frontend/src/Components/RoadDetails/ImageGallery.tsx +++ b/frontend/src/Components/RoadDetails/ImageGallery.tsx @@ -4,18 +4,6 @@ import { IImage } from '../../models/path'; import { getImagesForASurvey, getImagesForWays } from '../../queries/images'; import { useParams } from 'react-router-dom'; -interface Image { - id: number; - url: string; -} - -export const images = (cameraImages: IImage[]): Image[] => { - return cameraImages.map((ima, index) => ({ - id: index + 1, - url: ima.image_path, - })); -}; - /** * React functional component for the Image Gallery of Dash Camera image. * Image gallery is for show the real road image, and user can scroll to check @@ -101,7 +89,7 @@ const ImageGallery: React.FC = () => { className="image-gallery-page" ref={galleryRef} style={{ - justifyContent: images.length <= 9 ? 'center' : 'flex-start', + justifyContent: cameraImages.length <= 9 ? 'center' : 'flex-start', }} > {cameraImages.map((ima, index) => ( diff --git a/frontend/src/Components/RoadDetails/MapArea.tsx b/frontend/src/Components/RoadDetails/MapArea.tsx index 885ddfa1..2c22180a 100644 --- a/frontend/src/Components/RoadDetails/MapArea.tsx +++ b/frontend/src/Components/RoadDetails/MapArea.tsx @@ -1,12 +1,15 @@ import React from 'react'; import ImageGallery from './ImageGallery'; import MapWrapper from '../Map/MapWrapper'; -import ForceMapUpdate from '../Map/ForceMapUpdate'; +import ForceMapUpdate from '../Map/Hooks/ForceMapUpdate'; import { LatLng } from '../../models/models'; interface Props { + /** The trigger to update the map */ triggerUpdate: number; + /** The children to display in the map */ children?: React.ReactNode; + /** The center of the map */ center?: LatLng; } /** diff --git a/frontend/src/Components/RoadDetails/RotatedImage.tsx b/frontend/src/Components/RoadDetails/RotatedImage.tsx index 211315d8..a10a041b 100644 --- a/frontend/src/Components/RoadDetails/RotatedImage.tsx +++ b/frontend/src/Components/RoadDetails/RotatedImage.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; interface Props { + /** The path of the image to display */ src: string; } diff --git a/frontend/src/Components/RoadDetails/TopBar.tsx b/frontend/src/Components/RoadDetails/TopBar.tsx index 1a984694..684c5398 100644 --- a/frontend/src/Components/RoadDetails/TopBar.tsx +++ b/frontend/src/Components/RoadDetails/TopBar.tsx @@ -1,5 +1,5 @@ // The TopBar for Inspect page -import React from 'react'; +import React, { useCallback } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import Selector from '../Map/Inputs/Selector'; @@ -12,10 +12,15 @@ interface TopBarProps { setSelectedType: (type: string) => void; /** Callback to set the selected type for graph*/ graphIndicatorSet: (type: string[]) => void; + /** The available types for the road images */ availableRoadImagesTypes: string[]; + /** The available types for the graph */ availableGraphIndicatorType: string[]; } +/** + * @author Muro + */ const makeOnlyAvailableOptionsClickable = ( options: { value: string; label: string }[], availableOptions: string[], @@ -60,10 +65,10 @@ const TopBar: React.FC = ({ }) => { const navigate = useNavigate(); // Get the navigate function - const handleReturn = () => { + const handleReturn = useCallback(() => { // Navigate back to the home page when the button is clicked navigate('/'); - }; + }, [navigate]); return (
diff --git a/frontend/src/assets/hotline/DistRenderer.ts b/frontend/src/assets/hotline/DistRenderer.ts index 38eb392b..82d8b747 100644 --- a/frontend/src/assets/hotline/DistRenderer.ts +++ b/frontend/src/assets/hotline/DistRenderer.ts @@ -8,6 +8,8 @@ import Edge from './Edge'; /** * A renderer that allow the condition to be projected between two GPS points * (knowing the distance from the start of the path) + * + * @author LiraVis, Kerbourc'h */ export default class DistRenderer extends Renderer { conditions: DataPoint[]; diff --git a/frontend/src/assets/hotline/Edge.ts b/frontend/src/assets/hotline/Edge.ts index 51ddaa3f..91894c9a 100644 --- a/frontend/src/assets/hotline/Edge.ts +++ b/frontend/src/assets/hotline/Edge.ts @@ -1,3 +1,6 @@ +/** + * @author LiraVis + */ export default class Edge { r: number; g: number; diff --git a/frontend/src/assets/hotline/hotline.d.ts b/frontend/src/assets/hotline/hotline.d.ts index f9c20498..5e44f75e 100644 --- a/frontend/src/assets/hotline/hotline.d.ts +++ b/frontend/src/assets/hotline/hotline.d.ts @@ -1,3 +1,7 @@ +/** + * @author LiraVis + */ + // DistHotline export interface DistPoint { x: number; diff --git a/frontend/src/pages/Main.tsx b/frontend/src/pages/Main.tsx index 273f92fa..7cbcca5f 100644 --- a/frontend/src/pages/Main.tsx +++ b/frontend/src/pages/Main.tsx @@ -8,7 +8,7 @@ import { getAllConditions } from '../queries/conditions'; import ConditionsMap from '../Components/Conditions/ConditionsMap'; import Search from '../Components/Map/Inputs/Search'; -import ForceMapUpdate from '../Components/Map/ForceMapUpdate'; +import ForceMapUpdate from '../Components/Map/Hooks/ForceMapUpdate'; import Paths from '../Components/Map/Paths'; import { ConditionTypeOptions, @@ -25,7 +25,7 @@ import { import MonthFilter from '../Components/Map/Inputs/MonthFilter'; import MultiSelector from '../Components/Map/Inputs/MultiSelector'; import '../css/navbar.css'; -import DetectMapClick from '../Components/Map/DetectMapClick'; +import DetectMapClick from '../Components/Map/Hooks/DetectMapClick'; import RoadInfoCard from '../Components/Map/InfoCard'; import { useNavigate } from 'react-router-dom'; import InfoButton from '../Components/Conditions/InfoButton'; @@ -197,12 +197,10 @@ const Main: FC = () => { onPlaceSelect={(value: any) => { const osm_id = value?.properties?.datasource?.raw?.osm_id; if (osm_id && roads) { - console.debug(osm_id, roads.length); for (let idx = 0; idx < roads.length; idx++) { if ( Object.keys(roads[idx].geometries).includes(String(osm_id)) ) { - console.debug('Found road', idx); setSelectedRoadIdx(idx); break; } diff --git a/frontend/src/queries/conditions.ts b/frontend/src/queries/conditions.ts index 1d7036c8..0b0a875d 100644 --- a/frontend/src/queries/conditions.ts +++ b/frontend/src/queries/conditions.ts @@ -3,6 +3,9 @@ import { FeatureCollection } from 'geojson'; import { Survey } from '../models/models'; import { SurveyList } from '../../../backend/src/models'; +/** + * @author Muro + */ export const getSurveyData = ( surveyId: string, setConditions: (data: Survey) => void, @@ -19,6 +22,9 @@ export const getAllSurveyData = (callback: (surveys: SurveyList) => void) => { get('/surveys/all', callback); }; +/** + * @author LiraVis + */ export const getAllConditions = ( callback: (data: FeatureCollection) => void, ) => { diff --git a/frontend/src/queries/fetch.ts b/frontend/src/queries/fetch.ts index cbdef5c6..493bc06f 100644 --- a/frontend/src/queries/fetch.ts +++ b/frontend/src/queries/fetch.ts @@ -39,7 +39,10 @@ export function getWithQueryParameters( asyncGetWithQueryParameters(path, obj) .then((res) => callback(res.data)) .catch((err) => { - console.log(err); + console.warn( + 'Error occurred with getting (GET) data with query parameters: ', + err, + ); }); } diff --git a/frontend/src/queries/images.ts b/frontend/src/queries/images.ts index 9ddbf3eb..3e9dd2a1 100644 --- a/frontend/src/queries/images.ts +++ b/frontend/src/queries/images.ts @@ -33,6 +33,14 @@ export const getImagesForASurvey = ( ); }; +/** + * + * @param wayIds the way ids used to filter the images + * @param isDashCam boolean to indicate if the images are dash camera images or road surface images + * @param callback the function called back when the request is responded + * + * @author Kerbourc'h + */ export const getImagesForWays = ( wayIds: string[], isDashCam: boolean, diff --git a/frontend/src/queries/road.ts b/frontend/src/queries/road.ts index c0d5c15c..c576df50 100644 --- a/frontend/src/queries/road.ts +++ b/frontend/src/queries/road.ts @@ -2,10 +2,21 @@ import { IRoad } from '../models/path'; import { get, post } from './fetch'; import { PathWithConditions } from '../models/models'; +/** + * @param setRoads the function called back with the roads paths + * + * @author Kerbourc'h + */ export const getRoadsPaths = (setRoads: (data: IRoad[]) => void) => { get('/roads/paths', setRoads); }; +/** + * @param wayIds the way ids used to filter the data + * @param callback the function called back when the request is responded + * + * @author Kerbourc'h + */ export const getRoadsData = ( wayIds: string[], callback: (data: PathWithConditions) => void, diff --git a/frontend/src/queries/upload.ts b/frontend/src/queries/upload.ts index d9275223..ca4fc97a 100644 --- a/frontend/src/queries/upload.ts +++ b/frontend/src/queries/upload.ts @@ -1,5 +1,15 @@ import { postForm } from './fetch'; +/** + * Uploads a survey to the backend. + * + * @param file the zip file + * @param password the password (to prevent unauthorized uploads) + * @param onSuccess the callback on success + * @param onError the callback on error + * + * @author Kerbourc'h + */ export const uploadSurvey = ( file: File, password: string,