-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add badges #1119
Add badges #1119
Conversation
@Saibamen Thx for your feedback! |
Quick Quesion: Will the Uptime Kuma API support all the url parameters from |
Shouldn't be a problem, |
server/config.js
Outdated
module.exports = { | ||
args, | ||
demoMode | ||
demoMode, | ||
badgeConstants |
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.
badgeConstants | |
badgeConstants, |
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.
Is a dangling comma sth you would like to see everywhere ( multiline )?
I was trying to stick to the current code style ... and will adjust my code :)
server/routers/api-router.js
Outdated
downLabel = "Down", | ||
upColor = badgeConstants.defaultUpColor, | ||
downColor = badgeConstants.defaultDownColor, | ||
style = "flat", |
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.
style = "flat",
is repeated 3 times in this file
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.
Well, there are several code blocks that share similarities / repeat themselves.
Would you like to see a constant here as well or a more sophisticated routing approach in which 'ping' and 'uptime' share a route? Since style
is a query parameter it has to be repeated in every 'badge'-route.
Really nice! However, since monitors could be private, granting a permission is needed. My idea would be that badges could be generated or revoked on demand. |
@chakflying Thanks for your feedback!
What about a checkbox on the monitors settings page, enabling badges or, more general, enabling public availability. This could effect metrics as well, since those are bound to the status page as well ( afaik ) and could / would be overridden once the monitor appears on the status page. |
Co-authored-by: Adam Stachowicz <[email protected]>
Co-authored-by: Adam Stachowicz <[email protected]>
Co-authored-by: Adam Stachowicz <[email protected]>
Co-authored-by: Adam Stachowicz <[email protected]>
Co-authored-by: Adam Stachowicz <[email protected]>
How would you like to progress with this PR? |
# Conflicts: # server/util-server.js
Thank you so much, it is so solid. My next steps will be adding your description in the wiki. For the maybe next next release, badge gui generator should be added into status page editor, so users don't need to check the wiki. |
Great Idea! Maybe I can help. |
Great functionality! @jensneuber Мaybe the URL example for 30 days uptime percentage that is shown in the example:
should be:
|
You are absolutely right! Thanks for noticing and letting me know |
Hi guys, I'm not sure to understand how this works... Is the badge supposed to be update over time to reflect what's on the dashboard? |
This is expected behavior. A badge is an image and includes no further logic to update. |
Oh ok |
How do you change the status pages to show the badges in the UI? I see the settings option next to the monitor, and then the badge generator, however I cannot seem to find a way to make the badge show instead of the default percentage. |
There is no such option. The badges are designed to be displayed externally. |
Okay I got it, thanks. |
Great one. Is it a Bug or by design, that those badges don't work with Groups? I only see 'N/A' in the label when trying to access the status of a monitor group. |
Can we get an option that returns a png instead of html? |
You can display it in the status page description or footer using markdown. For example : |
* migrate badge documentation from pull into wiki from this pull louislam/uptime-kuma#1119 * Update badges documentation resolve comments from CommanderStorm * Update Badge.md * Apply suggestions from code review Co-authored-by: Frank Elsinga <[email protected]> * delete counting badges Co-authored-by: Frank Elsinga <[email protected]> * Tip Open Badge Generator Co-authored-by: Frank Elsinga <[email protected]> * Delete Screenshots * Reorder whole content * Delete Example Image * Update Badge.md delete ref pull Co-authored-by: Frank Elsinga <[email protected]> * Update Badge.md delete headline open Badge Generator Co-authored-by: Frank Elsinga <[email protected]> * Update Badge.md Change Sentence about the predefined or custom color Co-authored-by: Frank Elsinga <[email protected]> * Update Badge.mf Change the appearance of all examples Co-authored-by: Frank Elsinga <[email protected]> * Update Badge.md delete file inline Table of content Co-authored-by: Frank Elsinga <[email protected]> * Update Badge.md Correction of the tables with examples * Update Badge.md Correct Markdown Typo Co-authored-by: Frank Elsinga <[email protected]> --------- Co-authored-by: Frank Elsinga <[email protected]>
Description
Status, ping and uptime badges, generated in node-js, no internet access required (based on badge-maker aka. shields.io)
This PR adds three API endpoints returning a SVG graphic for a given (public) monitor:
Status
<kuma-url>/api/badge/:monitorID/status
e.g.<kuma-url>/api/badge/1/status
returning sth like:Ping
<kuma-url>/api/badge/:monitorID/ping/:duration
e.g.<kuma-url>/api/badge/1/ping
returning sth like:Uptime
<kuma-url>/api/badge/:monitorID/uptime/:duration
e.g.<kuma-url>/api/badge/1/uptime/24
returning sth like:Status badge
There are options to customize the status badge's appearance:
upLabel = Up
,downLabel = Down
,upColor
,downColor
:<kuma-url>/api/badge/<monitorId>/status?upLabel=<upLabel>&downLabel=<downLabel>
<kuma-url>/api/badge/<monitorId>/status?upColor=white&downColor=black
Ping and uptime badge
There are options to customize the ping and uptime badge's text:
labelPrefix
,label
,labelSuffix = h
,prefix
,suffix = ms / %
,color
,labelColor
:<kuma-url>/api/badge/<monitorId>/ping/24?labelPrefix=<labelPrefix>&label=<label>&labelSuffix=<labelSuffix>&prefix=<prefix>&suffix=<suffix>
<kuma-url>/api/badge/<monitorId>/uptime/24?labelPrefix=<labelPrefix>&label=<label>&labelSuffix=<labelSuffix>&prefix=<prefix>&suffix=<suffix>
The given time interval has to be in 'hours', but customizing options allow for a different display:
<kuma-url>/api/badge/1/uptime/720?label=30&labelSuffix=d
The default uptime badge's color is based on the uptime percentage:
but can be overwritten with predefined color or any other color in HEX code:
See https://shields.io/#colors for predefined colors.
Different badge styles as defined by https://shields.io/#styles are also supported. (thx @throwabird / comment )
<kuma-url>/api/badge/<monitorId>/status?style=flat-square
Use of the following options to enable them:
flat
(default),flat-square
,plastic
,for-the-badge
,social
:Type of change
Checklist
Screenshots (if any)