Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Subdao reorg (#1005)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Whitman <twhit093@gmail.com>
  • Loading branch information
allenan and tyler-whitman authored Aug 11, 2022
1 parent e4a642c commit e0a70af
Show file tree
Hide file tree
Showing 33 changed files with 540 additions and 221 deletions.
2 changes: 1 addition & 1 deletion components/InfoBox/AccountDetailsInfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const AccountDetailsInfoBox = () => {
subtitles={subtitles}
breadcrumbs={
maker
? [{ title: 'Makers', path: '/hotspots/makers' }]
? [{ title: 'Makers', path: '/iot/makers' }]
: [{ title: 'Overview', path: '/' }]
}
>
Expand Down
2 changes: 1 addition & 1 deletion components/InfoBox/BlocksInfoPanes/BlockStatisticsPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useState, useEffect } from 'react'
import ElectionTimeWidget from '../../Widgets/ElectionTimeWidget'

const BlockStatisticsPane = () => {
let { data: blocks } = useApi('/metrics/blocks')
const { data: blocks } = useApi('/metrics/blocks')

const [processingData, setProcessingData] = useState(true)
const [blockTimeDay, setBlockTimeDay] = useState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import LocationIcon from '../../Icons/Location'
import { Tooltip } from 'antd'
import { useMakers } from '../../../data/makers'

const MakersPane = () => {
const { makers } = useMakers()
const MakersPane = ({ type = 'lorawan' }) => {
const { makers } = useMakers({ type })

const keyExtractor = useCallback((maker) => maker.address, [])

Expand Down
13 changes: 9 additions & 4 deletions components/InfoBox/HotspotDetailsInfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ const HotspotDetailsInfoBox = ({ address, isLoading, hotspot }) => {
)

const generateBreadcrumbs = (hotspot) => {
if (!hotspot) return [{ title: 'Hotspots', path: '/hotspots' }]
if (!hotspot) return [{ title: 'IOT', path: '/iot' }]
return [
{ title: 'Hotspots', path: '/hotspots/latest' },
{ title: 'IOT', path: '/iot' },
...(hotspot.location
? // if the hotspot has a location, show breadcrumbs for it
[
Expand All @@ -192,7 +192,7 @@ const HotspotDetailsInfoBox = ({ address, isLoading, hotspot }) => {
<HexIndex index={hotspot.location} />
</div>
),
path: `/hotspots/hex/${hotspot.location}`,
path: `/iot/hex/${hotspot.location}`,
},
]
: []),
Expand Down Expand Up @@ -256,7 +256,12 @@ const HotspotDetailsInfoBox = ({ address, isLoading, hotspot }) => {
title="5G Statistics"
key="5g-statistics"
path="5g-statistics"
hidden={!(maker?.id === MAKER_IDS.FREEDOM_FI || maker?.id === MAKER_IDS.BOBCAT_5G)}
hidden={
!(
maker?.id === MAKER_IDS.FREEDOM_FI ||
maker?.id === MAKER_IDS.BOBCAT_5G
)
}
>
{isLoading ? (
<SkeletonWidgets />
Expand Down
30 changes: 0 additions & 30 deletions components/InfoBox/HotspotsInfoBox.js

This file was deleted.

16 changes: 10 additions & 6 deletions components/InfoBox/InfoBoxSwitch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Switch, Route } from 'react-router-dom'
import { Switch, Route, Redirect } from 'react-router-dom'
import OverviewInfoBox from './OverviewInfoBox'
import HotspotsInfoBox from './HotspotsInfoBox'
import IotInfoBox from './Iot/IotInfoBox'
import HotspotDetailsInfoBox from './HotspotDetailsInfoBox'
import ValidatorsInfoBox from './ValidatorsInfoBox'
import BlocksInfoBox from './BlocksInfoBox'
Expand All @@ -15,24 +15,28 @@ import MarketInfoBox from './MarketInfoBox'
import CommunityToolsInfoBox from './CommunityTools/CommunityToolsInfoBox'
import ErrorInfoBox from './ErrorInfoBox'
import CityDetailsInfoBox from './CityDetailsInfoBox'
import MobileInfoBox from './Mobile/MobileInfoBox'

const InfoBoxSwitch = () => {
// Match locales with regular expression containing each locale separated by `|`
const base = '/:locale(en|fr)?'

return (
<Switch>
<Route path={`${base}/hotspots/hex/:index([a-z0-9]{15})`}>
<Route path={`${base}/iot/hex/:index([a-z0-9]{15})`}>
<HexDetailsInfoBox />
</Route>
<Route path={`${base}/hotspots/:address([a-zA-Z0-9]{40,})`}>
<HotspotDetailsInfoBox />
</Route>
<Route path={`${base}/hotspots/cities/:cityid`}>
<Route path={`${base}/iot/cities/:cityid`}>
<CityDetailsInfoBox />
</Route>
<Route path={`${base}/hotspots`}>
<HotspotsInfoBox />
<Route path={`${base}/iot`}>
<IotInfoBox />
</Route>
<Route path={`${base}/mobile`}>
<MobileInfoBox />
</Route>
<Route path={`${base}/accounts/:address([a-zA-Z0-9]{40,})`}>
<AccountDetailsInfoBox />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ const CellStatisticsPane = () => {

return (
<InfoBoxPaneContainer>
<TrendWidget
title="5G Hotspots"
series={stats?.count}
isLoading={!stats}
/>
<TrendWidget title="5G Radios" series={stats?.count} isLoading={!stats} />
<StatWidget
title="Indoor Radios"
series={stats?.indoorCount}
Expand Down
33 changes: 33 additions & 0 deletions components/InfoBox/Iot/IotInfoBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useEffect } from 'react'
import InfoBox from '../InfoBox'
import TabNavbar, { TabPane } from '../../Nav/TabNavbar'
import StatisticsPane from './StatisticsPane'
import MakersPane from '../Common/MakersPane'
import TopCitiesPane from './TopCitiesPane'
import useMapLayer from '../../../hooks/useMapLayer'

const IotInfoBox = () => {
const { setMapLayer } = useMapLayer()

useEffect(() => {
setMapLayer('default')
}, [setMapLayer])

return (
<InfoBox title="IOT (Coming Soon)" metaTitle="IOT">
<TabNavbar htmlTitleRoot="IOT">
<TabPane title="Statistics" key="statistics">
<StatisticsPane />
</TabPane>
<TabPane title="Makers" key="makers" path="makers">
<MakersPane />
</TabPane>
<TabPane title="Cities" key="latest" path="cities">
<TopCitiesPane />
</TabPane>
</TabNavbar>
</InfoBox>
)
}

export default IotInfoBox
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import useApi from '../../../hooks/useApi'
import InfoBoxPaneContainer from '../Common/InfoBoxPaneContainer'
import Widget from '../../Widgets/Widget'
import { maxBy, last } from 'lodash'
import { useDataCredits } from '../../../data/datacredits'
import LargeBalance from '../../Common/LargeBalance'

const StatisticsPane = () => {
const { data: stats } = useApi('/metrics/hotspots')
const { data: makers } = useApi('/makers')
const { latestHotspots } = useLatestHotspots()
const { dataCredits } = useDataCredits()

const latestHotspot = useMemo(() => {
if (!latestHotspots) return null
Expand Down Expand Up @@ -41,6 +44,16 @@ const StatisticsPane = () => {
series={stats?.dataOnlyCount}
isLoading={!stats}
/>
<Widget
title="Packets Sent (24h)"
value={<LargeBalance value={dataCredits?.lastDay?.stateChannel} />}
isLoading={!dataCredits}
/>
<Widget
title="Packets Sent (30d)"
value={<LargeBalance value={dataCredits?.lastMonth?.stateChannel} />}
isLoading={!dataCredits}
/>
<StatWidget
title="% Online"
series={stats?.onlinePct}
Expand All @@ -53,7 +66,7 @@ const StatisticsPane = () => {
value={makers?.length}
subtitle={`Latest: ${maxBy(makers, 'id')?.name}`}
isLoading={!makers}
linkTo="/hotspots/makers"
linkTo="/iot/makers"
/>
<StatWidget
title="Cities"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const TopCitiesPane = () => {

const keyExtractor = useCallback((city) => city.cityId, [])

const linkExtractor = useCallback(
(city) => `/hotspots/cities/${city.cityId}`,
[],
)
const linkExtractor = useCallback((city) => `/iot/cities/${city.cityId}`, [])

const renderItem = useCallback((city) => {
const cityTitle = city?.longCity ? city.longCity : city.longState
Expand Down
30 changes: 26 additions & 4 deletions components/InfoBox/MarketInfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,38 @@ const MarketInfoBox = () => {
isLoading={!oraclePrices}
/>
<Widget
title="Market Price"
tooltip={<span>Based on data provided by <a target="_blank" rel="noreferrer" href="https://www.coingecko.com/en/coins/helium">CoinGecko</a></span>}
title="HNT Market Price"
tooltip={
<span>
Based on data provided by{' '}
<a
target="_blank"
rel="noreferrer"
href="https://www.coingecko.com/en/coins/helium"
>
CoinGecko
</a>
</span>
}
value={<Currency value={market?.price} />}
change={round(market?.priceChange, 2)}
changeSuffix="%"
isLoading={!market}
/>
<Widget
title="Market Cap"
tooltip={<span>Based on data provided by <a target="_blank" rel="noreferrer" href="https://www.coingecko.com/en/coins/helium">CoinGecko</a></span>}
title="HNT Market Cap"
tooltip={
<span>
Based on data provided by{' '}
<a
target="_blank"
rel="noreferrer"
href="https://www.coingecko.com/en/coins/helium"
>
CoinGecko
</a>
</span>
}
value={
<Currency
value={market?.price * stats?.circulatingSupply}
Expand Down
29 changes: 29 additions & 0 deletions components/InfoBox/Mobile/MobileInfoBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useEffect } from 'react'
import InfoBox from '../InfoBox'
import TabNavbar, { TabPane } from '../../Nav/TabNavbar'
import StatisticsPane from './StatisticsPane'
import useMapLayer from '../../../hooks/useMapLayer'
import MakersPane from '../Common/MakersPane'

const MobileInfoBox = () => {
const { setMapLayer } = useMapLayer()

useEffect(() => {
setMapLayer('cbrs')
}, [setMapLayer])

return (
<InfoBox title="MOBILE" metaTitle="MOBILE">
<TabNavbar htmlTitleRoot="MOBILE">
<TabPane title="Statistics" key="statistics">
<StatisticsPane />
</TabPane>
<TabPane title="Makers" key="makers" path="makers">
<MakersPane type="5g" />
</TabPane>
</TabNavbar>
</InfoBox>
)
}

export default MobileInfoBox
36 changes: 36 additions & 0 deletions components/InfoBox/Mobile/StatisticsPane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import TrendWidget from '../../Widgets/TrendWidget'
import useApi from '../../../hooks/useApi'
import InfoBoxPaneContainer from '../Common/InfoBoxPaneContainer'
import StatWidget from '../../Widgets/StatWidget'

const StatisticsPane = () => {
const { data: stats } = useApi('/metrics/cells')

return (
<InfoBoxPaneContainer>
<TrendWidget title="5G Radios" series={stats?.count} isLoading={!stats} />
<StatWidget
title="Indoor Radios"
series={stats?.indoorCount}
isLoading={!stats}
/>
<StatWidget
title="Outdoor Radios"
series={stats?.outdoorCount}
isLoading={!stats}
/>
<StatWidget
title="Cities"
series={stats?.citiesCount}
isLoading={!stats}
/>
<StatWidget
title="States"
series={stats?.statesCount}
isLoading={!stats}
/>
</InfoBoxPaneContainer>
)
}

export default StatisticsPane
Loading

0 comments on commit e0a70af

Please sign in to comment.