Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
d4819cc2
Commit
d4819cc2
authored
Nov 24, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network utilization and clean up
parent
653bc4a5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
20 deletions
+20
-20
stats.ts
pages/api/index/stats.ts
+0
-7
index.ts
pages/api/stats/index.ts
+0
-1
stats.ts
types/api/stats.ts
+1
-0
LatestBlocks.tsx
ui/home/LatestBlocks.tsx
+17
-10
LatestTxs.tsx
ui/home/LatestTxs.tsx
+1
-1
Stats.tsx
ui/home/Stats.tsx
+1
-1
No files found.
pages/api/index/stats.ts
deleted
100644 → 0
View file @
653bc4a5
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
()
=>
'
/v2/stats
'
;
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
export
default
requestHandler
;
pages/api/stats/index.ts
View file @
d4819cc2
// todo_tom leave only one api endpoint
import
handler
from
'
lib/api/handler
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
()
=>
'
/v2/stats
'
;
const
getUrl
=
()
=>
'
/v2/stats
'
;
...
...
types/api/stats.ts
View file @
d4819cc2
...
@@ -10,4 +10,5 @@ export type Stats = {
...
@@ -10,4 +10,5 @@ export type Stats = {
gas_prices
:
{
average
:
number
;
fast
:
number
;
slow
:
number
};
gas_prices
:
{
average
:
number
;
fast
:
number
;
slow
:
number
};
static_gas_price
:
string
;
static_gas_price
:
string
;
market_cap
:
string
;
market_cap
:
string
;
network_utilization_percentage
:
number
;
}
}
ui/home/LatestBlocks.tsx
View file @
d4819cc2
...
@@ -5,6 +5,7 @@ import React from 'react';
...
@@ -5,6 +5,7 @@ import React from 'react';
import
type
{
SocketMessage
}
from
'
lib/socket/types
'
;
import
type
{
SocketMessage
}
from
'
lib/socket/types
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
import
type
{
Stats
}
from
'
types/api/stats
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
...
@@ -26,10 +27,14 @@ const LatestBlocks = () => {
...
@@ -26,10 +27,14 @@ const LatestBlocks = () => {
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Block
>>
(
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Block
>>
(
[
QueryKeys
.
indexBlocks
],
[
QueryKeys
.
indexBlocks
],
async
()
=>
await
fetch
(
`/api/index/blocks`
),
async
()
=>
await
fetch
(
`/
node-
api/index/blocks`
),
);
);
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
const
statsQueryResult
=
useQuery
<
unknown
,
unknown
,
Stats
>
(
[
QueryKeys
.
stats
],
()
=>
fetch
(
'
/node-api/stats
'
),
);
const
handleNewBlockMessage
:
SocketMessage
.
NewBlock
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
const
handleNewBlockMessage
:
SocketMessage
.
NewBlock
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
queryClient
.
setQueryData
([
QueryKeys
.
indexBlocks
],
(
prevData
:
Array
<
Block
>
|
undefined
)
=>
{
queryClient
.
setQueryData
([
QueryKeys
.
indexBlocks
],
(
prevData
:
Array
<
Block
>
|
undefined
)
=>
{
...
@@ -78,15 +83,17 @@ const LatestBlocks = () => {
...
@@ -78,15 +83,17 @@ const LatestBlocks = () => {
content
=
(
content
=
(
<>
<>
<
Box
mb=
{
{
base
:
6
,
lg
:
9
}
}
>
{
statsQueryResult
.
data
?.
network_utilization_percentage
&&
(
<
Text
as=
"span"
fontSize=
"sm"
>
<
Box
mb=
{
{
base
:
6
,
lg
:
9
}
}
>
Network utilization:
{
nbsp
}
<
Text
as=
"span"
fontSize=
"sm"
>
</
Text
>
Network utilization:
{
nbsp
}
{
/* Not implemented in API yet */
}
</
Text
>
<
Text
as=
"span"
fontSize=
"sm"
color=
"blue.400"
fontWeight=
{
700
}
>
{
/* Not implemented in API yet */
}
43.8%
<
Text
as=
"span"
fontSize=
"sm"
color=
"blue.400"
fontWeight=
{
700
}
>
</
Text
>
{
statsQueryResult
.
data
.
network_utilization_percentage
.
toFixed
(
2
)
}
%
</
Box
>
</
Text
>
</
Box
>
)
}
<
VStack
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksCount + BLOCK_MARGIN * (blocksCount - 1) }px`
}
overflow=
"hidden"
>
<
VStack
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksCount + BLOCK_MARGIN * (blocksCount - 1) }px`
}
overflow=
"hidden"
>
<
AnimatePresence
initial=
{
false
}
>
<
AnimatePresence
initial=
{
false
}
>
{
dataToShow
.
map
((
block
=>
<
LatestBlocksItem
key=
{
block
.
height
}
block=
{
block
}
h=
{
BLOCK_HEIGHT
}
/>))
}
{
dataToShow
.
map
((
block
=>
<
LatestBlocksItem
key=
{
block
.
height
}
block=
{
block
}
h=
{
BLOCK_HEIGHT
}
/>))
}
...
...
ui/home/LatestTxs.tsx
View file @
d4819cc2
...
@@ -19,7 +19,7 @@ const LatestTransactions = () => {
...
@@ -19,7 +19,7 @@ const LatestTransactions = () => {
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Transaction
>>
(
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Transaction
>>
(
[
QueryKeys
.
indexTxs
],
[
QueryKeys
.
indexTxs
],
async
()
=>
await
fetch
(
`/api/index/txs`
),
async
()
=>
await
fetch
(
`/
node-
api/index/txs`
),
);
);
let
content
;
let
content
;
...
...
ui/home/Stats.tsx
View file @
d4819cc2
...
@@ -28,7 +28,7 @@ const Stats = () => {
...
@@ -28,7 +28,7 @@ const Stats = () => {
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Stats
>
(
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Stats
>
(
[
QueryKeys
.
stats
],
[
QueryKeys
.
stats
],
async
()
=>
await
fetch
(
`/
api/index
/stats`
),
async
()
=>
await
fetch
(
`/
node-api
/stats`
),
);
);
if
(
isError
)
{
if
(
isError
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment