mirror of
https://github.com/TwiN/gatus.git
synced 2026-02-12 13:26:19 +00:00
fix(ui): Inconsistent time values in UI (#1452)
* fix(ui): Truncate displayed time values * refactor(ui): Use util function * chore(ui): Regenerate static assets --------- Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
@@ -141,8 +141,8 @@ const formattedResponseTime = computed(() => {
|
||||
return `~${avgMs}ms`
|
||||
} else {
|
||||
// Show min-max range
|
||||
const minMs = Math.round(min)
|
||||
const maxMs = Math.round(max)
|
||||
const minMs = Math.trunc(min)
|
||||
const maxMs = Math.trunc(max)
|
||||
// If min and max are the same, show single value
|
||||
if (minMs === maxMs) {
|
||||
return `${minMs}ms`
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-1">
|
||||
<p class="text-xs text-muted-foreground">Success Rate: {{ successRate }}%</p>
|
||||
<p class="text-xs text-muted-foreground" v-if="averageDuration">{{ averageDuration }}ms avg</p>
|
||||
<p class="text-xs text-muted-foreground" v-if="averageDuration !== null">{{ averageDuration }}ms avg</p>
|
||||
</div>
|
||||
<div class="flex gap-0.5">
|
||||
<div
|
||||
@@ -126,7 +126,7 @@ const averageDuration = computed(() => {
|
||||
|
||||
const total = props.suite.results.reduce((sum, r) => sum + (r.duration || 0), 0)
|
||||
// Convert nanoseconds to milliseconds
|
||||
return Math.round((total / props.suite.results.length) / 1000000)
|
||||
return Math.trunc((total / props.suite.results.length) / 1000000)
|
||||
})
|
||||
|
||||
const oldestResultTime = computed(() => {
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
{{ endpoint.success ? '✓' : '✗' }}
|
||||
</span>
|
||||
<span class="truncate">{{ endpoint.name }}</span>
|
||||
<span class="text-muted-foreground">({{ (endpoint.duration / 1000000).toFixed(0) }}ms)</span>
|
||||
<span class="text-muted-foreground">({{ Math.trunc(endpoint.duration / 1000000) }}ms)</span>
|
||||
</div>
|
||||
<div v-if="result.endpointResults.length > 5" class="text-xs text-muted-foreground">
|
||||
... and {{ result.endpointResults.length - 5 }} more
|
||||
@@ -60,7 +60,7 @@
|
||||
{{ isSuiteResult ? 'Total Duration' : 'Response Time' }}
|
||||
</div>
|
||||
<div class="font-mono text-xs">
|
||||
{{ isSuiteResult ? (result.duration / 1000000).toFixed(0) : (result.duration / 1000000).toFixed(0) }}ms
|
||||
{{ Math.trunc(result.duration / 1000000) }}ms
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export const formatDuration = (duration) => {
|
||||
const durationMs = duration / 1000000
|
||||
|
||||
if (durationMs < 1000) {
|
||||
return `${durationMs.toFixed(0)}ms`
|
||||
return `${Math.trunc(durationMs)}ms`
|
||||
} else {
|
||||
return `${(durationMs / 1000).toFixed(2)}s`
|
||||
}
|
||||
|
||||
@@ -281,8 +281,8 @@ const pageResponseTimeRange = computed(() => {
|
||||
}
|
||||
|
||||
if (!hasData) return 'N/A'
|
||||
const minMs = Math.round(min / 1000000)
|
||||
const maxMs = Math.round(max / 1000000)
|
||||
const minMs = Math.trunc(min / 1000000)
|
||||
const maxMs = Math.trunc(max / 1000000)
|
||||
// If min and max are the same, show single value
|
||||
if (minMs === maxMs) {
|
||||
return `${minMs}ms`
|
||||
|
||||
@@ -153,6 +153,7 @@ import StepDetailsModal from '@/components/StepDetailsModal.vue'
|
||||
import Settings from '@/components/Settings.vue'
|
||||
import Loading from '@/components/Loading.vue'
|
||||
import { generatePrettyTimeAgo } from '@/utils/time'
|
||||
import { formatDuration } from '@/utils/format'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -238,19 +239,6 @@ const formatTimestamp = (timestamp) => {
|
||||
return date.toLocaleString()
|
||||
}
|
||||
|
||||
const formatDuration = (duration) => {
|
||||
if (!duration && duration !== 0) return 'N/A'
|
||||
|
||||
// Convert nanoseconds to milliseconds
|
||||
const durationMs = duration / 1000000
|
||||
|
||||
if (durationMs < 1000) {
|
||||
return `${durationMs.toFixed(0)}ms`
|
||||
} else {
|
||||
return `${(durationMs / 1000).toFixed(2)}s`
|
||||
}
|
||||
}
|
||||
|
||||
const calculateSuccessRate = (result) => {
|
||||
if (!result || !result.endpointResults || result.endpointResults.length === 0) {
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user