Skip to content

Commit d13188d

Browse files
Merge pull request #2473 from asfadmin/tyler/nisar-default-filter
NISAR default filters
2 parents c6f1de2 + d67dcf7 commit d13188d

7 files changed

Lines changed: 80 additions & 4 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('NISAR default filter sticks around', async ({ page }) => {
4+
await page.goto('/');
5+
await page.getByRole('button', { name: 'Sentinel-' }).click();
6+
await page
7+
.getByRole('menuitem', { name: 'NISAR (Uncalibrated) NISAR' })
8+
.click();
9+
await expect(page.locator('app-info-bar')).toContainText(
10+
'Production Configuration: PR',
11+
);
12+
await page.locator('#mat-button-toggle-9-button').click();
13+
await page.getByRole('menuitem', { name: 'Clear Search' }).click();
14+
await expect(page.locator('app-info-bar')).toContainText(
15+
'Production Configuration: PR',
16+
);
17+
await page.getByRole('button', { name: 'Filters', exact: true }).click();
18+
await page
19+
.locator('div')
20+
.filter({ hasText: /^Production ConfigurationProduction$/ })
21+
.first()
22+
.click();
23+
await page.getByRole('option', { name: 'Production' }).click();
24+
await page.getByText('Urgent Response').click();
25+
await page.locator('.cdk-overlay-backdrop').click();
26+
27+
await expect(page.locator('app-info-bar')).toContainText(
28+
'Production Configuration: UR',
29+
);
30+
await page.locator('#mat-button-toggle-7-button').click();
31+
await page.getByRole('menuitem', { name: 'Clear Search' }).click();
32+
await expect(page.locator('app-info-bar')).toContainText(
33+
'Production Configuration: PR',
34+
);
35+
});

src/app/components/shared/selectors/production-config-selector/production-config-selector.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ProductionConfigSelectorComponent implements OnInit, OnDestroy {
3333
private store$ = inject<Store<AppState>>(Store);
3434

3535
prodConfigControl = new FormControl(['']);
36-
public selectedConfig: string[] = ['PR']; // Default selected config
36+
public selectedConfig: string[] = [];
3737

3838
prodConfigs: prodConfig[] = [
3939
{ value: 'PR', viewValue: 'PRODUCTION' },
@@ -44,8 +44,6 @@ export class ProductionConfigSelectorComponent implements OnInit, OnDestroy {
4444
private subs: SubSink = new SubSink();
4545

4646
public ngOnInit(): void {
47-
this.onProductionConfigSelect(this.selectedConfig);
48-
4947
this.subs.add(
5048
this.store$
5149
.select(filtersStore.getProductionConfig)

src/app/models/dataset.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FiltersState } from '@store/filters';
12
import * as fromDatasets from './datasets';
23
import { Props } from './filters.model';
34

@@ -8,6 +9,7 @@ export interface Dataset {
89
beta: boolean;
910
apiValue: Record<string, string>;
1011
date: DateRange;
12+
defaultFilters?: Partial<FiltersState>;
1113
infoUrl: string;
1214
citationUrl: string;
1315
productTypes: ProductType[];

src/app/models/datasets/nisar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const nisar = {
2323
],
2424
apiValue: { dataset: 'NISAR' },
2525
date: { start: new Date('2025/08/02 03:44:43 UTC') },
26+
defaultFilters: {
27+
productionConfig: ['PR'],
28+
},
2629
infoUrl: 'https://nisar-docs.asf.alaska.edu/',
2730
citationUrl: 'https://asf.alaska.edu/nisar/',
2831
frequency: 'L-Band',

src/app/store/filters/filters.action.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Action } from '@ngrx/store';
22

33
import * as models from '@models';
44
import { EventProductSort, SBASOverlap } from '@models';
5+
import { FiltersState } from './filters.reducer';
56

67
export enum FiltersActionType {
78
SET_SELECTED_DATASET = '[Filters-Dataset] Set Selected Dataset',
@@ -111,6 +112,8 @@ export enum FiltersActionType {
111112
SET_ARIA_VERSION = '[Filters] Set ARIA Version',
112113

113114
SET_USER_FRAME_FOR_BASELINE = '[Filters] Set if frame(s) used for baseline/sbas searches as reference scene',
115+
116+
APPLY_DATASET_DEFAULTS = '[Filters] Apply dataset default filters',
114117
}
115118

116119
export class SetSelectedDataset implements Action {
@@ -443,6 +446,12 @@ export class SetDefaultFilters implements Action {
443446
) {}
444447
}
445448

449+
export class ApplyDatasetDefaults implements Action {
450+
public readonly type = FiltersActionType.APPLY_DATASET_DEFAULTS;
451+
452+
constructor(public payload: Partial<FiltersState>) {}
453+
}
454+
446455
export class SetGeocode implements Action {
447456
public readonly type = FiltersActionType.SET_GEOCODE;
448457

@@ -605,4 +614,5 @@ export type FiltersActions =
605614
| setScienceProduct
606615
| setProductionConfig
607616
| setAriaVersion
608-
| SetUseFrameForBaseline;
617+
| SetUseFrameForBaseline
618+
| ApplyDatasetDefaults;

src/app/store/filters/filters.effect.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { getSearchType } from '@store/search';
1717
import { LoadFiltersPreset } from '@store/user';
1818
import { ResetMaxHyp3ResultsHit } from '@store/hyp3';
1919
import { SearchType } from '@models';
20+
import { getSelectedDataset } from './filters.reducer';
2021

2122
@Injectable()
2223
export class FiltersEffects {
@@ -76,4 +77,24 @@ export class FiltersEffects {
7677
map((_) => new ResetMaxHyp3ResultsHit()),
7778
),
7879
);
80+
81+
public applyDefaultFilters = createEffect(() =>
82+
this.actions$.pipe(
83+
ofType(
84+
filtersAction.FiltersActionType.CLEAR_DATASET_FILTERS,
85+
filtersAction.FiltersActionType.SET_SELECTED_DATASET,
86+
),
87+
withLatestFrom(this.store$.select(getSelectedDataset)),
88+
filter(([_, dataset]) => !!dataset),
89+
map(([_, dataset]) => {
90+
const defaults = dataset.defaultFilters;
91+
if (!defaults) {
92+
return null;
93+
}
94+
95+
return new filtersAction.ApplyDatasetDefaults(defaults);
96+
}),
97+
filter((a) => a !== null),
98+
),
99+
);
79100
}

src/app/store/filters/filters.reducer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ export function filtersReducer(
498498
return { ...state, shouldOmitSearchPolygon: false };
499499
}
500500

501+
case FiltersActionType.APPLY_DATASET_DEFAULTS: {
502+
return {
503+
...state,
504+
...action.payload,
505+
};
506+
}
507+
501508
case FiltersActionType.OMIT_SEARCH_POLYGON: {
502509
return { ...state, shouldOmitSearchPolygon: true };
503510
}

0 commit comments

Comments
 (0)