Skip to content

Commit

Permalink
fix: Show total hashrate & color temps when high
Browse files Browse the repository at this point in the history
  • Loading branch information
mrv777 committed Nov 9, 2024
1 parent 0f4030b commit 13ad7c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<button pButton (click)="scanNetwork()" [disabled]="scanning">{{scanning ? 'Scanning...' : 'Automatic Scan'}}</button>
<button pButton severity="secondary" (click)="refreshList()" [disabled]="scanning">Refresh List ({{refreshIntervalTime}})</button>
</div>
<div class="text-sm md:text-base">
Total Hash Rate: <span class="text-primary">{{totalHashRate * 1000000000 | hashSuffix}}</span>
</div>
</div>

<div class="table-container">
Expand Down Expand Up @@ -46,7 +49,7 @@
<td>{{axe.uptimeSeconds | dateAgo}}</td>
<td>{{axe.sharesAccepted | number: '1.0-0'}}</td>
<td>{{axe.power | number: '1.1-1'}} <small>W</small> </td>
<td>{{axe.temp | number: '1.0-1'}}°<small>C</small></td>
<td [ngClass]="{'text-orange-500': axe.temp > 65}">{{axe.temp | number: '1.0-1'}}°<small>C</small></td>
<td>{{axe.bestDiff}}</td>
<td>{{axe.version}}</td>
<td><p-button icon="pi pi-pencil" pp-button (click)="edit(axe)"></p-button></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class SwarmComponent implements OnInit, OnDestroy {
public refreshIntervalRef!: number;
public refreshIntervalTime = REFRESH_TIME_SECONDS;

public totalHashRate: number = 0;

constructor(
private fb: FormBuilder,
private systemService: SystemService,
Expand All @@ -48,6 +50,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
//this.swarm$ = this.scanNetwork('192.168.1.23', '255.255.255.0').pipe(take(1));
} else {
this.swarm = swarmData;
this.calculateTotalHashRate();
}

this.refreshIntervalRef = window.setInterval(() => {
Expand Down Expand Up @@ -111,6 +114,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
const newItems = result.filter(item => !existingIps.has(item.IP));
this.swarm = [...this.swarm, ...newItems].sort(this.sortByIp.bind(this));
this.localStorageService.setObject(SWARM_DATA, this.swarm);
this.calculateTotalHashRate();
},
complete: () => {
this.scanning = false;
Expand All @@ -132,6 +136,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
this.swarm.push({ IP: newIp, ...res });
this.swarm = this.swarm.sort(this.sortByIp.bind(this));
this.localStorageService.setObject(SWARM_DATA, this.swarm);
this.calculateTotalHashRate();
}
});
}
Expand All @@ -157,6 +162,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
public remove(axeOs: any) {
this.swarm = this.swarm.filter(axe => axe.IP != axeOs.IP);
this.localStorageService.setObject(SWARM_DATA, this.swarm);
this.calculateTotalHashRate();
}

public refreshList() {
Expand Down Expand Up @@ -185,6 +191,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
next: (result) => {
this.swarm = result.sort(this.sortByIp.bind(this));
this.localStorageService.setObject(SWARM_DATA, this.swarm);
this.calculateTotalHashRate();
},
complete: () => {
}
Expand All @@ -196,4 +203,8 @@ export class SwarmComponent implements OnInit, OnDestroy {
return this.ipToInt(a.IP) - this.ipToInt(b.IP);
}

private calculateTotalHashRate() {
this.totalHashRate = this.swarm.reduce((sum, axe) => sum + (axe.hashRate || 0), 0);
}

}

0 comments on commit 13ad7c7

Please sign in to comment.