Skip to content
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

Merged
merged 8 commits into from
Jul 4, 2024
Merged

Conversation

ZhaoQi99
Copy link
Contributor

@ZhaoQi99 ZhaoQi99 commented Jun 12, 2024

⚠️⚠️⚠️ 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

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 in BadgeGeneratorDialog that is not used.

<div v-if=" (parameters[badge.type || 'null'] || [] ).includes('label') " class="mb-3">
<label for="label" class="form-label">{{ $t("Badge Label") }}</label>
<input id="label" v-model="badge.label" type="text" class="form-control">
</div>

Also,labelSuffix seems to be designed only for default label. And I don't know the purpose of this design.🤔

badgeValues.label = filterAndJoin([
labelPrefix,
label ?? `Uptime (${requestedDuration}${labelSuffix})`,
]);

Type of change

Please delete any options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

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)

Header after
image imageimage

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.

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/uptime-calculator.js Outdated Show resolved Hide resolved
server/routers/api-router.js Show resolved Hide resolved
@@ -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;
Copy link
Collaborator

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..

Copy link
Contributor Author

@ZhaoQi99 ZhaoQi99 Jun 12, 2024

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.

Copy link
Collaborator

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

server/uptime-calculator.js Outdated Show resolved Hide resolved
@CommanderStorm CommanderStorm added area:core issues describing changes to the core of uptime kuma needs:work this PR needs work labels Jun 12, 2024
@CommanderStorm CommanderStorm added this to the 2.0.0 milestone Jun 12, 2024
@ZhaoQi99
Copy link
Contributor Author

Hi,

About the screenshots, I am bit unsure which are before and wich are after the Pr. Could you clairify this?

See comments below

Hi! Now it can't generate badge correctly.
image

And both of two screenshots are the results after PR.

@CommanderStorm CommanderStorm added the releaseblocker blocking bugs encountered with a new release label Jun 12, 2024
@ZhaoQi99 ZhaoQi99 changed the title Fix status & ping badge duration Fix uptime & ping badge duration Jun 13, 2024
CommanderStorm

This comment was marked as resolved.

@ZhaoQi99
Copy link
Contributor Author

@CommanderStorm Hi! PTAL

ZhaoQi99 and others added 7 commits June 20, 2024 10:50
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>
@CommanderStorm CommanderStorm added needs:review this PR needs a review by maintainers or other community members and removed needs:work this PR needs work labels Jun 24, 2024
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.

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):

  • The default labelSuffix does not make huge sense anymore
    image
  • The frontend badge generator does not allow specifiying the suffixes. This means that things like /api/badge/1/uptime/6666 get rejected because the hours is larger than 1400

@CommanderStorm CommanderStorm removed the needs:review this PR needs a review by maintainers or other community members label Jun 29, 2024
@ZhaoQi99
Copy link
Contributor Author

ZhaoQi99 commented Jul 4, 2024

Is it ready for merge?🤔

@CommanderStorm
Copy link
Collaborator

There are two semi-related issues (we can fix them in different PRs if you'd prefer, feedback on this would be appreciated)

I am still wating for feedback on these ^^

@ZhaoQi99
Copy link
Contributor Author

ZhaoQi99 commented Jul 4, 2024

There are two semi-related issues (we can fix them in different PRs if you'd prefer, feedback on this would be appreciated)

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.

@CommanderStorm CommanderStorm merged commit 1a5a1a6 into louislam:master Jul 4, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core issues describing changes to the core of uptime kuma releaseblocker blocking bugs encountered with a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants