From 13ad7c70c36bbefb690d9de42d515cb0f00c47ef Mon Sep 17 00:00:00 2001 From: mrv777 Date: Sat, 9 Nov 2024 17:41:08 -0600 Subject: [PATCH] fix: Show total hashrate & color temps when high --- .../src/app/components/swarm/swarm.component.html | 5 ++++- .../src/app/components/swarm/swarm.component.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main/http_server/axe-os/src/app/components/swarm/swarm.component.html b/main/http_server/axe-os/src/app/components/swarm/swarm.component.html index e4440d8e..0694d89f 100644 --- a/main/http_server/axe-os/src/app/components/swarm/swarm.component.html +++ b/main/http_server/axe-os/src/app/components/swarm/swarm.component.html @@ -19,6 +19,9 @@ +
+ Total Hash Rate: {{totalHashRate * 1000000000 | hashSuffix}} +
@@ -46,7 +49,7 @@ {{axe.uptimeSeconds | dateAgo}} {{axe.sharesAccepted | number: '1.0-0'}} {{axe.power | number: '1.1-1'}} W - {{axe.temp | number: '1.0-1'}}°C + {{axe.temp | number: '1.0-1'}}°C {{axe.bestDiff}} {{axe.version}} diff --git a/main/http_server/axe-os/src/app/components/swarm/swarm.component.ts b/main/http_server/axe-os/src/app/components/swarm/swarm.component.ts index d49f3cfc..fac79e2a 100644 --- a/main/http_server/axe-os/src/app/components/swarm/swarm.component.ts +++ b/main/http_server/axe-os/src/app/components/swarm/swarm.component.ts @@ -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); + } + }