From e45ee6d8933d887a8f8af7a727aea4c5c08e817c Mon Sep 17 00:00:00 2001 From: cainan Date: Sun, 19 Jan 2025 22:16:23 -0500 Subject: [PATCH] Region filter adjustments. Regions now stored by the back end and returned to the front end. This allows it to be manipulated easier. Also allows the regions to exists for all current spots even if filtered out. Fies #47 --- src/@types/Spots.d.ts | 3 ++- src/api.py | 9 +++++++ src/components/FilterBar/FilterBar.tsx | 6 +++-- src/components/SpotViewer/SpotViewer.tsx | 33 +++++++++++++++++------- src/db/db.py | 12 +++++++++ 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/@types/Spots.d.ts b/src/@types/Spots.d.ts index d6ada96..de2f507 100644 --- a/src/@types/Spots.d.ts +++ b/src/@types/Spots.d.ts @@ -26,5 +26,6 @@ export interface SpotRow { loc_total: number, is_qrt: boolean, act_cmts: string, - cw_wpm: number + cw_wpm: number, + spot_source: string }; diff --git a/src/api.py b/src/api.py index 03b64fa..a0f2a02 100644 --- a/src/api.py +++ b/src/api.py @@ -559,6 +559,15 @@ def import_park_data(self) -> str: return self._response( True, "Park data imported successfully", persist=True) + + def get_seen_regions(self) -> str: + ''' + Gets a sorted list of distinct regions (POTA) and associations (SOTA) + that are in the current set of spots. + ''' + x = self.db.seen_regions + # logging.debug(f"return seen regions: {x}") + return self._response(True, '', seen_regions=x) def _do_update(self): ''' diff --git a/src/components/FilterBar/FilterBar.tsx b/src/components/FilterBar/FilterBar.tsx index 39fa6e9..0c9e779 100644 --- a/src/components/FilterBar/FilterBar.tsx +++ b/src/components/FilterBar/FilterBar.tsx @@ -22,7 +22,7 @@ export const FilterBar = (props: IFilterBarPros) => { const [mode, setMode] = React.useState(''); const [band, setBand] = React.useState(''); const [region, setRegion] = React.useState(''); - const [location, setLocation] = React.useState(''); + const [loc, setLocation] = React.useState(''); const [sig, setSig] = React.useState(''); const [qrt, setQrt] = React.useState(true); const [hunted, setHunted] = React.useState(false); @@ -129,6 +129,8 @@ export const FilterBar = (props: IFilterBarPros) => { onlyNew: false }; setData(next); + + location.reload(); }; function handleQrtSwitch(event: any, checked: boolean): void { @@ -327,7 +329,7 @@ export const FilterBar = (props: IFilterBarPros) => {