fix: Show total hashrate & color temps when high

This commit is contained in:
mrv777 2024-11-09 17:41:08 -06:00
parent 0f4030b4a1
commit 13ad7c70c3
2 changed files with 15 additions and 1 deletions

View File

@ -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">
@ -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>

View File

@ -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,
@ -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(() => {
@ -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;
@ -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();
}
});
}
@ -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() {
@ -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: () => {
}
@ -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);
}
}