Add difficulty adjustment table in mining dashboard

This commit is contained in:
nymkappa 2022-02-28 17:52:55 +09:00
parent b2dec5e20a
commit 6cdd41a8f7
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
3 changed files with 22 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<div [class]="widget === false ? 'full-container' : ''">
<div class="card-header mb-0 mb-md-4" [style]="widget ? 'display:none' : ''">
<div *ngIf="!tableOnly" class="card-header mb-0 mb-md-4" [style]="widget ? 'display:none' : ''">
<form [formGroup]="radioGroupForm" class="formRadioGroup" *ngIf="(hashrateObservable$ | async) as hashrates">
<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="dateSpan">
<label ngbButtonLabel class="btn-primary btn-sm" *ngIf="hashrates.availableTimespanDay >= 90">
@ -25,17 +25,16 @@
</form>
</div>
<div *ngIf="hashrateObservable$ | async" [class]="!widget ? 'chart' : 'chart-widget'"
<div *ngIf="(hashrateObservable$ | async) && !tableOnly" [class]="!widget ? 'chart' : 'chart-widget'"
echarts [initOpts]="chartInitOptions" [options]="chartOptions"></div>
<div class="text-center loadingGraphs" *ngIf="isLoading">
<div class="spinner-border text-light"></div>
</div>
<!-- <div class="mt-3" *ngIf="!widget">
<div class="mt-3" *ngIf="tableOnly || !widget">
<table class="table table-borderless table-sm text-center">
<thead>
<tr>
<th i18n="mining.rank">Block</th>
<th class="d-none d-md-block" i18n="block.timestamp">Timestamp</th>
<th i18n="mining.adjusted">Adjusted</th>
<th i18n="mining.difficulty">Difficulty</th>
@ -44,15 +43,13 @@
</thead>
<tbody *ngIf="(hashrateObservable$ | async) as data">
<tr *ngFor="let diffChange of data.difficulty">
<td><a [routerLink]="['/block' | relativeUrl, diffChange.height]">{{ diffChange.height }}</a></td>
<td class="d-none d-md-block">&lrm;{{ diffChange.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}</td>
<td><app-time-since [time]="diffChange.timestamp" [fastRender]="true"></app-time-since></td>
<td class="d-none d-md-block">{{ formatNumber(diffChange.difficulty, locale, '1.2-2') }}</td>
<td class="d-block d-md-none">{{ diffChange.difficultyShorten }}</td>
<td>{{ diffChange.difficultyShorten }}</td>
<td [style]="diffChange.change >= 0 ? 'color: #42B747' : 'color: #B74242'">{{ formatNumber(diffChange.change, locale, '1.2-2') }}%</td>
</tr>
</tbody>
</table>
</div> -->
</div>
</div>

View File

@ -22,7 +22,8 @@ import { selectPowerOfTen } from 'src/app/bitcoin.utils';
`],
})
export class HashrateChartComponent implements OnInit {
@Input() widget: boolean = false;
@Input() tableOnly = false;
@Input() widget = false;
@Input() right: number | string = 45;
@Input() left: number | string = 75;
@ -114,7 +115,7 @@ export class HashrateChartComponent implements OnInit {
}
return {
availableTimespanDay: availableTimespanDay,
difficulty: tableData
difficulty: this.tableOnly ? tableData.slice(0, 8) : tableData
};
}),
);

View File

@ -44,11 +44,10 @@
</div>
</div>
<!-- pools hashrate -->
<!-- pool dominance -->
<div class="col">
<div class="card" style="height: 385px">
<div class="card-body">
<!-- pool dominance -->
<h5 class="card-title">
<a href="" [routerLink]="['/mining/hashrate/pools' | relativeUrl]" i18n="mining.pool-historical-dominance">
Mining Pools Dominance (1y)
@ -59,5 +58,18 @@
</div>
</div>
<div class="col">
<div class="card" style="height: 385px">
<div class="card-body">
<h5 class="card-title">
<a href="" [routerLink]="['/mining/hashrate' | relativeUrl]" i18n="mining.pool-historical-dominance">
Adjusments
</a>
</h5>
<app-hashrate-chart [tableOnly]=true [widget]=true></app-hashrate-chart>
</div>
</div>
</div>
</div>
</div>