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
1130e1c2
Commit
1130e1c2
authored
Jan 13, 2023
by
Yuri Mikhin
Committed by
Yuri Mikhin
Jan 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remake counters API integration.
parent
77e0febf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
65 deletions
+12
-65
resources.ts
lib/api/resources.ts
+2
-2
stats.ts
types/api/stats.ts
+8
-14
NumberWidgetsList.tsx
ui/stats/NumberWidgetsList.tsx
+2
-10
number-widgets-scheme.ts
ui/stats/constants/number-widgets-scheme.ts
+0
-39
No files found.
lib/api/resources.ts
View file @
1130e1c2
...
...
@@ -22,7 +22,7 @@ import type { InternalTransactionsResponse } from 'types/api/internalTransaction
import
type
{
LogsResponseTx
,
LogsResponseAddress
}
from
'
types/api/log
'
;
import
type
{
RawTracesResponse
}
from
'
types/api/rawTrace
'
;
import
type
{
SearchResult
,
SearchResultFilters
}
from
'
types/api/search
'
;
import
type
{
Stat
s
,
Charts
,
HomeStats
}
from
'
types/api/stats
'
;
import
type
{
Counter
s
,
Charts
,
HomeStats
}
from
'
types/api/stats
'
;
import
type
{
TokenCounters
,
TokenInfo
,
TokenHolders
}
from
'
types/api/tokenInfo
'
;
import
type
{
TokenTransferResponse
,
TokenTransferFilters
}
from
'
types/api/tokenTransfer
'
;
import
type
{
TransactionsResponseValidated
,
TransactionsResponsePending
,
Transaction
}
from
'
types/api/transaction
'
;
...
...
@@ -292,7 +292,7 @@ Q extends 'homepage_chart_market' ? ChartMarketResponse :
Q
extends
'
homepage_blocks
'
?
Array
<
Block
>
:
Q
extends
'
homepage_txs
'
?
Array
<
Transaction
>
:
Q
extends
'
homepage_indexing_status
'
?
IndexingStatus
:
Q
extends
'
stats_counters
'
?
Stat
s
:
Q
extends
'
stats_counters
'
?
Counter
s
:
Q
extends
'
stats_charts
'
?
Charts
:
Q
extends
'
blocks
'
?
BlocksResponse
:
Q
extends
'
block
'
?
Block
:
...
...
types/api/stats.ts
View file @
1130e1c2
...
...
@@ -19,21 +19,15 @@ export type GasPrices = {
slow
:
number
;
}
export
type
Stats
=
{
counters
:
{
totalBlocks
:
string
;
averageBlockTime
:
string
;
totalTransactions
:
string
;
completedTransactions
:
string
;
totalAccounts
:
string
;
totalTokens
:
string
;
export
type
Counters
=
{
counters
:
Array
<
Counter
>
;
}
totalNativeCoinHolders
:
string
;
totalNativeCoinTransfers
:
string
;
};
type
Counter
=
{
id
:
string
;
value
:
string
;
title
:
string
;
units
:
string
;
}
export
type
Charts
=
{
...
...
ui/stats/NumberWidgetsList.tsx
View file @
1130e1c2
...
...
@@ -4,7 +4,6 @@ import React from 'react';
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
formatNumberToMetricPrefix
from
'
lib/formatNumberToMetricPrefix
'
;
import
{
numberWidgetsScheme
}
from
'
./constants/number-widgets-scheme
'
;
import
NumberWidget
from
'
./NumberWidget
'
;
import
NumberWidgetSkeleton
from
'
./NumberWidgetSkeleton
'
;
...
...
@@ -22,20 +21,13 @@ const NumberWidgetsList = () => {
gridGap=
{
4
}
>
{
isLoading
?
skeletonElement
:
numberWidgetsScheme
.
map
(({
id
,
title
,
formatFn
})
=>
{
if
(
!
data
?.
counters
[
id
])
{
return
null
;
}
const
value
=
formatNumberToMetricPrefix
(
Number
(
data
.
counters
[
id
]));
data
?.
counters
?.
map
(({
id
,
title
,
value
,
units
})
=>
{
return
(
<
NumberWidget
key=
{
id
}
label=
{
title
}
value=
{
formatFn
?
formatFn
(
value
)
:
value
}
value=
{
`${ formatNumberToMetricPrefix(Number(value)) } ${ units }`
}
/>
);
})
}
...
...
ui/stats/constants/number-widgets-scheme.ts
deleted
100644 → 0
View file @
77e0febf
import
type
{
Stats
}
from
'
types/api/stats
'
;
type
Key
=
keyof
Stats
[
'
counters
'
];
export
const
numberWidgetsScheme
:
Array
<
{
id
:
Key
;
title
:
string
;
formatFn
?:
(
n
:
string
)
=>
string
}
>
=
[
{
id
:
'
totalBlocks
'
,
title
:
'
Total blocks
'
,
},
{
id
:
'
averageBlockTime
'
,
title
:
'
Average block time
'
,
formatFn
:
(
n
)
=>
`
${
n
}
s`
,
},
{
id
:
'
totalTransactions
'
,
title
:
'
Total transactions
'
,
},
{
id
:
'
completedTransactions
'
,
title
:
'
Completed transactions
'
,
},
{
id
:
'
totalAccounts
'
,
title
:
'
Total accounts
'
,
},
{
id
:
'
totalTokens
'
,
title
:
'
Total tokens
'
,
},
{
id
:
'
totalNativeCoinHolders
'
,
title
:
'
Total native coin holders
'
,
},
{
id
:
'
totalNativeCoinTransfers
'
,
title
:
'
Total native coin transfers
'
,
},
];
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