Node stats updates

This commit is contained in:
softsimon
2022-05-05 23:19:24 +04:00
parent 7d6f0b5ebe
commit d9d7f8cc66
11 changed files with 127 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
intervals = {};
@Input() time: number;
@Input() dateString: number;
@Input() fastRender = false;
constructor(
@@ -52,7 +53,13 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
}
calculate() {
const seconds = Math.floor((+new Date() - +new Date(this.time * 1000)) / 1000);
let date: Date;
if (this.dateString) {
date = new Date(this.dateString)
} else {
date = new Date(this.time * 1000);
}
const seconds = Math.floor((+new Date() - +date) / 1000);
if (seconds < 60) {
return $localize`:@@date-base.just-now:Just now`;
}

View File

@@ -32,6 +32,10 @@ export class LightningApiService {
return this.httpClient.get<any>(API_BASE_URL + '/statistics/latest');
}
listNodeStats$(publicKey: string): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/nodes/' + publicKey + '/statistics');
}
listTopNodes$(): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/nodes/top');
}

View File

@@ -18,12 +18,16 @@
<table class="table table-borderless table-striped">
<tbody>
<tr>
<td i18n="address.total-received">First Seen</td>
<td>{{ node.first_seen | date:'yyyy-MM-dd HH:mm' }}</td>
<td i18n="address.total-received">First seen</td>
<td>
<app-time-since [dateString]="node.first_seen"></app-time-since>
</td>
</tr>
<tr>
<td i18n="address.total-sent">Updated At</td>
<td>{{ node.updated_at | date:'yyyy-MM-dd HH:mm' }}</td>
<td i18n="address.total-sent">Last update</td>
<td>
<app-time-since [dateString]="node.updated_at"></app-time-since>
</td>
</tr>
<tr>
<td i18n="address.balance">Color</td>

View File

@@ -12,6 +12,7 @@ import { LightningApiService } from '../lightning-api.service';
})
export class NodeComponent implements OnInit {
node$: Observable<any>;
statistics$: Observable<any>;
publicKey$: Observable<string>;
constructor(
@@ -26,6 +27,13 @@ export class NodeComponent implements OnInit {
return this.lightningApiService.getNode$(params.get('public_key'));
})
);
this.statistics$ = this.activatedRoute.paramMap
.pipe(
switchMap((params: ParamMap) => {
return this.lightningApiService.listNodeStats$(params.get('public_key'));
})
);
}
}

View File

@@ -12,10 +12,10 @@
<a [routerLink]="['/lightning/node' | relativeUrl, node.public_key]">{{ node.alias }}</a>
</td>
<td class="capacity text-right">
<app-amount [satoshis]="node.capacity_left + node.capacity_right" digitsInfo="1.2-2"></app-amount>
<app-amount [satoshis]="node.capacity" digitsInfo="1.2-2"></app-amount>
</td>
<td class="channels text-right">
{{ node.channels_left + node.channels_right | number }}
{{ node.channels | number }}
</td>
</tr>
</tbody>