Add formatted connected time in listeners report (#4324)

This commit is contained in:
Vaalyn 2021-06-21 04:04:01 +02:00 committed by GitHub
parent 328caf3987
commit 3320520492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -128,6 +128,26 @@ $(function () {
var tlh_hours = tlh_seconds / 3600;
return Math.round((tlh_hours + 0.00001) * 100) / 100;
}
},
methods: {
formatTime (time) {
let sec_num = parseInt(time, 10);
let hours = Math.floor(sec_num / 3600);
let minutes = Math.floor((sec_num - (hours * 3600)) / 60);
let seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {
hours = '0' + hours;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
}
return (hours !== '00' ? hours + ':' : '') + minutes + ':' + seconds;
}
}
});

View File

@ -59,6 +59,7 @@ $assets
<thead>
<tr>
<th><?=__('IP')?></th>
<th><?=__('Time')?></th>
<th><?=__('Time (sec)')?></th>
<th><?=__('User Agent')?></th>
<th><?=__('Stream')?></th>
@ -68,6 +69,7 @@ $assets
<tbody>
<tr v-for="listener in listeners">
<td>{{ listener.ip }}</td>
<td>{{ formatTime(listener.connected_time) }}</td>
<td>{{ listener.connected_time }}</td>
<td>
<span v-if="listener.is_mobile">