From 10e711afb694cfec2368ad6195c5e34f53365bdf Mon Sep 17 00:00:00 2001 From: Ben Sherriff Date: Mon, 2 Oct 2023 21:03:51 -0400 Subject: [PATCH] Updated modal widgets --- service/docker-compose.yml | 6 +- ui/src/components/Metars/MetarModal.tsx | 138 ++++++++++++++------- ui/src/components/Metars/SkyConditions.tsx | 34 ++--- 3 files changed, 112 insertions(+), 66 deletions(-) diff --git a/service/docker-compose.yml b/service/docker-compose.yml index 3be70a0..5d1ae42 100644 --- a/service/docker-compose.yml +++ b/service/docker-compose.yml @@ -25,9 +25,9 @@ services: env_file: - .env environment: - - DATABASE_HOST: db - - SERVICE_HOST: service - - SERVICE_PORT: 5000 + DATABASE_HOST: db + SERVICE_HOST: service + SERVICE_PORT: 5000 ports: - "${SERVICE_PORT:-5000}:5000" build: diff --git a/ui/src/components/Metars/MetarModal.tsx b/ui/src/components/Metars/MetarModal.tsx index 948e54c..d61fcdd 100644 --- a/ui/src/components/Metars/MetarModal.tsx +++ b/ui/src/components/Metars/MetarModal.tsx @@ -6,6 +6,10 @@ import { FaArrowsSpin, FaLocationArrow } from 'react-icons/fa6'; import Link from 'next/link'; import { AiFillStar, AiOutlineStar } from 'react-icons/ai'; import { + BsFillCloudDrizzleFill, + BsFillCloudFogFill, + BsFillCloudHailFill, + BsFillCloudHazeFill, BsFillCloudRainFill, BsFillCloudRainHeavyFill, BsFillCloudSleetFill, @@ -13,7 +17,7 @@ import { BsQuestionLg } from 'react-icons/bs'; import { useState } from 'react'; -import { Grid, Modal, Tooltip } from '@mantine/core'; +import { Card, Divider, Grid, Modal, Tooltip } from '@mantine/core'; import './metars.css'; import SkyConditions from './SkyConditions'; @@ -43,7 +47,7 @@ export default function MetarModal({ airport, isOpen, onClose }: MetarModalProps )}
-
+ {airport.metar && }
@@ -68,22 +72,14 @@ function MetarInfo({ metar }: { metar: Metar }) { function windColor(metar: Metar | undefined) { if (metar) { if (Number(metar.wind_speed_kt) <= 9) { - return 'bg-green-300'; + return 'green'; } else if (Number(metar.wind_speed_kt) <= 12) { - return 'bg-orange-300'; + return 'orange'; } else { - return 'bg-red-300'; + return 'red'; } } else { - return 'gb-gray-100'; - } - } - - function metarIcon(weatherPhenomena: string) { - if (weatherPhenomena == 'RA') { - return <>; - } else { - return <>; + return 'gray'; } } @@ -92,26 +88,74 @@ function MetarInfo({ metar }: { metar: Metar }) {

{metar.raw_text}

- - {metar.flight_category ? metar.flight_category : 'UNKN'} - - - {metar.wind_speed_kt != undefined && metar.wind_speed_kt > 0 ? `${metar.wind_speed_kt} KT` : 'CALM'} - + + + + + {metar.flight_category ? metar.flight_category : 'UNKN'} + + + + <> + {metar.wind_speed_kt == undefined || metar.wind_speed_kt == 0 ? ( + + CALM + + ) : ( + + + {metar.wind_speed_kt} KT + + + {metar.wind_dir_degrees && Number(metar.wind_dir_degrees) > 0 ? ( + <> + + {metar.wind_dir_degrees}° + + ) : ( + <> + )} + {metar.wind_dir_degrees && metar.wind_dir_degrees == 'VRB' ? : <>} + + + )} + + + + + + + {metar.wx_string && + metar.wx_string.split(' ').map((wx) => ( + + + + ))} + + - - {metar.wx_string && metar.wx_string.split(' ').map((wx) => )} - ); @@ -141,46 +185,48 @@ function MetarIcon({ wx }: { wx: string }) { icon = ; } else if (wx.includes('GR')) { title = 'Hail'; - icon = ; + icon = ; } else if (wx.includes('GS')) { title = 'Snow Pellets'; icon = ; } else if (wx.includes('BR')) { title = 'Mist'; - icon = ; + icon = ; } else if (wx.includes('FG')) { title = 'Fog'; - icon = ; + icon = ; } else if (wx.includes('FU')) { title = 'Smoke'; - icon = ; + icon = ; } else if (wx.includes('VA')) { title = 'Volcanic Ash'; - icon = ; + icon = ; } else if (wx.includes('DU')) { title = 'Dust'; - icon = ; + icon = ; } else if (wx.includes('SA')) { title = 'Sand'; - icon = ; + icon = ; } else if (wx.includes('HZ')) { title = 'Haze'; - icon = ; + icon = ; } else { title = 'Unknown'; icon = ; } - // if (wx.charAt(0) == '+') { - // color = ''; - // } else if (wx.charAt(0) == '-') { - // color = ''; - // } else { - // color = ''; - // } return ( - {icon} + + {icon} + ); } diff --git a/ui/src/components/Metars/SkyConditions.tsx b/ui/src/components/Metars/SkyConditions.tsx index 3d170c7..b69f6b3 100644 --- a/ui/src/components/Metars/SkyConditions.tsx +++ b/ui/src/components/Metars/SkyConditions.tsx @@ -1,19 +1,19 @@ 'use client'; import { Metar } from '@/api/metar.types'; -import { Box, Text } from '@mantine/core'; +import { Box, Card, Divider } from '@mantine/core'; import { CartesianGrid, LabelList, Line, LineChart, XAxis, YAxis } from 'recharts'; export default function SkyConditions({ metar }: { metar: Metar }) { + const data: any = [ + { + name: 'start' + }, + { + name: 'end' + } + ]; if (metar.sky_condition && metar.sky_condition.length > 0 && metar.sky_condition[0].sky_cover != 'CLR') { - const data: any = [ - { - name: 'start' - }, - { - name: 'end' - } - ]; let maxHeight = 0; metar.sky_condition.forEach((skyCondition, index) => { data[0][index] = skyCondition.cloud_base_ft_agl; @@ -37,9 +37,9 @@ export default function SkyConditions({ metar }: { metar: Metar }) { } return ( - - Sky Conditions - + + + ))} - + ); } else { return ( - - Sky Conditions - Clear - + + + Clear Skies + ); } }