Skip to content

Badge generator for status pages #5572

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

hiagodotme
Copy link

@hiagodotme hiagodotme commented Jan 25, 2025

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
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]:

  • I have read and understand the pull request rules.

Description

I implemented a new feature to generate statusPage badges as discussed in issue #5507

Type of change

Please delete any options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

01_button_generator

02_generator_form

  1. Badge style to be generated
  2. Texts for each situation, it is better to let each user choose their text as it may be used in different places and they may prefer to change the terms.
  3. Image preview (in current page status)

@louislam @CommanderStorm 🚀

@cyril59310
Copy link
Contributor

You cannot edit other language file. Only the en.json file can be modified to avoid conflicts with the Weblate translation tool.

see the contribution guide: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#translations

@hiagodotme
Copy link
Author

Você não pode editar outro arquivo de idioma. Somente o en.jsonarquivo pode ser modificado para evitar conflitos com a ferramenta de tradução Weblate.

veja o guia de contribuição: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#translations

@cyril59310 I translated pt-BR.json because it is my native language, I misinterpreted this part of the guide line.

Is it possible to revert this by maintaining this pull request?

@hiagodotme
Copy link
Author

hiagodotme commented Jan 25, 2025

@cyril59310 I reverted the pt-BR.json file to the last authorized commit on master using the command below.

But now I believe it is following all the guidelines.

git checkout 489b73a7a638b6bc248e79800257808a19b15253 -- src/lang/pt-BR.json

@CommanderStorm CommanderStorm added the pr:needs review this PR needs a review by maintainers or other community members label Feb 16, 2025
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long wait-time.
This is a larger PR and it took me a longer time to review.

Was on my backlog for longer but got pushed back by smaller simpler to digest PRs.

Comment on lines +14 to +20
<label for="badge-builder-badge-style" class="form-label">{{ $t("Badge Style") }}</label>
<select id="badge-builder-badge-style" v-model="config.badgeStyle" class="form-select">
<option value="flat">Flat</option>
<option value="flat-square">Flat Square</option>
<option value="for-the-badge">For The Badge</option>
<option value="plastic">Plastic</option>
<option value="social">Social</option>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make sure that all values that are english are translatable ($t) and are in the translation file en.json.

If they are not, our kickass team of translators won't be able to translate them

response.set("Content-Type", "image/svg+xml");
response.send(await StatusPage.renderSVG(slug, config, statusPage));
} else {
response.status(404).send(await StatusPage.renderSVG(slug, config, null));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In cases of 404s, aborting early is usually a good call.

aborting here also has downstream effects in the code of renderSVG and upstream in the html

Suggested change
response.status(404).send(await StatusPage.renderSVG(slug, config, null));
response.status(404).send(UptimeKumaServer.getInstance().indexHTML);

Comment on lines +24 to +31
<div class="mb-3">
<label for="badge-not-found-text" class="form-label">{{ $t("Return to not found") }}</label>
<input
id="badge-not-found-text" v-model="config.notFoundText" type="text"
class="form-control"
>
</div>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is nessesary, please remove it here and in all references to notFoundText or Return to not found

Suggested change
<div class="mb-3">
<label for="badge-not-found-text" class="form-label">{{ $t("Return to not found") }}</label>
<input
id="badge-not-found-text" v-model="config.notFoundText" type="text"
class="form-control"
>
</div>

Comment on lines +111 to +116

computed: {
},

watch: {
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not nessesary

Suggested change
computed: {
},
watch: {
},

@@ -19,7 +19,10 @@
<!-- Description -->
<div class="my-3">
<label for="description" class="form-label">{{ $t("Description") }}</label>
<textarea id="description" v-model="config.description" class="form-control" data-testid="description-input"></textarea>
<textarea
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove all accidental changes to this file.
It is a large enough PR as is.

Comment on lines +226 to +229
// calculate RSS feed description
let status = StatusPage.overallStatus(heartbeats);

switch (status) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a status page and not a description. lets inline

Suggested change
// calculate RSS feed description
let status = StatusPage.overallStatus(heartbeats);
switch (status) {
switch (StatusPage.overallStatus(heartbeats)) {


<div class="modal-footer">
<button type="button" class="btn btn-primary" @click="copyImageURL()">
<!-- <div v-if="processing" class="spinner-border spinner-border-sm me-1"></div> -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<!-- <div v-if="processing" class="spinner-border spinner-border-sm me-1"></div> -->

@@ -0,0 +1,152 @@
<template>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this component StatusPageSVGBadgeDialog.vue to reflect the tight focus of this component.

</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" />
</div>
<div class="modal-body">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an info alert here to inform users that

Note that adding badges at a monitor level is possible too if they are on any public status page

switch (status) {
case STATUS_PAGE_ALL_DOWN:
return makeBadge({
message: userConfig.allDownText ?? "all down",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please stick to the options we defined on https://github.com/louislam/uptime-kuma/wiki/Badge where possible.

Different options for different apis is okay, but explaining this difference is a bit too confusing imo.

@CommanderStorm CommanderStorm added pr:please address review comments this PR needs a bit more work to be mergable and removed pr:needs review this PR needs a review by maintainers or other community members labels Mar 25, 2025
@CommanderStorm CommanderStorm added this to the 2.0.0-beta.4 milestone Jun 29, 2025
@Ionys320
Copy link
Contributor

@CommanderStorm If this PR brings a new feature, it may not be necessary blocking 2.0.0-beta4. May this be in 2.1.0 instead?

@CommanderStorm
Copy link
Collaborator

True, I was a bit sloppy in #5177.
I distinctly remember another PR doing work in this area though.

@CommanderStorm CommanderStorm modified the milestones: 2.0.0-beta.4, 2.1.0 Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:resolve-merge-conflict pr:please address review comments this PR needs a bit more work to be mergable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants