-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge blocks page redesign into develop (#517)
- Loading branch information
Showing
35 changed files
with
875 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\ForgingStats; | ||
use App\Services\BigNumber; | ||
use App\Services\Timestamp; | ||
use Carbon\Carbon; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
final class BlocksController | ||
{ | ||
public const STATS_TTL = 300; | ||
|
||
public function __invoke(): View | ||
{ | ||
$data = $this->blockData(); | ||
|
||
return view('app.blocks', [ | ||
'forgedCount' => $data['block_count'], | ||
'missedCount' => $data['missed_count'], | ||
'totalRewards' => BigNumber::new($data['total_rewards'])->toFloat(), | ||
'largestAmount' => BigNumber::new($data['largest_amount'])->toFloat(), | ||
]); | ||
} | ||
|
||
private function blockData(): array | ||
{ | ||
return Cache::remember('blocks:stats', self::STATS_TTL, function () { | ||
$timestamp = Timestamp::fromUnix(Carbon::now()->subDays(1)->unix())->unix(); | ||
$data = (array) DB::connection('explorer') | ||
->table('blocks') | ||
->selectRaw('COUNT(*) as block_count') | ||
->selectRaw('SUM(reward) as total_rewards') | ||
->selectRaw('MAX(total_amount) as largest_amount') | ||
->where('timestamp', '>', $timestamp) | ||
->first(); | ||
|
||
return [ | ||
'block_count' => $data['block_count'], | ||
'missed_count' => ForgingStats::missed()->where('timestamp', '>', $timestamp)->count(), | ||
'total_rewards' => $data['total_rewards'] ?? 0, | ||
'largest_amount' => $data['largest_amount'] ?? 0, | ||
]; | ||
}); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@component('layouts.app') | ||
<x-metadata page="blocks" /> | ||
|
||
@section('content') | ||
<x-page-headers.blocks | ||
:forged-count="$forgedCount" | ||
:missed-count="$missedCount" | ||
:total-rewards="$totalRewards" | ||
:largest-amount="$largestAmount" | ||
/> | ||
|
||
<div class="px-6 pt-6 pb-8 border-t-4 md:px-10 md:pt-0 md:pb-6 md:mx-auto md:max-w-7xl md:border-0 border-theme-secondary-200 dark:border-theme-dark-950"> | ||
<livewire:block-table /> | ||
</div> | ||
@endsection | ||
@endcomponent |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@props([ | ||
'forgedCount', | ||
'missedCount', | ||
'totalRewards', | ||
'largestAmount', | ||
]) | ||
|
||
<x-page-headers.generic | ||
:title="trans('pages.blocks.title')" | ||
:subtitle="trans('pages.blocks.subtitle', ['network' => Network::name()])" | ||
class="md:pb-3" | ||
> | ||
<div class="grid flex-1 grid-cols-1 gap-2 w-full sm:grid-cols-2 md:gap-3 xl:grid-cols-4"> | ||
<x-page-headers.blocks.blocks-produced :count="$forgedCount" /> | ||
<x-page-headers.blocks.missed-blocks :count="$missedCount" /> | ||
<x-page-headers.blocks.block-rewards :rewards="$totalRewards" /> | ||
<x-page-headers.blocks.largest-block :amount="$largestAmount" /> | ||
</div> | ||
</x-page-headers.generic> |
10 changes: 10 additions & 0 deletions
10
resources/views/components/page-headers/blocks/block-rewards.blade.php
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,10 @@ | ||
@props(['rewards']) | ||
|
||
<x-page-headers.header-item | ||
:title="trans('pages.blocks.block_rewards_24h')" | ||
:attributes="$attributes" | ||
> | ||
<span> | ||
{{ ExplorerNumberFormatter::currency($rewards, Network::currency()) }} | ||
</span> | ||
</x-page-headers.header-item> |
10 changes: 10 additions & 0 deletions
10
resources/views/components/page-headers/blocks/blocks-produced.blade.php
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,10 @@ | ||
@props(['count']) | ||
|
||
<x-page-headers.header-item | ||
:title="trans('pages.blocks.blocks_produced_24h')" | ||
:attributes="$attributes" | ||
> | ||
<span> | ||
<x-number>{{ $count }}</x-number> | ||
</span> | ||
</x-page-headers.header-item> |
10 changes: 10 additions & 0 deletions
10
resources/views/components/page-headers/blocks/largest-block.blade.php
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,10 @@ | ||
@props(['amount']) | ||
|
||
<x-page-headers.header-item | ||
:title="trans('pages.blocks.largest_block_24h')" | ||
:attributes="$attributes" | ||
> | ||
<span> | ||
{{ ExplorerNumberFormatter::currency($amount, Network::currency()) }} | ||
</span> | ||
</x-page-headers.header-item> |
10 changes: 10 additions & 0 deletions
10
resources/views/components/page-headers/blocks/missed-blocks.blade.php
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,10 @@ | ||
@props(['count']) | ||
|
||
<x-page-headers.header-item | ||
:title="trans('pages.blocks.missed_blocks_24h')" | ||
:attributes="$attributes" | ||
> | ||
<span> | ||
<x-number>{{ $count }}</x-number> | ||
</span> | ||
</x-page-headers.header-item> |
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
<x-loading.visible> | ||
@isset($withoutGenerator) | ||
<x-tables.desktop.skeleton.blocks without-generator /> | ||
@props([ | ||
'rowCount' => 10, | ||
]) | ||
|
||
<x-tables.mobile.skeleton.blocks without-generator /> | ||
@else | ||
<x-tables.desktop.skeleton.blocks /> | ||
@if (! $this->isReady) | ||
<div wire:key="skeleton:blocks:not-ready"> | ||
<x-tables.desktop.skeleton.blocks :row-count="$rowCount" /> | ||
|
||
<x-tables.mobile.skeleton.blocks /> | ||
@endif | ||
</x-loading.visible> | ||
</div> | ||
@else | ||
<x-loading.visible | ||
wire:key="skeleton:blocks:ready" | ||
display-type="block" | ||
> | ||
<x-tables.desktop.skeleton.blocks :row-count="$rowCount" /> | ||
|
||
<x-loading.hidden> | ||
{{ $slot }} | ||
</x-loading.hidden> | ||
<x-tables.mobile.skeleton.blocks /> | ||
</x-loading.visible> | ||
|
||
<div wire:key="skeleton:blocks:hidden"> | ||
<x-loading.hidden> | ||
{{ $slot }} | ||
</x-loading.hidden> | ||
</div> | ||
@endif |
Oops, something went wrong.