updated code logic to pic FW/App version from appversion instead of hard-coding in js/html/cpp files

This commit is contained in:
Shailen Sobhee 2026-03-30 22:41:08 +02:00
parent bb61a1703d
commit fe4aa83ed2
8 changed files with 78 additions and 155 deletions

View file

@ -1 +1 @@
2.4.8
2.5.0

View file

@ -8,9 +8,9 @@
<meta name="apple-mobile-web-app-title" content="ESPSomfy RTS App">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="main.css?v=2.4.8c" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.4.8c" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.4.8c" type="text/css" />
<link rel="stylesheet" href="main.css" type="text/css" />
<link rel="stylesheet" href="widgets.css" type="text/css" />
<link rel="stylesheet" href="icons.css" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<!-- iPad retina icon -->
@ -114,7 +114,7 @@
rel="apple-touch-startup-image">
<script type="text/javascript" src="index.js?v=2.4.8c"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div id="divContainer" class="container main" data-auth="false">

View file

@ -1267,9 +1267,27 @@ class Security {
}
var security = new Security();
// let appVersion = 'v0.0.0'; // Default placeholder
async function getAppVersion() {
try {
const response = await fetch('/appversion');
if (!response.ok) throw new Error('File not found');
const data = await response.text();
appVersion = `v${data.trim()}`;
console.log("Loaded Version:", appVersion);
// Trigger any UI updates here
} catch (error) {
console.error("Error loading App version:", error);
appVersion = 'v0.0.0'; // Default placeholder
}
return appVersion;
}
class General {
initialized = false;
appVersion = 'v2.4.8';
appVersion = getAppVersion();
reloadApp = false;
init() {
if (this.initialized) return;
@ -4815,3 +4833,15 @@ class Firmware {
}
var firmware = new Firmware();
window.addEventListener('load', async () => {
// 1. Initialize your main application logic
// await init();
// 2. Fetch and display the app version
appVersion = await getAppVersion();
const spanAppVersion = document.getElementById('spanAppVersion');
spanAppVersion.innerText = `${appVersion.trim()}`;
console.log("Application fully loaded and version updated.");
});