Skip to content

Commit

Permalink
adapt FE to latest api (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauserBitfly authored Mar 13, 2024
1 parent ab1f3b9 commit 211fc2b
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 137 deletions.
28 changes: 14 additions & 14 deletions frontend/components/dashboard/ValidatorOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ const dataList = computed(() => {
]
efficiency.value = { label: formatPercent(v.efficiency.total) }
rewards.value = converter.value.weiToValue(totalElCl(v.rewards.total), { addPlus: true })
rewards.value = converter.value.weiToValue(totalElCl(v.rewards.all_time), { addPlus: true })
const statsLabels = [
{ label: `(${$t('statistics.day')})` },
{ label: `(${$t('statistics.week')})` },
{ label: `(${$t('statistics.month')})` },
{ label: `(${$t('statistics.year')})` }
{ label: `(${$t('statistics.last_24h')})` },
{ label: `(${$t('statistics.last_7d')})` },
{ label: `(${$t('statistics.last_31d')})` },
{ label: `(${$t('statistics.last_365d')})` }
]
rewards.additonalValues = [
[
converter.value.weiToValue(totalElCl(v.rewards.day), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.week), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.month), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.year), { addPlus: true })
converter.value.weiToValue(totalElCl(v.rewards.last_24h), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.last_7d), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.last_31d), { addPlus: true }),
converter.value.weiToValue(totalElCl(v.rewards.last_365d), { addPlus: true })
], statsLabels
]
Expand All @@ -86,13 +86,13 @@ const dataList = computed(() => {
{ label: $t(`${tPath}sync_committee_luck`) }
]
]
apr.value = { label: formatPercent(totalElClNumbers(v.apr.total)) }
apr.value = { label: formatPercent(totalElClNumbers(v.apr.all_time)) }
apr.additonalValues = [
[
{ label: formatPercent(totalElClNumbers(v.apr.day)) },
{ label: formatPercent(totalElClNumbers(v.apr.week)) },
{ label: formatPercent(totalElClNumbers(v.apr.month)) },
{ label: formatPercent(totalElClNumbers(v.apr.year)) }
{ label: formatPercent(totalElClNumbers(v.apr.last_24h)) },
{ label: formatPercent(totalElClNumbers(v.apr.last_7d)) },
{ label: formatPercent(totalElClNumbers(v.apr.last_31d)) },
{ label: formatPercent(totalElClNumbers(v.apr.last_365d)) }
], statsLabels
]
return list
Expand Down
14 changes: 7 additions & 7 deletions frontend/components/dashboard/ValidatorSubsetModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ const caption = computed(() => {
}
switch (props.timeFrame) {
case 'details_day':
return text + ' ' + $t('statistics.day')
case 'details_week':
return text + ' ' + $t('statistics.week')
case 'details_month':
return text + ' ' + $t('statistics.month')
case 'details_total':
case 'last_24h':
return text + ' ' + $t('statistics.last_24h')
case 'last_7d':
return text + ' ' + $t('statistics.last_7d')
case 'last_31d':
return text + ' ' + $t('statistics.last_31d')
case 'all_time':
return text + ' ' + $t('statistics.all')
}
return text
Expand Down
24 changes: 12 additions & 12 deletions frontend/components/dashboard/table/DashboardTableSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,42 +133,42 @@ const getRowClass = (row: VDBSummaryTableRow) => {
</template>
</Column>
<Column
field="efficiency_day"
field="efficiency_last_24h"
:sortable="true"
:header="$t('dashboard.validator.summary.col.efficiency_day')"
:header="$t('dashboard.validator.summary.col.efficiency_last_24h')"
>
<template #body="slotProps">
<BcFormatPercent :percent="slotProps.data.efficiency_day" :color-break-point="80" />
<BcFormatPercent :percent="slotProps.data.efficiency_last_24h" :color-break-point="80" />
</template>
</Column>
<Column
v-if="colsVisible.efficiency_plus"
field="efficiency_week"
field="efficiency_last_7d"
:sortable="true"
:header="$t('dashboard.validator.summary.col.efficiency_week')"
:header="$t('dashboard.validator.summary.col.efficiency_last_7d')"
>
<template #body="slotProps">
<BcFormatPercent :percent="slotProps.data.efficiency_week" :color-break-point="80" />
<BcFormatPercent :percent="slotProps.data.efficiency_last_7d" :color-break-point="80" />
</template>
</Column>
<Column
v-if="colsVisible.efficiency_plus"
field="efficiency_month"
field="efficiency_last_31d"
:sortable="true"
:header="$t('dashboard.validator.summary.col.efficiency_month')"
:header="$t('dashboard.validator.summary.col.efficiency_last_31d')"
>
<template #body="slotProps">
<BcFormatPercent :percent="slotProps.data.efficiency_month" :color-break-point="80" />
<BcFormatPercent :percent="slotProps.data.efficiency_last_31d" :color-break-point="80" />
</template>
</Column>
<Column
v-if="colsVisible.efficiency_plus"
field="efficiency_total"
field="efficiency_all_time"
:sortable="true"
:header="$t('dashboard.validator.summary.col.efficiency_total')"
:header="$t('dashboard.validator.summary.col.efficiency_all_time')"
>
<template #body="slotProps">
<BcFormatPercent :percent="slotProps.data.efficiency_total" :color-break-point="80" />
<BcFormatPercent :percent="slotProps.data.efficiency_all_time" :color-break-point="80" />
</template>
</Column>
<Column
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/dashboard/table/SummaryDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const data = computed<SummaryRow[][]>(() => {
}
if (!row) {
let title = $t(`dashboard.validator.summary.row.${prop}`)
if (prop === 'efficiency_total') {
if (prop === 'efficiency_all_time') {
title = `${title} (${$t(`statistics.${detail.split('_')[1]}`)})`
}
row = { title, prop, details: [] }
Expand All @@ -44,7 +44,7 @@ const data = computed<SummaryRow[][]>(() => {
row?.details.push(detail)
}
const props: SummaryDetailsEfficiencyCombinedProp[] = ['efficiency_total', 'attestation_total', 'attestation_head', 'attestation_source', 'attestation_target', 'attestation_efficiency', 'attestation_avg_incl_dist', 'sync', 'validators_sync', 'proposals', 'validators_proposal', 'slashed', 'validators_slashings', 'apr', 'luck']
const props: SummaryDetailsEfficiencyCombinedProp[] = ['efficiency_all_time', 'attestation_total', 'attestations_head', 'attestations_source', 'attestations_target', 'attestation_efficiency', 'attestation_avg_incl_dist', 'sync', 'validators_sync', 'proposals', 'validators_proposal', 'slashed', 'validators_slashings', 'apr', 'luck']
SummaryDetails.forEach((detail, index) => {
props.forEach((prop, propIndex) => {
if (!isWideEnough.value || propIndex) {
Expand All @@ -58,14 +58,14 @@ const data = computed<SummaryRow[][]>(() => {
const rowClass = (data:SummaryRow) => {
const classNames: Partial<Record<SummaryDetailsEfficiencyCombinedProp, string>> = {
efficiency_total: 'bold',
efficiency_all_time: 'bold',
attestation_total: 'bold',
sync: 'bold spacing-top',
proposals: 'bold spacing-top',
slashed: 'bold spacing-top',
apr: 'bold',
luck: 'bold spacing-top',
attestation_head: 'spacing-top'
attestations_head: 'spacing-top'
}
return classNames[data.prop]
}
Expand Down
23 changes: 10 additions & 13 deletions frontend/components/dashboard/table/SummaryValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ const data = computed(() => {
if (props.property === 'attestation_total') {
return {
efficiency: {
status_count: {
success: col.attestation_head.status_count.success + col.attestation_source.status_count.success + col.attestation_target.status_count.success,
failed: col.attestation_head.status_count.failed + col.attestation_source.status_count.failed + col.attestation_target.status_count.failed
}
status_count: col.attestation_count
}
}
} else if (SummaryDetailsEfficiencyProps.includes(props.property as SummaryDetailsEfficiencyProp)) {
Expand All @@ -54,7 +51,7 @@ const data = computed(() => {
let validators: number[] = []
let context: DashboardValidatorContext = 'attestation'
if (props.property === 'validators_attestation') {
validators = union(col.attestation_head.validators, col.attestation_source.validators, col.attestation_target.validators)
validators = union(col.attestations_head.validators, col.attestations_source.validators, col.attestations_target.validators)
} else if (props.property === 'validators_proposal') {
validators = col.proposals.validators ?? []
context = 'proposal'
Expand Down Expand Up @@ -87,17 +84,17 @@ const data = computed(() => {
return {
luck: col.luck
}
} else if (props.property === 'efficiency_total') {
let efficiencyTotal = props.row.efficiency_day
} else if (props.property === 'efficiency_all_time') {
let efficiencyTotal = props.row.efficiency_last_24h
switch (props.detail) {
case 'details_month':
efficiencyTotal = props.row.efficiency_month
case 'last_31d':
efficiencyTotal = props.row.efficiency_last_31d
break
case 'details_week':
efficiencyTotal = props.row.efficiency_week
case 'last_7d':
efficiencyTotal = props.row.efficiency_last_7d
break
case 'details_total':
efficiencyTotal = props.row.efficiency_total
case 'all_time':
efficiencyTotal = props.row.efficiency_all_time
break
}
return {
Expand Down
24 changes: 12 additions & 12 deletions frontend/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"scheduled": "Scheduled"
},
"statistics": {
"day": "24h",
"week": "7d",
"month": "31d",
"year": "365d",
"last_24h": "24h",
"last_7d": "7d",
"last_31d": "31d",
"last_365d": "365d",
"total": "All Time",
"all": "All Time"
},
Expand Down Expand Up @@ -141,19 +141,19 @@
"search_placeholder": "Index, Public Key, Group",
"col": {
"group": "Group",
"efficiency_day": "Efficiency (24h)",
"efficiency_week": "Efficiency (7d)",
"efficiency_month": "Efficiency (31d)",
"efficiency_total": "Efficiency (All Time)",
"efficiency_last_24h": "Efficiency (24h)",
"efficiency_last_7d": "Efficiency (7d)",
"efficiency_last_31d": "Efficiency (31d)",
"efficiency_all_time": "Efficiency (All Time)",
"validators": "Validators"
},
"row": {
"efficiency_total": "Efficiency",
"efficiency_all_time": "Efficiency",
"attestations": "Attestations",
"attestation_total": "Total Attestations",
"attestation_head": "Head",
"attestation_source": "Source",
"attestation_target": "Target",
"attestations_head": "Head",
"attestations_source": "Source",
"attestations_target": "Target",
"attestation_efficiency": "Att. Efficiency",
"attestation_avg_incl_dist": "Avg. Incl. Distance",
"sync": "Sync Committee",
Expand Down
29 changes: 14 additions & 15 deletions frontend/public/mock/dashboard/overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@
"exited": 4
},
"efficiency": {
"total": 11.1234,
"day": 31.1234,
"week": 41.1234,
"month": 51.1234,
"year": 81.1234
"total": 11.12304,
"attestation": 31.1234,
"proposal": 41,
"sync": 51.1234
},
"rewards": {
"total": { "cl": "1456748000000000000", "el": "1456748000000000000" },
"day": { "cl": "56748000000000000", "el": "56748000000000000" },
"week": { "cl": "456748000000000000", "el": "456748000000000000" },
"month": { "cl": "1056748000000000000", "el": "1056748000000000000" },
"year": { "cl": "1456748000000000000", "el": "1456748000000000000" }
"all_time": { "cl": "1456748000000000000", "el": "1456748000000000000" },
"last_24h": { "cl": "56748000000000000", "el": "56748000000000000" },
"last_7d": { "cl": "456748000000000000", "el": "456748000000000000" },
"last_31d": { "cl": "1056748000000000000", "el": "1056748000000000000" },
"last_365d": { "cl": "1456748000000000000", "el": "1456748000000000000" }
},
"luck": {
"proposal": {
Expand All @@ -68,11 +67,11 @@
}
},
"apr": {
"total": {"el":2.45, "cl": 1.45},
"day": {"el":3.45, "cl": 21.45},
"week": {"el":12.45, "cl": 31.45},
"month": {"el":22.45, "cl": 51.45},
"year": {"el":52.45, "cl": 61.45}
"all_time": {"el":2.45, "cl": 1.45},
"last_24h": {"el":3.45, "cl": 21.45},
"last_7d": {"el":12.45, "cl": 31.45},
"last_31d": {"el":22.45, "cl": 51.45},
"last_365d": {"el":52.45, "cl": 61.45}
}
}
}
64 changes: 32 additions & 32 deletions frontend/public/mock/dashboard/validatorSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,66 @@
"data": [
{
"group_id": -1,
"efficiency_day": 81.02,
"efficiency_week": 82.52,
"efficiency_month": 82.28,
"efficiency_total": 92.06,
"efficiency_last_24h": 81.02,
"efficiency_last_7d": 82.52,
"efficiency_last_31d": 82.28,
"efficiency_all_time": 92.06,
"validators":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,101,102,103,104,105,106,107,108,109,110,123,456,653,789,1024,1234,2048,5678,7253,29533,124584,212455,324323,459393,462852,501249,515359,525356,530363,538953,553539,642533,875390,875391,875392,875393,875394,875395,875396,875397,875398,875399,875400,875401,875402,875403,91234]
},
{
"group_id": 0,
"efficiency_day": 100,
"efficiency_week": 100,
"efficiency_month": 100,
"efficiency_total": 100,
"efficiency_last_24h": 100,
"efficiency_last_7d": 100,
"efficiency_last_31d": 100,
"efficiency_all_time": 100,
"validators": [1, 123, 456, 789, 1234, 5678, 91234]
},
{
"group_id": 1,
"efficiency_day": 80.13,
"efficiency_week": 85.42,
"efficiency_month": 85.61,
"efficiency_total": 86.24,
"efficiency_last_24h": 80.13,
"efficiency_last_7d": 85.42,
"efficiency_last_31d": 85.61,
"efficiency_all_time": 86.24,
"validators": [124584, 324323, 459393, 462852, 501249, 515359, 525356, 553539]
},
{
"group_id": 2,
"efficiency_day": 75.001,
"efficiency_week": 82.53,
"efficiency_month": 81.96,
"efficiency_total": 79.33,
"efficiency_last_24h": 75.001,
"efficiency_last_7d": 82.53,
"efficiency_last_31d": 81.96,
"efficiency_all_time": 79.33,
"validators": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
},
{
"group_id": 3,
"efficiency_day": 5.9,
"efficiency_week": 4.62,
"efficiency_month": 6.15,
"efficiency_total": 5.55,
"efficiency_last_24h": 5.9,
"efficiency_last_7d": 4.62,
"efficiency_last_31d": 6.15,
"efficiency_all_time": 5.55,
"validators": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]
},
{
"group_id": 4,
"efficiency_day": 98.15,
"efficiency_week": 99.41,
"efficiency_month": 98.62,
"efficiency_total": 98.00,
"efficiency_last_24h": 98.15,
"efficiency_last_7d": 99.41,
"efficiency_last_31d": 98.62,
"efficiency_all_time": 98.00,
"validators": [653, 7253, 29533, 212455, 530363, 538953, 642533]
},
{
"group_id": 5,
"efficiency_day": 50.00,
"efficiency_week": 50.00,
"efficiency_month": 50.00,
"efficiency_total": 50.00,
"efficiency_last_24h": 50.00,
"efficiency_last_7d": 50.00,
"efficiency_last_31d": 50.00,
"efficiency_all_time": 50.00,
"validators": [1024, 2048]
},
{
"group_id": 6,
"efficiency_day": 94.2,
"efficiency_week": 93.4,
"efficiency_month": 92.5,
"efficiency_total": 91.6,
"efficiency_last_24h": 94.2,
"efficiency_last_7d": 93.4,
"efficiency_last_31d": 92.5,
"efficiency_all_time": 91.6,
"validators": [875390, 875391, 875392, 875393, 875394, 875395, 875396, 875397, 875398, 875399, 875400, 875401, 875402, 875403]
}
]
Expand Down
Loading

0 comments on commit 211fc2b

Please sign in to comment.