correct hashrate suffix
This commit is contained in:
@@ -17,6 +17,7 @@ import { WorkerComponent } from './components/worker/worker.component';
|
|||||||
import { AppLayoutModule } from './layout/app.layout.module';
|
import { AppLayoutModule } from './layout/app.layout.module';
|
||||||
import { DateAgoPipe } from './pipes/date-ago.pipe';
|
import { DateAgoPipe } from './pipes/date-ago.pipe';
|
||||||
import { NumberSuffixPipe } from './pipes/number-suffix.pipe';
|
import { NumberSuffixPipe } from './pipes/number-suffix.pipe';
|
||||||
|
import { HashSuffixPipe } from './pipes/hash-suffix.pipe';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +30,8 @@ import { NumberSuffixPipe } from './pipes/number-suffix.pipe';
|
|||||||
NumberSuffixPipe,
|
NumberSuffixPipe,
|
||||||
DateAgoPipe,
|
DateAgoPipe,
|
||||||
WorkerGroupComponent,
|
WorkerGroupComponent,
|
||||||
BackgroundParticlesComponent
|
BackgroundParticlesComponent,
|
||||||
|
HashSuffixPipe
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
{{getSessionCount(worker.name, clientInfo.workers)}} Sessions
|
{{getSessionCount(worker.name, clientInfo.workers)}} Sessions
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{getTotalHashRate(worker.name, clientInfo.workers)}} GH/s
|
{{getTotalHashRate(worker.name, clientInfo.workers) | hashSuffix}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{getBestDifficulty(worker.name, clientInfo.workers) | numberSuffix}}
|
{{getBestDifficulty(worker.name, clientInfo.workers) | numberSuffix}}
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<tr [routerLink]="[worker.name, worker.sessionId]">
|
<tr [routerLink]="[worker.name, worker.sessionId]">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>{{worker.sessionId}}</td>
|
<td>{{worker.sessionId}}</td>
|
||||||
<td>{{worker.hashRate}} GH/s</td>
|
<td>{{worker.hashRate | hashSuffix}}</td>
|
||||||
<td>{{worker.bestDifficulty | numberSuffix}}</td>
|
<td>{{worker.bestDifficulty | numberSuffix}}</td>
|
||||||
<td>{{worker.startTime | dateAgo}}</td>
|
<td>{{worker.startTime | dateAgo}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { map, Observable, shareReplay } from 'rxjs';
|
import { map, Observable, shareReplay } from 'rxjs';
|
||||||
|
|
||||||
|
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
||||||
import { ClientService } from '../../services/client.service';
|
import { ClientService } from '../../services/client.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -18,6 +19,8 @@ export class DashboardComponent {
|
|||||||
|
|
||||||
public chartOptions: any;
|
public chartOptions: any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private clientService: ClientService, private route: ActivatedRoute) {
|
constructor(private clientService: ClientService, private route: ActivatedRoute) {
|
||||||
this.address = this.route.snapshot.params['address'];
|
this.address = this.route.snapshot.params['address'];
|
||||||
this.clientInfo$ = this.clientService.getClientInfo(this.address).pipe(
|
this.clientInfo$ = this.clientService.getClientInfo(this.address).pipe(
|
||||||
@@ -108,7 +111,7 @@ export class DashboardComponent {
|
|||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
color: textColorSecondary,
|
color: textColorSecondary,
|
||||||
callback: (value: number) => value + ' GH/s',
|
callback: (value: number) => HashSuffixPipe.transform(value)
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
color: surfaceBorder,
|
color: surfaceBorder,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { map, Observable } from 'rxjs';
|
import { map, Observable } from 'rxjs';
|
||||||
|
|
||||||
|
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
||||||
import { AppService } from '../../services/app.service';
|
import { AppService } from '../../services/app.service';
|
||||||
import { bitcoinAddressValidator } from '../../validators/bitcoin-address.validator';
|
import { bitcoinAddressValidator } from '../../validators/bitcoin-address.validator';
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ export class SplashComponent {
|
|||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
color: textColorSecondary,
|
color: textColorSecondary,
|
||||||
callback: (value: number) => value + ' GH/s',
|
callback: (value: number) => HashSuffixPipe.transform(value)
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
color: surfaceBorder,
|
color: surfaceBorder,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { map, Observable, shareReplay } from 'rxjs';
|
import { map, Observable, shareReplay } from 'rxjs';
|
||||||
|
|
||||||
|
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
||||||
import { WorkerService } from '../../services/worker.service';
|
import { WorkerService } from '../../services/worker.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -75,7 +76,7 @@ export class WorkerGroupComponent {
|
|||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
color: textColorSecondary,
|
color: textColorSecondary,
|
||||||
callback: (value: number) => value + ' GH/s',
|
callback: (value: number) => HashSuffixPipe.transform(value)
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
color: surfaceBorder,
|
color: surfaceBorder,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { map, Observable, shareReplay } from 'rxjs';
|
import { map, Observable, shareReplay } from 'rxjs';
|
||||||
|
|
||||||
|
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
||||||
import { WorkerService } from '../../services/worker.service';
|
import { WorkerService } from '../../services/worker.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -75,7 +76,7 @@ export class WorkerComponent {
|
|||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
color: textColorSecondary,
|
color: textColorSecondary,
|
||||||
callback: (value: number) => value + ' GH/s',
|
callback: (value: number) => HashSuffixPipe.transform(value)
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
color: surfaceBorder,
|
color: surfaceBorder,
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { HashSuffixPipe } from './hash-suffix.pipe';
|
||||||
|
|
||||||
|
describe('HashSuffixPipe', () => {
|
||||||
|
it('create an instance', () => {
|
||||||
|
const pipe = new HashSuffixPipe();
|
||||||
|
expect(pipe).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'hashSuffix'
|
||||||
|
})
|
||||||
|
export class HashSuffixPipe implements PipeTransform {
|
||||||
|
|
||||||
|
private static _this = new HashSuffixPipe();
|
||||||
|
|
||||||
|
public static transform(value: number): string {
|
||||||
|
return this._this.transform(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public transform(value: number): string {
|
||||||
|
|
||||||
|
if (value == null || value < 1) {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
const suffixes = [' H/s', ' KH/s', ' MH/s', ' GH/s', ' TH/s', ' PH/s', ' EH/s'];
|
||||||
|
|
||||||
|
const power = Math.floor(Math.log10(value) / 3);
|
||||||
|
const scaledValue = value / Math.pow(1000, power);
|
||||||
|
const suffix = suffixes[power];
|
||||||
|
|
||||||
|
return scaledValue.toFixed(1) + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user