mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-17 13:22:53 +01:00
Add uptime to home screen (#425)
This commit is contained in:
parent
fe4ac7e305
commit
468718abda
@ -218,6 +218,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 lg:col-6">
|
||||
<div class="card" *ngIf="info$ | async as info; else loading">
|
||||
<h5>Uptime</h5>
|
||||
{{info.uptimeSeconds | dateAgo}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -9,7 +9,7 @@ export class DateAgoPipe implements PipeTransform {
|
||||
transform(value: any, args?: any): any {
|
||||
if (value) {
|
||||
value = new Date().getTime() - value * 1000;
|
||||
const seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
|
||||
let seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
|
||||
if (seconds < 29) // less than 30 seconds ago will show as 'Just now'
|
||||
return 'Just now';
|
||||
const intervals: { [key: string]: number } = {
|
||||
@ -21,16 +21,21 @@ export class DateAgoPipe implements PipeTransform {
|
||||
'minute': 60,
|
||||
'second': 1
|
||||
};
|
||||
let counter;
|
||||
let result = '';
|
||||
for (const i in intervals) {
|
||||
counter = Math.floor(seconds / intervals[i]);
|
||||
const counter = Math.floor(seconds / intervals[i]);
|
||||
if (counter > 0)
|
||||
if (counter === 1) {
|
||||
return counter + ' ' + i + ''; // singular (1 day ago)
|
||||
if (result) result += ', '
|
||||
result += counter + ' ' + i + ''; // singular (1 day ago)
|
||||
seconds -= intervals[i]
|
||||
} else {
|
||||
return counter + ' ' + i + 's'; // plural (2 days ago)
|
||||
if (result) result += ', '
|
||||
result += counter + ' ' + i + 's'; // plural (2 days ago)
|
||||
seconds -= intervals[i] * counter
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user