Skip to content

Commit f335596

Browse files
committed
Add SIG filter w/ SOTA and POTA
-Also at FT4 to mode filters
1 parent 0d5f2e4 commit f335596

File tree

5 files changed

+68
-7
lines changed

5 files changed

+68
-7
lines changed

src/@types/ContextTypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ContextData {
2121
errorSeverity: string;
2222
themeMode: string;
2323
onlyNewFilter: boolean;
24+
sigFilter: string;
2425
otherOperators: string;
2526
}
2627

src/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,15 @@ def set_only_new_filter(self, filter_only_new: bool):
343343
logging.debug(f"api setting ATNO filter to: {filter_only_new}")
344344
self.db.set_only_new_filter(filter_only_new)
345345

346+
def set_sig_filter(self, sig_filter: str):
347+
'''
348+
Set the Special Interest Group (sig) filter.
349+
350+
:param string sig_filter: only POTA or SOTA
351+
'''
352+
logging.debug(f"api setting SIG filter to: {sig_filter}")
353+
self.db.set_sig_filter(sig_filter)
354+
346355
def update_activator_stats(self, callsign: str) -> int:
347356
j = self.pota.get_activator_stats(callsign)
348357

src/components/AppContext.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const defData: ContextData = {
2424
themeMode: 'dark',
2525
onlyNewFilter: false,
2626
otherOperators: '',
27-
summit: null
27+
summit: null,
28+
sigFilter: ''
2829
};
2930

3031
export const AppContext = React.createContext<AppContextType | null>(null);
@@ -50,7 +51,8 @@ export const AppContextProvider = ( {children}: any ) => {
5051
themeMode: ctx.themeMode,
5152
onlyNewFilter: ctx.onlyNewFilter,
5253
otherOperators: ctx.otherOperators,
53-
summit: ctx.summit
54+
summit: ctx.summit,
55+
sigFilter: ctx.sigFilter
5456
}
5557
setContextData(newContext);
5658
};

src/components/FilterBar/FilterBar.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const FilterBar = (props: IFilterBarPros) => {
2323
const [band, setBand] = React.useState('');
2424
const [region, setRegion] = React.useState('');
2525
const [location, setLocation] = React.useState('');
26+
const [sig, setSig] = React.useState('');
2627
const [qrt, setQrt] = React.useState(true);
2728
const [hunted, setHunted] = React.useState(false);
2829
const [onlyNew, setOnlyNew] = React.useState(false);
@@ -53,6 +54,9 @@ export const FilterBar = (props: IFilterBarPros) => {
5354
setHuntedFilter((hf === "true"));
5455
let on = window.localStorage.getItem("ATNO_FILTER");
5556
setOnlyNewFilter((on === "true"));
57+
58+
let sf = window.localStorage.getItem("SIG_FILTER") || '';
59+
setSigFilter(sf);
5660
};
5761
}, []);
5862

@@ -81,6 +85,12 @@ export const FilterBar = (props: IFilterBarPros) => {
8185
window.localStorage.setItem("LOCATION_FILTER", l);
8286
}
8387

88+
const handleSigChange = (event: SelectChangeEvent) => {
89+
let sig = event.target.value as string;
90+
setSigFilter(sig);
91+
window.localStorage.setItem("SIG_FILTER", sig);
92+
}
93+
8494
const handleClear = () => {
8595
setMode("");
8696
setBand("0");
@@ -93,11 +103,13 @@ export const FilterBar = (props: IFilterBarPros) => {
93103
window.pywebview.api.set_qrt_filter(true);
94104
window.pywebview.api.set_hunted_filter(false);
95105
window.pywebview.api.set_only_new_filter(false);
106+
window.pywebview.api.set_sig_filter("");
96107
setRegion("");
97108
setLocation("");
98109
setQrt(true);
99110
setHunted(false);
100111
setOnlyNew(false);
112+
setSig("");
101113

102114
window.localStorage.setItem("BAND_FILTER", '0');
103115
window.localStorage.setItem("REGION_FILTER", '');
@@ -106,7 +118,7 @@ export const FilterBar = (props: IFilterBarPros) => {
106118
window.localStorage.setItem("QRT_FILTER", 'true');
107119
window.localStorage.setItem("HUNTED_FILTER", 'false');
108120
window.localStorage.setItem("ATNO_FILTER", 'false');
109-
121+
110122
const next = {
111123
...contextData,
112124
bandFilter: 0,
@@ -200,6 +212,16 @@ export const FilterBar = (props: IFilterBarPros) => {
200212
setLocation(l);
201213
}
202214

215+
function setSigFilter(sig: string) {
216+
console.log("changing sig filt to: " + sig);
217+
window.pywebview.api.set_sig_filter(sig);
218+
219+
let next = { ...contextData, locationFilter: sig };
220+
setData(next);
221+
setSig(sig);
222+
}
223+
224+
203225
const StyledTypoGraphy = styled(Typography)(({ theme }) =>
204226
theme.unstable_sx({
205227
fontSize: {
@@ -277,6 +299,7 @@ export const FilterBar = (props: IFilterBarPros) => {
277299
<MenuItem value='CW'>CW</MenuItem>
278300
<MenuItem value='SSB'>SSB</MenuItem>
279301
<MenuItem value='FT8'>FT8</MenuItem>
302+
<MenuItem value='FT4'>FT4</MenuItem>
280303
</Select>
281304
</FormControl>
282305
<FormControl size='small'>
@@ -315,6 +338,21 @@ export const FilterBar = (props: IFilterBarPros) => {
315338
))}
316339
</Select>
317340
</FormControl>
341+
<FormControl size='small'>
342+
<StyledInputLabel id="sig-lbl">SIG</StyledInputLabel>
343+
<Select
344+
labelId="sig-lbl"
345+
id="sig"
346+
value={sig}
347+
variant='standard'
348+
sx={{ minWidth: 100 }}
349+
onChange={handleSigChange}
350+
>
351+
<MenuItem value=""><em>None</em></MenuItem>
352+
<MenuItem value='POTA'>POTA</MenuItem>
353+
<MenuItem value='SOTA'>SOTA</MenuItem>
354+
</Select>
355+
</FormControl>
318356
<Button onClick={handleClear} variant="outlined"
319357
sx={{ maxWidth: 100 }}>
320358
Clear

src/db/db.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ def update_all_spots(self, spots_json, sota_spots):
193193
to_add.is_qrt = True
194194

195195
for sota in sota_spots:
196-
# the sota spots are returned in a descending spot time order. where
197-
# the first spot is the newest.
196+
# the sota spots are returned in a descending spot time order.
197+
# where the first spot is the newest.
198198
sota_to_add = Spot()
199199
sota_to_add.init_from_sota(sota)
200200

@@ -314,7 +314,7 @@ def build_qso_from_spot(self, spot_id: int) -> Qso:
314314
if (s.spot_source == 'POTA'):
315315
a = self.get_activator(s.activator)
316316
name = a.name if a is not None else ""
317-
elif s.spot_source == 'SOTA' :
317+
elif s.spot_source == 'SOTA':
318318
name = s.name
319319
if s.grid4 == '':
320320
sota_api = SotaApi()
@@ -353,13 +353,17 @@ def set_only_new_filter(self, is_on: bool):
353353
logging.debug(f"db setting ATNO filter to {is_on}")
354354
self.only_new_on = is_on
355355

356+
def set_sig_filter(self, sig: str):
357+
self.sig_filter = sig
358+
356359
def _get_all_filters(self) -> list[sa.ColumnElement[bool]]:
357360
return self._get_band_filters() + \
358361
self._get_region_filters() + \
359362
self._get_location_filters() + \
360363
self._get_qrt_filter() + \
361364
self._get_hunted_filter() + \
362-
self._get_only_new_filter()
365+
self._get_only_new_filter() + \
366+
self._get_sig_filter()
363367

364368
def _get_band_filters(self) -> list[sa.ColumnElement[bool]]:
365369
band = Bands(self.band_filter) # not sure why cast is needed
@@ -403,3 +407,10 @@ def _get_only_new_filter(self) -> list[sa.ColumnElement[bool]]:
403407
return [Spot.park_hunts == 0] # noqa E712
404408
terms = []
405409
return terms
410+
411+
def _get_sig_filter(self) -> list[sa.ColumnElement[bool]]:
412+
sig = self.sig_filter
413+
if (sig is None or sig == ''):
414+
return []
415+
terms = [Spot.spot_source == sig]
416+
return terms

0 commit comments

Comments
 (0)