Skip to content

Commit

Permalink
Add support for ooni run id filtering for measurements and mat
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Oct 26, 2023
1 parent 8708170 commit 444ec76
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions components/aggregation/mat/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const defaultDefaultValues = {
axis_x: 'measurement_start_day',
axis_y: '',
time_grain: 'day',
ooni_run_link_id: '',
}

export const Form = ({ onSubmit, query }) => {
Expand Down Expand Up @@ -424,6 +425,18 @@ export const Form = ({ onSubmit, query }) => {
</Box>
</>
)}
<Box width={[1, 1 / 5]}>
<Controller
name='ooni_run_link_id'
control={control}
render={({ field }) => (
<Input
label={intl.formatMessage({ id: 'Search.Sidebar.OoniRunLinkId' })}
{...field}
/>
)}
/>
</Box>
</Flex>
<Flex my={4}>
<Button data-test-id='mat-form-submit' width={[1, 'unset']} onClick={maybeWarnBeforeSubmit}>
Expand Down
15 changes: 15 additions & 0 deletions components/search/FilterSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const inputRegEx =
export const queryToFilterMap = {
domain: ['domainFilter', ''],
input: ['inputFilter', ''],
ooni_run_link_id: ['ooniRunLinkId', ''],
category_code: ['categoryFilter', ''],
probe_cc: ['countryFilter', ''],
probe_asn: ['asnFilter', ''],
Expand All @@ -95,6 +96,7 @@ const FilterSidebar = ({
countries,
domainFilter,
inputFilter,
ooniRunLinkId,
categoryFilter,
onlyFilter = 'all',
testNameFilter = 'XX',
Expand All @@ -109,6 +111,7 @@ const FilterSidebar = ({
const defaultValues = {
domainFilter,
inputFilter,
ooniRunLinkId,
categoryFilter,
onlyFilter,
testNameFilter,
Expand Down Expand Up @@ -365,6 +368,7 @@ const FilterSidebar = ({
id: 'Search.Sidebar.Input.Placeholder',
})}
type='text'
mb={3}
/>
)}
rules={{
Expand All @@ -376,6 +380,17 @@ const FilterSidebar = ({
},
}}
/>
<Controller
control={control}
name='ooniRunLinkId'
render={({ field }) => (
<Input
{...field}
label={intl.formatMessage({ id: 'Search.Sidebar.OoniRunLinkId' })}
type='text'
/>
)}
/>
</>
)}

Expand Down
3 changes: 2 additions & 1 deletion pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getServerSideProps = async ({query}) => {
const queryToParams = ({ query }) => {
let params = {},
show = 50
const supportedParams = ['probe_cc', 'domain', 'input','category_code', 'probe_asn', 'test_name', 'since', 'until', 'failure']
const supportedParams = ['probe_cc', 'domain', 'input','category_code', 'probe_asn', 'test_name', 'since', 'until', 'failure', 'ooni_run_link_id']

if (query.show) {
show = parseInt(query.show)
Expand Down Expand Up @@ -273,6 +273,7 @@ const Search = ({ countries, query: queryProp }) => {
<FilterSidebar
domainFilter={query.domain}
inputFilter={query.input}
ooniRunLinkId={query.ooni_run_link_id}
categoryFilter={query.category_code}
testNameFilter={query.test_name}
countryFilter={query.probe_cc}
Expand Down
1 change: 1 addition & 0 deletions public/static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
"Search.Sidebar.From": "From",
"Search.Sidebar.Until": "Until",
"Search.Sidebar.HideFailed": "Hide failed measurements",
"Search.Sidebar.OoniRunLinkId": "OONI Run Link ID",
"Search.Sidebar.Button.FilterResults": "Filter Results",
"Search.FilterButton.AllResults": "All Results",
"Search.FilterButton.Confirmed": "Confirmed",
Expand Down

0 comments on commit 444ec76

Please sign in to comment.