feat: add ping text in heartbeat tooltip#7205
feat: add ping text in heartbeat tooltip#7205lehuutrung1412 wants to merge 2 commits intolouislam:masterfrom
Conversation
|
Hello and thanks for lending a paw to Uptime Kuma! 🐻👋 |
|
|
||
| .tooltip-time { | ||
| color: #d1d5db; | ||
| color: $secondary-text; |
There was a problem hiding this comment.
I have updated this to use the defined color and maintain consistency for both ping and timestamp
silversword411
left a comment
There was a problem hiding this comment.
Small simple change, and a fix on a hard coded style in addition to the addition.
LGTM!
|
Hi @CommanderStorm, could you please help me review this PR? Thank you! |
|
I will get back to reviewing PRs when my thesis is done. |
|
pingText() {
if (!this.content || this.content.ping == null) {
return null;
}
return Math.round(this.content.ping) + "ms";
} |
SweetSophia
left a comment
There was a problem hiding this comment.
Thanks for the clean implementation! A few things worth addressing:
-
Bug (re-echoing @smarshall-rightside's comment):
pingText()uses!this.content.pingwhich treatsping === 0as falsy. A0msping is valid (localhost, sub-ms responses). Should usethis.content.ping == nullinstead. This was flagged on Apr 5 but doesn't appear to have been addressed yet. -
"ms" not internationalized:
pingText()hardcodes"ms". The codebase uses$t()for all user-visible strings — this should use an i18n key for consistency and to allow locale-specific formatting (e.g. spacing like"0 ms"). -
DOWN heartbeats show ping: The
v-if="pingText"shows ping for all heartbeat types including DOWN. When a monitor times out,pingcan reflect the full timeout duration (e.g.30000ms). Showing this next to "DOWN" could mislead users. Consider only showing ping for UP heartbeats, or differentiating the label. -
Minor style:
.tooltip-pingsetsfont-weight: 500while the adjacent.tooltip-timeinherits400. Same font-size, same color — the weight difference is subtle enough to look unintentional. They should probably match.
| @@ -107,6 +108,13 @@ export default { | |||
There was a problem hiding this comment.
This falsy check hides valid ping === 0 values (localhost monitors, sub-ms responses). As @smarshall-rightside noted, this should be:
pingText() {
if (!this.content || this.content.ping == null) {
return null;
}
return Math.round(this.content.ping) + "ms";
}ping is treated as valid when 0 elsewhere in the codebase (e.g. Details.vue uses ping || ping === 0).
| @@ -107,6 +108,13 @@ export default { | |||
There was a problem hiding this comment.
The "ms" suffix is hardcoded rather than internationalized. The codebase uses $t() for all user-visible strings. Consider adding an i18n key (e.g. $t('pingMs', [Math.round(this.content.ping)])) so locales can format the unit with proper spacing or different conventions.
| <div class="tooltip-status" :class="statusClass"> | ||
| {{ statusText }} | ||
| </div> | ||
| <div v-if="pingText" class="tooltip-ping">{{ pingText }}</div> |
There was a problem hiding this comment.
Showing ping for DOWN heartbeats could mislead users. When a monitor times out, ping may contain the full timeout duration (e.g. 30000ms). Displaying that next to "DOWN" makes it look like a latency measurement when it's actually a connection failure.
Consider guarding with content.status === UP (import UP from util.ts — already imported in this component), or at minimum labeling it differently for non-UP states.
| @@ -107,6 +108,13 @@ export default { | |||
| } | |||
| return this.$root.datetime(this.content.time); | |||
There was a problem hiding this comment.
.tooltip-ping sets font-weight: 500 while the adjacent .tooltip-time has no font-weight (inherits 400). They share the same font-size: 13px and now the same color — the weight difference is subtle enough to look unintentional. Should these match?
Summary
In this pull request, the following changes are made:
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes
ping-text.mov
UPDOWN