Try fix: webui notify update not showing up
- commit
- c02e15bb744d8dca6483527d4fb611d892bd7473
- author
- bnema · · 2023-11-07 09:30 UTC
- parent
- cd460cf
- signature
- unsigned
1 file · +9 -7
M internal/webui/public/assets/js/custom.js +9 -7
| @@ -1,17 +1,23 @@ | |||
| 1 | 1 | function initializeVersionCheck() { | |
| 2 | - | const updateStrTemplate = | |
| 3 | - | "New version %VERSION% available, consider pulling the latest image"; | |
| 2 | + | const updateStrTemplate = "New version %VERSION% available, consider pulling the latest image"; | |
| 4 | 3 | ||
| 5 | 4 | const checkVersion = (versionData) => { | |
| 6 | 5 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | |
| 7 | 6 | const fetchedVersionNumber = versionData?.amd64?.name.match(/\d+\.\d+\.\d+/)?.[0]; | |
| 8 | 7 | ||
| 8 | + | if (!fetchedVersionNumber) { | |
| 9 | + | console.log("Dev mode detected, skipping version check."); | |
| 10 | + | return; | |
| 11 | + | } | |
| 12 | + | ||
| 9 | 13 | if (currentVersion !== fetchedVersionNumber) { | |
| 10 | 14 | const updateStr = updateStrTemplate.replace("%VERSION%", fetchedVersionNumber); | |
| 11 | 15 | console.log(updateStr); | |
| 12 | 16 | const updateElement = document.getElementById("update-available"); | |
| 13 | 17 | updateElement.title = updateStr; | |
| 14 | 18 | updateElement.removeAttribute("hidden"); | |
| 19 | + | updateElement.classList.remove("hidden"); // Remove the Tailwind `hidden` class | |
| 20 | + | updateElement.classList.add("block"); // Add the Tailwind `block` class | |
| 15 | 21 | } else { | |
| 16 | 22 | console.log("No new version. Current version is up-to-date:", currentVersion); | |
| 17 | 23 | } | |
| @@ -26,18 +32,14 @@ function initializeVersionCheck() { | |||
| 26 | 32 | ||
| 27 | 33 | const init = () => { | |
| 28 | 34 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | |
| 29 | - | ||
| 30 | - | // If currentVersion is empty, assume dev mode and do not fetch version info | |
| 31 | 35 | if (!currentVersion) { | |
| 32 | 36 | console.log("Dev mode detected, skipping version check."); | |
| 33 | 37 | return; | |
| 34 | 38 | } | |
| 35 | - | ||
| 36 | 39 | fetchVersionInfo(); | |
| 37 | 40 | }; | |
| 38 | 41 | ||
| 39 | 42 | init(); | |
| 40 | 43 | } | |
| 41 | 44 | ||
| 42 | - | // Ensure the document is fully loaded before running the script | |
| 43 | - | document.addEventListener('DOMContentLoaded', initializeVersionCheck);// switched to hyperscript for the most part⏎̸ | |
| 45 | + | document.addEventListener('DOMContentLoaded', initializeVersionCheck); | |
| @@ -1,17 +1,23 @@ | |||||
| 1 | function initializeVersionCheck() { | 1 | function initializeVersionCheck() { | ||
| 2 | - | const updateStrTemplate = | 2 | + | const updateStrTemplate = "New version %VERSION% available, consider pulling the latest image"; |
| 3 | - | "New version %VERSION% available, consider pulling the latest image"; | |||
| 4 | 3 | ||||
| 5 | const checkVersion = (versionData) => { | 4 | const checkVersion = (versionData) => { | ||
| 6 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | 5 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | ||
| 7 | const fetchedVersionNumber = versionData?.amd64?.name.match(/\d+\.\d+\.\d+/)?.[0]; | 6 | const fetchedVersionNumber = versionData?.amd64?.name.match(/\d+\.\d+\.\d+/)?.[0]; | ||
| 8 | 7 | ||||
| 8 | + | if (!fetchedVersionNumber) { | |||
| 9 | + | console.log("Dev mode detected, skipping version check."); | |||
| 10 | + | return; | |||
| 11 | + | } | |||
| 12 | + | ||||
| 9 | if (currentVersion !== fetchedVersionNumber) { | 13 | if (currentVersion !== fetchedVersionNumber) { | ||
| 10 | const updateStr = updateStrTemplate.replace("%VERSION%", fetchedVersionNumber); | 14 | const updateStr = updateStrTemplate.replace("%VERSION%", fetchedVersionNumber); | ||
| 11 | console.log(updateStr); | 15 | console.log(updateStr); | ||
| 12 | const updateElement = document.getElementById("update-available"); | 16 | const updateElement = document.getElementById("update-available"); | ||
| 13 | updateElement.title = updateStr; | 17 | updateElement.title = updateStr; | ||
| 14 | updateElement.removeAttribute("hidden"); | 18 | updateElement.removeAttribute("hidden"); | ||
| 19 | + | updateElement.classList.remove("hidden"); // Remove the Tailwind `hidden` class | |||
| 20 | + | updateElement.classList.add("block"); // Add the Tailwind `block` class | |||
| 15 | } else { | 21 | } else { | ||
| 16 | console.log("No new version. Current version is up-to-date:", currentVersion); | 22 | console.log("No new version. Current version is up-to-date:", currentVersion); | ||
| 17 | } | 23 | } | ||
| @@ -26,18 +32,14 @@ function initializeVersionCheck() { | |||||
| 26 | 32 | ||||
| 27 | const init = () => { | 33 | const init = () => { | ||
| 28 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | 34 | const currentVersion = document.getElementById("actual-version").textContent.trim(); | ||
| 29 | - | ||||
| 30 | - | // If currentVersion is empty, assume dev mode and do not fetch version info | |||
| 31 | if (!currentVersion) { | 35 | if (!currentVersion) { | ||
| 32 | console.log("Dev mode detected, skipping version check."); | 36 | console.log("Dev mode detected, skipping version check."); | ||
| 33 | return; | 37 | return; | ||
| 34 | } | 38 | } | ||
| 35 | - | ||||
| 36 | fetchVersionInfo(); | 39 | fetchVersionInfo(); | ||
| 37 | }; | 40 | }; | ||
| 38 | 41 | ||||
| 39 | init(); | 42 | init(); | ||
| 40 | } | 43 | } | ||
| 41 | 44 | ||||
| 42 | - | // Ensure the document is fully loaded before running the script | 45 | + | document.addEventListener('DOMContentLoaded', initializeVersionCheck); |
| 43 | - | document.addEventListener('DOMContentLoaded', initializeVersionCheck);// switched to hyperscript for the most part⏎̸ | |||