-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validators list page validator card (#4419)
* add validator card * update storybook * lint fix * update colums * add linechart sample * sort validators list * fix storybook * fix validatorlist sort * fix sortedValidators * update type of Validator * update storybook * fix * lint fix * update interaction test, mocking * Revert "add linechart sample" This reverts commit 2e7f08b. * address merge conflicts * fetch rewardPointHistory * update validator card * fix * Add uptime in depth * fix uptime percent scale * address merge conflicts * fix * fix merge conflict, update asChainData helper --------- Co-authored-by: Theophile Sandoz <[email protected]>
- Loading branch information
1 parent
5d255ae
commit 4b9a450
Showing
14 changed files
with
710 additions
and
43 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
229 changes: 218 additions & 11 deletions
229
packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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
73 changes: 73 additions & 0 deletions
73
packages/ui/src/validators/components/RewardPointChart.tsx
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,73 @@ | ||
import { Chart } from 'chart.js/auto' | ||
import React from 'react' | ||
import { Line } from 'react-chartjs-2' | ||
|
||
import { RewardPoints } from '../types' | ||
|
||
Chart.register() | ||
|
||
interface Data { | ||
rewardPointsHistory: RewardPoints[] | ||
} | ||
|
||
type Mode = 'index' | 'dataset' | 'point' | 'nearest' | 'x' | 'y' | undefined | ||
|
||
const RewardPointChart = ({ rewardPointsHistory }: Data) => { | ||
const sortedRewardsHistory = rewardPointsHistory.sort((a, b) => a.era - b.era) | ||
const eras = sortedRewardsHistory.map((item) => item.era) | ||
const rewardPoints = sortedRewardsHistory.map((item) => item.rewardPoints) | ||
const averageRewardPoints = rewardPoints.reduce((a, b) => a + b, 0) / rewardPoints.length | ||
const averageLine = Array(eras.length).fill(averageRewardPoints) | ||
|
||
const data = { | ||
labels: eras, | ||
datasets: [ | ||
{ | ||
label: 'Era points', | ||
data: rewardPoints, | ||
fill: false, | ||
borderColor: 'blue', | ||
borderWidth: 2, | ||
tension: 0.2, | ||
pointRadius: 0, | ||
}, | ||
{ | ||
label: 'Average points', | ||
data: averageLine, | ||
fill: false, | ||
borderColor: 'black', | ||
borderWidth: 1, | ||
pointRadius: 0, | ||
}, | ||
], | ||
} | ||
|
||
const options = { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
plugins: { | ||
legend: { | ||
display: false, | ||
}, | ||
}, | ||
interaction: { | ||
intersect: false, | ||
mode: 'index' as Mode, | ||
}, | ||
scales: { | ||
x: { | ||
grid: { | ||
color: 'rgba(0, 0, 0, 0.05)', | ||
}, | ||
}, | ||
y: { | ||
grid: { | ||
color: 'rgba(0, 0, 0, 0.05)', | ||
}, | ||
}, | ||
}, | ||
} | ||
return <Line data={data} options={options} /> | ||
} | ||
|
||
export default RewardPointChart |
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
Oops, something went wrong.
4b9a450
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:
pioneer-2-storybook – ./
pioneer-2-storybook-git-dev-joystream.vercel.app
pioneer-2-storybook-joystream.vercel.app
pioneer-2-storybook.vercel.app
4b9a450
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:
pioneer-2 – ./
pioneer-2-git-dev-joystream.vercel.app
pioneer-2-joystream.vercel.app
pioneer-2.vercel.app