-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Available upgrade notification #4906
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
990ba28
Update SiteFooter.tsx
sopex f1d7203
v2
sopex b434bba
remove hardcoded version number
sopex b6dbb68
Update SiteFooter.tsx
sopex ae5faa7
backend test
sopex dc03ad8
minimal changes
sopex 87eef10
remove useCallback logic
sopex 2d6252d
https.get
sopex 15394c6
trigger Jenkins that failed due to internet connection problems
sopex 963125f
Space scandal retified (hopefully)
7heMech b4fd242
remove 1
sopex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import express from "express"; | ||
| import { debug, express as logger } from "../logger.js"; | ||
| import pjson from "../package.json" with { type: "json" }; | ||
|
|
||
| const router = express.Router({ | ||
| caseSensitive: true, | ||
| strict: true, | ||
| mergeParams: true, | ||
| }); | ||
|
|
||
| /** | ||
| * /api/version/check | ||
| */ | ||
| router | ||
| .route("/check") | ||
| .options((_, res) => { | ||
| res.sendStatus(204); | ||
| }) | ||
|
|
||
| /** | ||
| * GET /api/version/check | ||
| * | ||
| * Check for available updates | ||
| */ | ||
| .get(async (req, res, next) => { | ||
| try { | ||
| const response = await fetch( | ||
| "https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest" | ||
| ); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`GitHub API returned ${response.status}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| const latestVersion = data.tag_name; | ||
|
|
||
| const version = pjson.version.split("-").shift().split("."); | ||
| const currentVersion = `v${version[0]}.${version[1]}.${version[2]}`; | ||
|
|
||
| res.status(200).send({ | ||
| current: currentVersion, | ||
| latest: latestVersion, | ||
| updateAvailable: compareVersions(currentVersion, latestVersion), | ||
| }); | ||
| } catch (error) { | ||
| debug(logger, `${req.method.toUpperCase()} ${req.path}: ${error}`); | ||
| res.status(200).send({ | ||
| current: null, | ||
| latest: null, | ||
| updateAvailable: false, | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Compare two version strings | ||
| * | ||
| */ | ||
| function compareVersions(current, latest) { | ||
| const cleanCurrent = current.replace(/^v/, ""); | ||
| const cleanLatest = latest.replace(/^v/, ""); | ||
|
|
||
| const currentParts = cleanCurrent.split(".").map(Number); | ||
| const latestParts = cleanLatest.split(".").map(Number); | ||
|
|
||
| for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) { | ||
| const curr = currentParts[i] || 0; | ||
| const lat = latestParts[i] || 0; | ||
|
|
||
| if (lat > curr) return true; | ||
| if (lat < curr) return false; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| export default router; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,99 @@ | ||
| import { useEffect, useState } from "react"; | ||
| import { useHealth } from "src/hooks"; | ||
| import { T } from "src/locale"; | ||
|
|
||
| export function SiteFooter() { | ||
| const health = useHealth(); | ||
| const health = useHealth(); | ||
| const [latestVersion, setLatestVersion] = useState<string | null>(null); | ||
| const [isNewVersionAvailable, setIsNewVersionAvailable] = useState(false); | ||
|
|
||
| const getVersion = () => { | ||
| if (!health.data) { | ||
| return ""; | ||
| } | ||
| const v = health.data.version; | ||
| return `v${v.major}.${v.minor}.${v.revision}`; | ||
| }; | ||
| const getVersion = () => { | ||
| if (!health.data) { | ||
| return ""; | ||
| } | ||
| const v = health.data.version; | ||
| return `v${v.major}.${v.minor}.${v.revision}`; | ||
| }; | ||
|
|
||
| return ( | ||
| <footer className="footer d-print-none py-3"> | ||
| <div className="container-xl"> | ||
| <div className="row text-center align-items-center flex-row-reverse"> | ||
| <div className="col-lg-auto ms-lg-auto"> | ||
| <ul className="list-inline list-inline-dots mb-0"> | ||
| <li className="list-inline-item"> | ||
| <a | ||
| href="https://github.com/NginxProxyManager/nginx-proxy-manager" | ||
| target="_blank" | ||
| className="link-secondary" | ||
| rel="noopener" | ||
| > | ||
| <T id="footer.github-fork" /> | ||
| </a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| <div className="col-12 col-lg-auto mt-3 mt-lg-0"> | ||
| <ul className="list-inline list-inline-dots mb-0"> | ||
| <li className="list-inline-item"> | ||
| © 2025{" "} | ||
| <a href="https://jc21.com" rel="noreferrer" target="_blank" className="link-secondary"> | ||
| jc21.com | ||
| </a> | ||
| </li> | ||
| <li className="list-inline-item"> | ||
| Theme by{" "} | ||
| <a href="https://tabler.io" rel="noreferrer" target="_blank" className="link-secondary"> | ||
| Tabler | ||
| </a> | ||
| </li> | ||
| <li className="list-inline-item"> | ||
| <a | ||
| href={`https://github.com/NginxProxyManager/nginx-proxy-manager/releases/tag/${getVersion()}`} | ||
| className="link-secondary" | ||
| target="_blank" | ||
| rel="noopener" | ||
| > | ||
| {" "} | ||
| {getVersion()}{" "} | ||
| </a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </footer> | ||
| ); | ||
| } | ||
| useEffect(() => { | ||
| const checkForUpdates = async () => { | ||
| try { | ||
| const response = await fetch("/api/version/check"); | ||
| if (response.ok) { | ||
| const data = await response.json(); | ||
| setLatestVersion(data.latest); | ||
| setIsNewVersionAvailable(data.updateAvailable); | ||
| } | ||
| } catch (error) { | ||
| console.debug("Could not check for updates:", error); | ||
| } | ||
| }; | ||
|
|
||
| if (health.data) { | ||
| checkForUpdates(); | ||
| } | ||
| }, [health.data]); | ||
|
|
||
| return ( | ||
| <footer className="footer d-print-none py-3"> | ||
| <div className="container-xl"> | ||
| <div className="row text-center align-items-center flex-row-reverse"> | ||
| <div className="col-lg-auto ms-lg-auto"> | ||
| <ul className="list-inline list-inline-dots mb-0"> | ||
| <li className="list-inline-item"> | ||
| <a | ||
| href="https://github.com/NginxProxyManager/nginx-proxy-manager" | ||
| target="_blank" | ||
| className="link-secondary" | ||
| rel="noopener" | ||
| > | ||
| <T id="footer.github-fork" /> | ||
| </a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| <div className="col-12 col-lg-auto mt-3 mt-lg-0"> | ||
| <ul className="list-inline list-inline-dots mb-0"> | ||
| <li className="list-inline-item"> | ||
| © 2025{" "} | ||
| <a href="https://jc21.com" rel="noreferrer" target="_blank" className="link-secondary"> | ||
| jc21.com | ||
| </a> | ||
| </li> | ||
| <li className="list-inline-item"> | ||
| Theme by{" "} | ||
| <a href="https://tabler.io" rel="noreferrer" target="_blank" className="link-secondary"> | ||
| Tabler | ||
| </a> | ||
| </li> | ||
| <li className="list-inline-item"> | ||
| <a | ||
| href={`https://github.com/NginxProxyManager/nginx-proxy-manager/releases/tag/${getVersion()}`} | ||
| className="link-secondary" | ||
| target="_blank" | ||
| rel="noopener" | ||
| > | ||
| {" "} | ||
| {getVersion()}{" "} | ||
| </a> | ||
| </li> | ||
| {isNewVersionAvailable && latestVersion && ( | ||
| <li className="list-inline-item"> | ||
| <a | ||
| href={`https://github.com/NginxProxyManager/nginx-proxy-manager/releases/tag/${latestVersion}`} | ||
| className="link-warning fw-bold" | ||
| target="_blank" | ||
| rel="noopener" | ||
| title={`New version ${latestVersion} is available`} | ||
| > | ||
| Update Available: ({latestVersion}) | ||
| </a> | ||
| </li> | ||
| )} | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </footer> | ||
| ); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.