Merge pull request #5320 from mempool/mononaut/24h-acc-dash

Add 24h and all time views to accelerator dashboard
This commit is contained in:
softsimon 2024-07-12 15:02:46 +09:00 committed by GitHub
commit 0e5a1abb2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 5 deletions

View File

@ -32,7 +32,7 @@ export class AccelerationFeesGraphComponent implements OnInit, OnChanges, OnDest
@Input() height: number = 300; @Input() height: number = 300;
@Input() right: number | string = 45; @Input() right: number | string = 45;
@Input() left: number | string = 75; @Input() left: number | string = 75;
@Input() period: '3d' | '1w' | '1m' = '1w'; @Input() period: '24h' | '3d' | '1w' | '1m' | 'all' = '1w';
@Input() accelerations$: Observable<Acceleration[]>; @Input() accelerations$: Observable<Acceleration[]>;
miningWindowPreference: string; miningWindowPreference: string;
@ -48,7 +48,7 @@ export class AccelerationFeesGraphComponent implements OnInit, OnChanges, OnDest
isLoading = true; isLoading = true;
formatNumber = formatNumber; formatNumber = formatNumber;
timespan = ''; timespan = '';
periodSubject$: Subject<'3d' | '1w' | '1m'> = new Subject(); periodSubject$: Subject<'24h' | '3d' | '1w' | '1m' | 'all'> = new Subject();
chartInstance: any = undefined; chartInstance: any = undefined;
daysAvailable: number = 0; daysAvailable: number = 0;
@ -78,7 +78,7 @@ export class AccelerationFeesGraphComponent implements OnInit, OnChanges, OnDest
this.radioGroupForm.controls.dateSpan.setValue(this.miningWindowPreference); this.radioGroupForm.controls.dateSpan.setValue(this.miningWindowPreference);
this.route.fragment.subscribe((fragment) => { this.route.fragment.subscribe((fragment) => {
if (['24h', '3d', '1w', '1m', '3m'].indexOf(fragment) > -1) { if (['24h', '3d', '1w', '1m', '3m', 'all'].indexOf(fragment) > -1) {
this.radioGroupForm.controls.dateSpan.setValue(fragment, { emitEvent: false }); this.radioGroupForm.controls.dateSpan.setValue(fragment, { emitEvent: false });
} }
}); });

View File

@ -16,7 +16,7 @@ export type AccelerationStats = {
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class AccelerationStatsComponent implements OnInit, OnChanges { export class AccelerationStatsComponent implements OnInit, OnChanges {
@Input() timespan: '3d' | '1w' | '1m' = '1w'; @Input() timespan: '24h' | '3d' | '1w' | '1m' | 'all' = '1w';
accelerationStats$: Observable<AccelerationStats>; accelerationStats$: Observable<AccelerationStats>;
blocksInPeriod: number = 7 * 144; blocksInPeriod: number = 7 * 144;
@ -35,6 +35,9 @@ export class AccelerationStatsComponent implements OnInit, OnChanges {
updateStats(): void { updateStats(): void {
this.accelerationStats$ = this.servicesApiService.getAccelerationStats$({ timeframe: this.timespan }); this.accelerationStats$ = this.servicesApiService.getAccelerationStats$({ timeframe: this.timespan });
switch (this.timespan) { switch (this.timespan) {
case '24h':
this.blocksInPeriod = 144;
break;
case '3d': case '3d':
this.blocksInPeriod = 3 * 144; this.blocksInPeriod = 3 * 144;
break; break;
@ -44,6 +47,9 @@ export class AccelerationStatsComponent implements OnInit, OnChanges {
case '1m': case '1m':
this.blocksInPeriod = 30 * 144; this.blocksInPeriod = 30 * 144;
break; break;
case 'all':
this.blocksInPeriod = Infinity;
break;
} }
} }
} }

View File

@ -23,12 +23,18 @@
<div class="main-title"> <div class="main-title">
<span [attr.data-cy]="'acceleration-stats'" i18n="accelerator.acceleration-stats">Acceleration stats</span>&nbsp; <span [attr.data-cy]="'acceleration-stats'" i18n="accelerator.acceleration-stats">Acceleration stats</span>&nbsp;
@switch (timespan) { @switch (timespan) {
@case ('24h') {
<span style="font-size: xx-small" i18n="mining.1-day">(1 day)</span>
}
@case ('1w') { @case ('1w') {
<span style="font-size: xx-small" i18n="mining.1-week">(1 week)</span> <span style="font-size: xx-small" i18n="mining.1-week">(1 week)</span>
} }
@case ('1m') { @case ('1m') {
<span style="font-size: xx-small" i18n="mining.1-month">(1 month)</span> <span style="font-size: xx-small" i18n="mining.1-month">(1 month)</span>
} }
@case ('all') {
<span style="font-size: xx-small" i18n="mining.all-time">(all time)</span>
}
} }
</div> </div>
<div class="card-wrapper"> <div class="card-wrapper">
@ -36,11 +42,17 @@
<div class="card-body more-padding"> <div class="card-body more-padding">
<app-acceleration-stats [timespan]="timespan"></app-acceleration-stats> <app-acceleration-stats [timespan]="timespan"></app-acceleration-stats>
<div class="widget-toggler"> <div class="widget-toggler">
<a href="" (click)="setTimespan('24h')" class="toggler-option"
[ngClass]="{'inactive': timespan === '24h'}"><small>24h</small></a>
<span style="color: #ffffff66; font-size: 8px"> | </span>
<a href="" (click)="setTimespan('1w')" class="toggler-option" <a href="" (click)="setTimespan('1w')" class="toggler-option"
[ngClass]="{'inactive': timespan === '1w'}"><small>1w</small></a> [ngClass]="{'inactive': timespan === '1w'}"><small>1w</small></a>
<span style="color: #ffffff66; font-size: 8px"> | </span> <span style="color: #ffffff66; font-size: 8px"> | </span>
<a href="" (click)="setTimespan('1m')" class="toggler-option" <a href="" (click)="setTimespan('1m')" class="toggler-option"
[ngClass]="{'inactive': timespan === '1m'}"><small>1m</small></a> [ngClass]="{'inactive': timespan === '1m'}"><small>1m</small></a>
<span style="color: #ffffff66; font-size: 8px"> | </span>
<a href="" (click)="setTimespan('all')" class="toggler-option"
[ngClass]="{'inactive': timespan === 'all'}"><small>all</small></a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -37,7 +37,7 @@ export class AcceleratorDashboardComponent implements OnInit, OnDestroy {
webGlEnabled = true; webGlEnabled = true;
seen: Set<string> = new Set(); seen: Set<string> = new Set();
firstLoad = true; firstLoad = true;
timespan: '3d' | '1w' | '1m' = '1w'; timespan: '24h' | '3d' | '1w' | '1m' | 'all' = '1w';
accelerationDeltaSubscription: Subscription; accelerationDeltaSubscription: Subscription;