This commit is contained in:
Ben Wilson
2023-06-24 12:54:21 -04:00
parent 48516e468e
commit 3ba7ef8ca9
14 changed files with 355 additions and 62 deletions
+16 -16
View File
@@ -13,14 +13,14 @@
</div>
</div>
<!-- <span class="text-green-500 font-medium">24 new </span> -->
<span class="text-500">{{workerInfo.id}}</span>
<span class="text-500">{{workerInfo.sessionId}}</span>
</div>
</div>
<div class="col-12 lg:col-6 xl:col-3">
<div class="card mb-0">
<div class="flex justify-content-between mb-3">
<div>
<span class="block text-500 font-medium mb-3">Best Luck</span>
<span class="block text-500 font-medium mb-3">Best Difficulty</span>
<div class="text-900 font-medium text-xl">{{workerInfo.bestDifficulty | numberSuffix}}
</div>
</div>
@@ -32,23 +32,23 @@
<span class="text-green-500 font-medium">{{workerInfo.bestDifficulty | number}}</span>
</div>
</div>
<!-- <div class="col-12 lg:col-6 xl:col-3">
<div class="card mb-0">
<div class="flex justify-content-between mb-3">
<div>
<span class="block text-500 font-medium mb-3">Customers</span>
<div class="text-900 font-medium text-xl">28441</div>
</div>
<div class="flex align-items-center justify-content-center bg-cyan-100 border-round"
[ngStyle]="{width: '2.5rem', height: '2.5rem'}">
<i class="pi pi-inbox text-cyan-500 text-xl"></i>
<div class="col-12 lg:col-6 xl:col-3">
<div class="card mb-0">
<div class="flex justify-content-between mb-3">
<div>
<span class="block text-500 font-medium mb-3">Uptime</span>
<div class="text-900 font-medium text-xl">{{workerInfo.startTime | dateAgo}}</div>
</div>
<div class="flex align-items-center justify-content-center bg-cyan-100 border-round"
[ngStyle]="{width: '2.5rem', height: '2.5rem'}">
<i class="pi pi-clock text-cyan-500 text-xl"></i>
</div>
</div>
<!-- <span class="text-green-500 font-medium">520 </span>-->
<span class="text-500">Since {{workerInfo.startTime | date : 'short'}}</span>
</div>
<span class="text-green-500 font-medium">520 </span>
<span class="text-500">newly registered</span>
</div>
</div>
<div class="col-12 lg:col-6 xl:col-3">
<!-- <div class="col-12 lg:col-6 xl:col-3">
<div class="card mb-0">
<div class="flex justify-content-between mb-3">
<div>
+3 -33
View File
@@ -23,49 +23,19 @@ export class WorkerComponent {
const textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
const surfaceBorder = documentStyle.getPropertyValue('--surface-border');
this.workerInfo$ = this.workerService.getWorkerInfo(this.route.snapshot.params['address'], this.route.snapshot.params['workerId']).pipe(
this.workerInfo$ = this.workerService.getWorkerInfo(this.route.snapshot.params['address'], this.route.snapshot.params['workerName'], this.route.snapshot.params['workerId']).pipe(
shareReplay({ bufferSize: 1, refCount: true })
)
this.chartData$ = this.workerInfo$.pipe(
map((workerInfo: any) => {
const GROUP_SIZE = 60;
const slice = workerInfo.hashData.length % GROUP_SIZE == 0 ? workerInfo.hashData : workerInfo.hashData.slice(0, workerInfo.hashData.length - workerInfo.hashData.length % GROUP_SIZE)
const reducedData = ((slice as any[])
.reduce((pre, cur, idx, arr) => {
if (idx % GROUP_SIZE != 0) {
pre[pre.length - 1].difficulty += cur.difficulty;
} else {
pre.push(cur);
}
return pre;
}, []) as any[]);
const labels = reducedData.reduce((pre, cur, idx, arr) => {
if (idx == 0) {
return pre;
}
pre.push(new Date(cur.time));
return pre;
}, []);
const data = reducedData
.reduce((pre, cur, idx, arr) => {
if (idx == 0) {
return pre;
}
//hashrate = (nonce_difficulty * 2^32) / time_to_find
pre.push((cur.difficulty * 4294967296 / (new Date(cur.time).getTime() - new Date(arr[idx - 1].time).getTime())) / 1000000);
return pre;
}, []);
return {
labels,
labels: workerInfo.chartData.map((d: any) => d.label),
datasets: [
{
label: workerInfo.name,
data,
data: workerInfo.chartData.map((d: any) => d.data),
fill: false,
backgroundColor: documentStyle.getPropertyValue('--bluegray-700'),
borderColor: documentStyle.getPropertyValue('--bluegray-700'),