Skip to content

Commit

Permalink
feat(webapp): add internationalization for endpoints stats view
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Mar 20, 2023
1 parent bff30f6 commit b61ba39
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 58 deletions.
58 changes: 42 additions & 16 deletions webapp/src/hooks/customHooks/useHealthCheckHistoryState.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useHealthCheckState = () => {
const [selected, setSelected] = useState()
const [historyData, setHistoryData] = useState()
const [statsAverage, setStatsAverage] = useState()
const [dates, setDates] = useState()

useEffect(() => {
const endpointFilter = {
Expand All @@ -37,7 +38,7 @@ const useHealthCheckState = () => {
},
})
loadEndpoints({ variables: { today: new Date() } })
}, [])
}, [loadProducers, loadEndpoints])

useEffect(() => {
if (!producers?.length) return
Expand All @@ -52,31 +53,56 @@ const useHealthCheckState = () => {
}, [producers])

useEffect(() => {
if (!selected) return

loadHistory({ variables: { id: selected } })
}, [selected])
}, [loadHistory, selected])

useEffect(() => {
if (!history) return

const data = history.reduce((aux, curr) => {
const index = aux.findIndex((x) => x.name === curr.value)
if (index < 0) {
aux.push({ name: curr.value, data: [curr.avg_time],avg_time:curr.avg_time, availability: curr.availability})
} else {
aux[index].data.push(curr.avg_time)
aux[index].availability = aux[index].availability + curr.availability
aux[index].avg_time = aux[index].avg_time + curr.avg_time
}

return aux
}, [])
const index = aux.findIndex(x => x.name === curr.value)
if (index < 0) {
aux.push({
name: curr.value,
data: [curr.avg_time],
dates: [curr.date],
avg_time: curr.avg_time,
availability: curr.availability,
})
} else {
aux[index].data.push(curr.avg_time)
aux[index].availability = aux[index].availability + curr.availability
aux[index].avg_time = aux[index].avg_time + curr.avg_time
aux[index].dates.push(curr.date)
}

return aux
}, [])
setDates(data[0]?.dates || [])
setHistoryData(data)
setStatsAverage(data.map(x=>({value:x.name,avg_time:x.avg_time/x.data.length,availability:x.availability/x.data.length})))

setStatsAverage(
data.map(x => ({
value: x.name,
avg_time: x.avg_time / x.data.length,
availability: x.availability / x.data.length,
})),
)
}, [history])

return [
{ fastestEndpoints, producersNames, historyData, statsAverage, selected, loading },
{
fastestEndpoints,
producersNames,
historyData,
statsAverage,
selected,
dates,
loading,
loadingHistory,
loadingProducers
},
{ setSelected },
]
}
Expand Down
11 changes: 11 additions & 0 deletions webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
"/endpoints>sidebar": "API Endpoints",
"/endpoints>title": "API Endpoints - EOSIO + Antelope Network Dashboard",
"/endpoints>heading": "API Endpoints",
"/endpoints-stats>sidebar": "API Endpoints Stats",
"/endpoints-stats>title": "API Endpoints Stats- EOSIO + Antelope Network Dashboard",
"/endpoints-stats>heading": "API Endpoints Stats",
"/about>sidebar": "About",
"/about>title": "About - EOSIO + Antelope Network Dashboard",
"/about>heading": "About",
Expand Down Expand Up @@ -385,5 +388,13 @@
},
"mainMapComponent": {
"numberOfNodes": "Number of Nodes"
},
"EndpointsStatsRoute": {
"fastest": "Top 5 fastest endpoints by querying from Costa Rica",
"byProducer": "Endpoints stats by producer",
"avgAvailability": "Average Availability",
"avgTime": "Average Response Time",
"list": "List of endpoints",
"timeInSecs": "Time in seconds"
}
}
2 changes: 2 additions & 0 deletions webapp/src/language/en.jungle.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Jungle4 Testnet Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Jungle4 Testnet Network Dashboard",
"/endpoints>title": "API Endpoints - Jungle4 Testnet Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats - Jungle4 Testnet Network Dashboard",
"/about>title": "About - Jungle4 Testnet Network Dashboard",
"/help>title": "Help - Jungle4 Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -25,6 +26,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.lacchain.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"/nodes>title": "LACChain EOSIO Nodes Status Monitor",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>title": "Geographic Distribution of Nodes - LACChain EOSIO + Antelope Network Dashboard",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>title": "Accounts and Contracts - LACChain EOSIO + Antelope Network Dashboard",
Expand All @@ -40,6 +41,7 @@
"/missed-blocks>title": "Missed Blocks - LACChain EOSIO + Antelope Network Dashboard",
"/missed-blocks>moreDescription": "A list of scheduled, produced, and missed blocks by each account in the network.",
"/endpoints>title": "API Endpoints - LACChain EOSIO + Antelope Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- LACChain EOSIO + Antelope Network Dashboard",
"/about>title": "About - LACChain EOSIO + Antelope Network Dashboard",
"/help>title": "Help - LACChain EOSIO + Antelope Network Dashboard"
},
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.libre-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Libre Testnet Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Libre Testnet Network Dashboard",
"/endpoints>title": "API Endpoints - Libre Testnet Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- Libre Testnet Network Dashboard",
"/about>title": "About - Libre Testnet Network Dashboard",
"/help>title": "Help - Libre Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -26,6 +27,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.libre.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Libre Mainnet Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Libre Mainnet Network Dashboard",
"/endpoints>title": "API Endpoints - Libre Mainnet Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- Libre Mainnet Network Dashboard",
"/about>title": "About - Libre Mainnet Network Dashboard",
"/help>title": "Help - Libre Mainnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -26,6 +27,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"/block-distribution>title": "Block Production Distribution - EOS Network Monitor",
"/missed-blocks>title": "Missed Blocks - EOS Network Monitor",
"/endpoints>title": "API Endpoints - EOS Network Monitor",
"/endpoints-stats>title": "API Endpoints Stats- EOS Network Monitor",
"/about>title": "About - EOS Network Monitor",
"/help>title": "Help - EOS Network Monitor",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -24,6 +25,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.proton-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Proton Testnet Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Proton Testnet Network Dashboard",
"/endpoints>title": "API Endpoints - Proton Testnet Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- Proton Testnet Network Dashboard",
"/about>title": "About - Proton Testnet Network Dashboard",
"/help>title": "Help - Proton Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -25,6 +26,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.proton.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Proton Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Proton Network Dashboard",
"/endpoints>title": "API Endpoints - Proton Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- Proton Network Dashboard",
"/about>title": "About - Proton Network Dashboard",
"/help>title": "Help - Proton Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -25,6 +26,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.telos-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Telos Testnet Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Telos Testnet Network Dashboard",
"/endpoints>title": "API Endpoints - Telos Testnet Network Dashboard",
"/endpoints-Stats>title": "API Endpoints Stats- Telos Testnet Network Dashboard",
"/about>title": "About - Telos Testnet Network Dashboard",
"/help>title": "Help - Telos Testnet Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -25,6 +26,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.telos.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/block-distribution>title": "Block Production Distribution - Telos Network Dashboard",
"/missed-blocks>title": "Missed Blocks - Telos Network Dashboard",
"/endpoints>title": "API Endpoints - Telos Network Dashboard",
"/endpoints-stats>title": "API Endpoints Stats- Telos Network Dashboard",
"/about>title": "About - Telos Network Dashboard",
"/help>title": "Help - Telos Network Dashboard",
"/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.",
Expand All @@ -25,6 +26,7 @@
"/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.",
"/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.",
"/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.",
"/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.",
"/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.",
"/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.",
"/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.",
Expand Down
Loading

0 comments on commit b61ba39

Please sign in to comment.