-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,638 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
{ | ||
"root": true, | ||
"plugins": ["cypress"], | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:cypress/recommended" | ||
], | ||
"extends": ["next/core-web-vitals", "plugin:cypress/recommended", "prettier"], | ||
"rules": { | ||
"linebreak-style": ["error", "unix"], | ||
"quotes": ["error", "single"], | ||
"semi": ["error", "never"] | ||
}, | ||
"ignorePatterns": ["components/vendor", "static"] | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": ["node_modules", "components/vendor", "static"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"prettier.singleQuote": false, | ||
"prettier.semi": false, | ||
"prettier.singleQuote": true | ||
"eslint.validate": ["javascript"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ImSpinner8 } from 'react-icons/im' | ||
import { keyframes, styled } from 'styled-components' | ||
|
||
const spin = keyframes` | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
` | ||
|
||
const StyledSpinner = styled(ImSpinner8)` | ||
animation: ${spin} 1s linear infinite; | ||
` | ||
|
||
const ButtonSpinner = () => <StyledSpinner /> | ||
|
||
export default ButtonSpinner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { Box, Text } from 'ooni-components' | ||
import { StackedBarChart } from 'components/aggregation/mat/StackedBarChart' | ||
import { FunnelChart } from 'components/aggregation/mat/FunnelChart' | ||
import { NoCharts } from 'components/aggregation/mat/NoCharts' | ||
import TableView from 'components/aggregation/mat/TableView' | ||
import { useMemo } from 'react' | ||
import useSWR from 'swr' | ||
import dayjs from 'services/dayjs' | ||
import { axiosResponseTime } from 'components/axios-plugins' | ||
import axios from 'axios' | ||
import { MATContextProvider } from 'components/aggregation/mat/MATContext' | ||
import { useIntl } from 'react-intl' | ||
import { ResizableBox } from './aggregation/mat/Resizable' | ||
import { FormattedMarkdownBase } from './FormattedMarkdown' | ||
|
||
axiosResponseTime(axios) | ||
|
||
const swrOptions = { | ||
revalidateOnFocus: false, | ||
dedupingInterval: 10 * 60 * 1000, | ||
} | ||
|
||
const fetcher = (query) => { | ||
const qs = new URLSearchParams(query).toString() | ||
const reqUrl = `${process.env.NEXT_PUBLIC_OONI_API}/api/v1/aggregation?${qs}` | ||
console.debug(`API Query: ${reqUrl}`) | ||
return axios | ||
.get(reqUrl) | ||
.then((r) => { | ||
return { | ||
data: r.data, | ||
loadTime: r.loadTime, | ||
url: r.config.url, | ||
} | ||
}) | ||
.catch((e) => { | ||
// throw new Error(e?.response?.data?.error ?? e.message) | ||
const error = new Error('An error occurred while fetching the data.') | ||
// Attach extra info to the error object. | ||
error.info = e.response.data.error | ||
error.status = e.response.status | ||
throw error | ||
}) | ||
} | ||
|
||
export const MATChartReportWrapper = ({link, caption}) => { | ||
let searchParams | ||
const today = dayjs.utc().add(1, 'day') | ||
const monthAgo = dayjs.utc(today).subtract(1, 'month') | ||
|
||
try { | ||
if (link) searchParams = Object.fromEntries(new URL(link).searchParams) | ||
} catch (e) { | ||
console.log('e', link, e) | ||
searchParams = null | ||
} | ||
|
||
//TODO: make sure searchParams are only the ones that are allowed | ||
const query = { | ||
test_name: 'web_connectivity', | ||
axis_x: 'measurement_start_day', | ||
since: monthAgo.format('YYYY-MM-DD'), | ||
until: today.format('YYYY-MM-DD'), | ||
time_grain: 'day', | ||
...searchParams, | ||
} | ||
|
||
return !!searchParams && | ||
<Box my={4}> | ||
<MATChart query={query} /> | ||
{caption && ( | ||
<Text fontSize={1} mt={2}> | ||
<FormattedMarkdownBase>{caption}</FormattedMarkdownBase> | ||
</Text> | ||
)} | ||
</Box> | ||
} | ||
|
||
const MATChart = ({ query }) => { | ||
const intl = useIntl() | ||
const { data, error, isValidating } = useSWR(query ? query : null, fetcher, swrOptions) | ||
|
||
const showLoadingIndicator = useMemo(() => isValidating, [isValidating]) | ||
return ( | ||
<Box> | ||
<MATContextProvider queryParams={query}> | ||
{error && <NoCharts message={error?.info ?? JSON.stringify(error)} />} | ||
<Box> | ||
{showLoadingIndicator ? ( | ||
<Box> | ||
<h2>{intl.formatMessage({ id: 'General.Loading' })}</h2> | ||
</Box> | ||
) : ( | ||
<> | ||
{data?.data?.result?.length > 0 ? | ||
<Box sx={{ minHeight: '500px' }}> | ||
{data && data.data.dimension_count == 0 && <FunnelChart data={data.data.result} />} | ||
{data && data.data.dimension_count == 1 && <StackedBarChart data={data.data.result} query={query} />} | ||
{data && data.data.dimension_count > 1 && ( | ||
<TableView data={data.data.result} query={query} /> | ||
)} | ||
</Box> : <ResizableBox><NoCharts /></ResizableBox> | ||
} | ||
</> | ||
)} | ||
</Box> | ||
</MATContextProvider> | ||
</Box> | ||
) | ||
} | ||
|
||
export default MATChart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* global process */ | ||
import React from 'react' | ||
import { Container, Flex, Box, Heading, Text } from 'ooni-components' | ||
import { useRouter } from 'next/router' | ||
|
||
import OONI404 from '../public/static/images/OONI_404.svg' | ||
import { useIntl } from 'react-intl' | ||
|
||
const NotFound = ({ title }) => { | ||
const { asPath } = useRouter() | ||
const intl = useIntl() | ||
|
||
return ( | ||
<Container> | ||
<Flex justifyContent="space-around" alignItems="center" my={5}> | ||
<OONI404 height="200px" /> | ||
<Box width={1 / 2}> | ||
<Heading h={4}>{title}</Heading> | ||
<Text color="gray8">{`${process.env.NEXT_PUBLIC_EXPLORER_URL}${asPath}`}</Text> | ||
</Box> | ||
</Flex> | ||
</Container> | ||
) | ||
} | ||
|
||
export default NotFound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
022498c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
explorer – ./
explorer-one.vercel.app
explorer-git-master-ooni1.vercel.app
explorer-ooni1.vercel.app