-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix uptime & ping badge duration #4850
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
About the screenshots, I am bit unsure which are before and wich are after the Pr. Could you clairify this?
See comments below
server/routers/api-router.js
Outdated
@@ -253,7 +249,7 @@ router.get("/api/badge/:id/uptime/:duration?", cache("5 minutes"), async (reques | |||
badgeValues.color = badgeConstants.naColor; | |||
} else { | |||
const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(requestedMonitorId); | |||
const uptime = overrideValue ?? uptimeCalculator.getDataByDuration(requestedDuration).uptime; | |||
const uptime = overrideValue ?? uptimeCalculator.getDataByDuration(`${requestedDuration}h`).uptime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this back up.
Currently, I don't think you are handling this correctly.
Think about cases where I supply 30d
=> this is now handled as 30dh
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, BadgeGeneratorDialog
does not support selecting time units. And I mistakenly thought that all durations would be treated as hour
. For backward compatibility reasons, I will reconsider this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have not yet looked deeply at that part of the UI.
Related #4500
c9088e8
to
977ff73
Compare
@CommanderStorm Hi! PTAL |
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as advertised.
There are two semi-related issues (we can fix them in different PRs if you'd prefer, feedback on this would be appreciated):
Is it ready for merge?🤔 |
I am still wating for feedback on these ^^ |
Sorry for my oversight, I think that it would be better if we fixed them in separate PRs. |
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Fixes uptime & ping badge duration not working when generate badge.
Now if you use input
25
as duration , you will get an error badge.Unfortunately, it still can't implement displaying
Uptime(30d)
after I fixed this. I think #2808 may be a good solution for this.Btw, It seems that there is a
label
variable inBadgeGeneratorDialog
that is not used.uptime-kuma/src/components/BadgeGeneratorDialog.vue
Lines 29 to 32 in bc25b71
Also,
labelSuffix
seems to be designed only for default label. And I don't know the purpose of this design.🤔uptime-kuma/server/routers/api-router.js
Lines 266 to 269 in bc25b71
Type of change
Please delete any options that are not relevant.
Checklist
Screenshots (if any)