From ed9299b0a6f15d9c82489463a6946a49bcd4dece Mon Sep 17 00:00:00 2001 From: hudaif747 Date: Mon, 11 Nov 2024 17:27:50 +0100 Subject: [PATCH 1/3] Updated namespace with keyInfo item; added 'anyOption' to records --- frontend/src/types/pandemos.ts | 76 ++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/frontend/src/types/pandemos.ts b/frontend/src/types/pandemos.ts index a6928337..3b70e1cf 100644 --- a/frontend/src/types/pandemos.ts +++ b/frontend/src/types/pandemos.ts @@ -3,31 +3,37 @@ /** Display names for the diffent enums of the pandemos data */ export namespace KeyInfo { + export const anyOption: KeyInfoItem = { + icon: '🤷', + fullName: "Any/Don't Care", + }; /** Locations */ - export const location_type: Record = { - /** Home */ 0: '🏡', - /** School */ 1: '🏫', - /** Work */ 2: '🏭/🏢', - /** Social Event */ 3: '🏟', - /** Shopping */ 4: '🏪', - /** Hospital */ 5: '🏥❗', - /** ICU */ 6: '🏥‼', - /** Car */ 7: '🚘', - /** Public */ 8: '⛲', - /** Transport */ 9: '🚍', - /** Cemetery */ 10: '⚰', + export const location_type: Record = { + /** Any */ 0: anyOption, + /** Home */ 1: {icon: '🏡', fullName: 'Home'}, + /** School */ 2: {icon: '🏫', fullName: 'School'}, + /** Work */ 3: {icon: '🏭/🏢', fullName: 'Workplace'}, + /** Social Event */ 4: {icon: '🏟', fullName: 'Social Event'}, + /** Shopping */ 5: {icon: '🏪', fullName: 'Shopping'}, + /** Hospital */ 6: {icon: '🏥❗', fullName: 'Hospital'}, + /** ICU */ 7: {icon: '🏥‼', fullName: 'Intensive Care Unit'}, + /** Car */ 8: {icon: '🚘', fullName: 'Car'}, + /** Public */ 9: {icon: '⛲', fullName: 'Public Space'}, + /** Transport */ 10: {icon: '🚍', fullName: 'Public Transport'}, + /** Cemetery */ 11: {icon: '⚰', fullName: 'Cemetery'}, }; - export const transport_mode: Record = { - /** Bike */ 0: '🚴‍♀️', - /** Car (Driver) */ 1: '🚘👤', - /** Car (Passenger) */ 2: '🚘👥', - /** Bus */ 3: '🚍', - /** Walking */ 4: '🚶‍♀️', - /** Other */ 5: '🛸', - /** Unknown */ 6: '❓', + export const transport_mode: Record = { + /** Any */ 0: anyOption, + /** Bike */ 1: {icon: '🚴‍♀️', fullName: 'Bicycle'}, + /** Car (Driver) */ 2: {icon: '🚘👤', fullName: 'Car as Driver'}, + /** Car (Passenger) */ 3: {icon: '🚘👥', fullName: 'Car as Passenger'}, + /** Bus */ 4: {icon: '🚍', fullName: 'Bus'}, + /** Walking */ 5: {icon: '🚶‍♀️', fullName: 'Walking'}, + /** Other */ 6: {icon: '🛸', fullName: 'Other Mode'}, + /** Unknown */ 7: {icon: '❓', fullName: 'Unknown Mode'}, }; - + export const activity: Record = { /** Workplace */ 0: 'Workplace', /** Education */ 1: 'Education', @@ -38,16 +44,17 @@ export namespace KeyInfo { /** Going Home */ 6: 'Going Home', /** Unknown */ 7: 'Unknown', }; - export const infection_state: Record = { - /** Susceptible */ 0: '🙂', - /** Infected with no symptoms */ 1: '🤔', - /** Infected with symptoms */ 2: '🤧', - /** Infected with severe symptoms */ 3: '🤒', - /** Infected with critical symptoms */ 4: '🤮', - /** Recovered */ 5: '😀', - /** Dead */ 6: '💀', - /** Unknown */ 7: '❓', - }; + export const infection_state: Record = { + /** Any */ 0: anyOption, + /** Susceptible */ 1: {icon: '🙂', fullName: 'Susceptible to Infection'}, + /** Infected with no symptoms */ 2: {icon: '🤔', fullName: 'Asymptomatic Infection'}, + /** Infected with symptoms */ 3: {icon: '🤧', fullName: 'Symptomatic Infection'}, + /** Infected with severe symptoms */ 4: {icon: '🤒', fullName: 'Severely Symptomatic'}, + /** Infected with critical symptoms */ 5: {icon: '🤮', fullName: 'Critically Symptomatic'}, + /** Recovered */ 6: {icon: '😀', fullName: 'Recovered from Infection'}, + /** Dead */ 7: {icon: '💀', fullName: 'Deceased'}, + /** Unknown */ 8: {icon: '❓', fullName: 'Unknown State'}, + }; } export interface Agent { @@ -103,4 +110,9 @@ export interface TripChain { chain_id: number; agent_id: number; trips: Array; -} \ No newline at end of file +} + +export interface KeyInfoItem { + icon: string; + fullName: string; +} From 016b3218b37734ae1108cfe467afab672b7ac3dd Mon Sep 17 00:00:00 2001 From: Hudaif <65321194+hudaif747@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:08:49 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Moritz Zeumer <25636783+NXXR@users.noreply.github.com> --- frontend/src/types/pandemos.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/types/pandemos.ts b/frontend/src/types/pandemos.ts index 3b70e1cf..9c523a3e 100644 --- a/frontend/src/types/pandemos.ts +++ b/frontend/src/types/pandemos.ts @@ -5,7 +5,7 @@ export namespace KeyInfo { export const anyOption: KeyInfoItem = { icon: '🤷', - fullName: "Any/Don't Care", + fullName: "Any", }; /** Locations */ export const location_type: Record = { @@ -16,7 +16,7 @@ export namespace KeyInfo { /** Social Event */ 4: {icon: '🏟', fullName: 'Social Event'}, /** Shopping */ 5: {icon: '🏪', fullName: 'Shopping'}, /** Hospital */ 6: {icon: '🏥❗', fullName: 'Hospital'}, - /** ICU */ 7: {icon: '🏥‼', fullName: 'Intensive Care Unit'}, + /** ICU */ 7: {icon: '🏥‼', fullName: 'Intensive Care'}, /** Car */ 8: {icon: '🚘', fullName: 'Car'}, /** Public */ 9: {icon: '⛲', fullName: 'Public Space'}, /** Transport */ 10: {icon: '🚍', fullName: 'Public Transport'}, @@ -30,8 +30,8 @@ export namespace KeyInfo { /** Car (Passenger) */ 3: {icon: '🚘👥', fullName: 'Car as Passenger'}, /** Bus */ 4: {icon: '🚍', fullName: 'Bus'}, /** Walking */ 5: {icon: '🚶‍♀️', fullName: 'Walking'}, - /** Other */ 6: {icon: '🛸', fullName: 'Other Mode'}, - /** Unknown */ 7: {icon: '❓', fullName: 'Unknown Mode'}, + /** Other */ 6: {icon: '🛸', fullName: 'Other'}, + /** Unknown */ 7: {icon: '❓', fullName: 'Unknown'}, }; export const activity: Record = { @@ -53,7 +53,7 @@ export namespace KeyInfo { /** Infected with critical symptoms */ 5: {icon: '🤮', fullName: 'Critically Symptomatic'}, /** Recovered */ 6: {icon: '😀', fullName: 'Recovered from Infection'}, /** Dead */ 7: {icon: '💀', fullName: 'Deceased'}, - /** Unknown */ 8: {icon: '❓', fullName: 'Unknown State'}, + /** Unknown */ 8: {icon: '❓', fullName: 'Unknown'}, }; } From 888ed1880d8925a6e2fb87dc40227fc4d99c9504 Mon Sep 17 00:00:00 2001 From: hudaif747 Date: Tue, 12 Nov 2024 14:10:40 +0100 Subject: [PATCH 3/3] lint and formatter fixes --- frontend/src/data_sockets/PandemosContext.tsx | 11 +++++------ frontend/src/types/pandemos.ts | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/data_sockets/PandemosContext.tsx b/frontend/src/data_sockets/PandemosContext.tsx index 1c94bce0..383fe3a8 100644 --- a/frontend/src/data_sockets/PandemosContext.tsx +++ b/frontend/src/data_sockets/PandemosContext.tsx @@ -1,12 +1,11 @@ // SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) // SPDX-License-Identifier: Apache-2.0 -import React, {createContext, useCallback, useEffect, useMemo, useState} from 'react'; +import React, {createContext, useEffect, useMemo, useState} from 'react'; import crossfilter, {Crossfilter} from 'crossfilter2'; import agentList from '../../assets/pandemos/agents_lookup.json?url'; import locationList from '../../assets/pandemos/locations_lookup.json?url'; import trajectories from '../../assets/pandemos/trajectories.json?url'; -import hash from 'object-hash'; import {Agent, Location, Trip, TripExpanded, TripChain} from 'types/pandemos'; /** * Data context for the pandemos data. @@ -90,9 +89,9 @@ export const PandemosProvider = ({children}: {children: React.ReactNode}) => { trips?.map((trip) => { return { ...trip, - agent_age_group: agents![trip.agent_id].age_group, - start_location_type: locations![trip.start_location].location_type, - end_location_type: locations![trip.end_location].location_type, + agent_age_group: agents[trip.agent_id].age_group, + start_location_type: locations[trip.start_location].location_type, + end_location_type: locations[trip.end_location].location_type, } as TripExpanded; }) ); @@ -120,7 +119,7 @@ export const PandemosProvider = ({children}: {children: React.ReactNode}) => { tripChains.push({agent_id: trip.agent_id, chain_id: chain_id++, trips: tripChain.slice(start, index + 1)}); }); } - return tripChains + return tripChains; }, [trips, locations]); return ( diff --git a/frontend/src/types/pandemos.ts b/frontend/src/types/pandemos.ts index 9c523a3e..e532f8c9 100644 --- a/frontend/src/types/pandemos.ts +++ b/frontend/src/types/pandemos.ts @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 /** Display names for the diffent enums of the pandemos data */ +/* eslint-disable @typescript-eslint/no-namespace */ export namespace KeyInfo { export const anyOption: KeyInfoItem = { icon: '🤷', - fullName: "Any", + fullName: 'Any', }; /** Locations */ export const location_type: Record = {