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 b858a5d..06287f7 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
@@ -26,7 +26,6 @@
@@ -68,7 +67,7 @@
{{axe.hostname}}
{{axe.hashRate * 1000000000 | hashSuffix}} |
- {{axe.uptimeSeconds | dateAgo}} |
+ {{axe.uptimeSeconds | dateAgo: {intervals: 2} }} |
{
- if (!this.isRefreshing) {
+ if (!this.scanning && !this.isRefreshing) {
this.refreshIntervalTime--;
if (this.refreshIntervalTime <= 0) {
this.refreshList();
@@ -84,8 +83,6 @@ export class SwarmComponent implements OnInit, OnDestroy {
this.form.reset();
}
-
-
private ipToInt(ip: string): number {
return ip.split('.').reduce((acc, octet) => (acc << 8) + parseInt(octet, 10), 0) >>> 0;
}
@@ -111,12 +108,15 @@ export class SwarmComponent implements OnInit, OnDestroy {
mergeMap(ipAddr =>
this.httpClient.get(`http://${ipAddr}/api/system/info`).pipe(
map(result => {
- return {
- IP: ipAddr,
- ...result
+ if ('hashRate' in result) {
+ return {
+ IP: ipAddr,
+ ...result
+ };
}
+ return null;
}),
- timeout(5000), // Set the timeout to 1 second
+ timeout(5000), // Set the timeout to 5 seconds
catchError(error => {
//console.error(`Request to ${ipAddr}/api/system/info failed or timed out`, error);
return []; // Return an empty result or handle as desired
@@ -127,9 +127,11 @@ export class SwarmComponent implements OnInit, OnDestroy {
toArray() // Collect all results into a single array
).pipe(take(1)).subscribe({
next: (result) => {
+ // Filter out null items first
+ const validResults = result.filter((item): item is NonNullable => item !== null);
// Merge new results with existing swarm entries
const existingIps = new Set(this.swarm.map(item => item.IP));
- const newItems = result.filter(item => !existingIps.has(item.IP));
+ const newItems = validResults.filter(item => !existingIps.has(item.IP));
this.swarm = [...this.swarm, ...newItems].sort(this.sortByIp.bind(this));
this.localStorageService.setObject(SWARM_DATA, this.swarm);
this.calculateTotals();
@@ -184,6 +186,10 @@ export class SwarmComponent implements OnInit, OnDestroy {
}
public refreshList() {
+ if (this.scanning) {
+ return;
+ }
+
this.refreshIntervalTime = this.refreshTimeSet;
const ips = this.swarm.map(axeOs => axeOs.IP);
this.isRefreshing = true;
diff --git a/main/http_server/axe-os/src/app/pipes/date-ago.pipe.ts b/main/http_server/axe-os/src/app/pipes/date-ago.pipe.ts
index 8e50368..5807281 100644
--- a/main/http_server/axe-os/src/app/pipes/date-ago.pipe.ts
+++ b/main/http_server/axe-os/src/app/pipes/date-ago.pipe.ts
@@ -22,9 +22,11 @@ export class DateAgoPipe implements PipeTransform {
'second': 1
};
let result = '';
+ let shownIntervals = 0;
for (const i in intervals) {
+ if (args?.intervals && shownIntervals >= args.intervals) break;
const counter = Math.floor(seconds / intervals[i]);
- if (counter > 0)
+ if (counter > 0) {
if (counter === 1) {
if (result) result += ', '
result += counter + ' ' + i + ''; // singular (1 day ago)
@@ -34,6 +36,8 @@ export class DateAgoPipe implements PipeTransform {
result += counter + ' ' + i + 's'; // plural (2 days ago)
seconds -= intervals[i] * counter
}
+ shownIntervals++;
+ }
}
return result;
}
|