-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first attempt to version checker
- Loading branch information
Benedith Mulongo
committed
Jul 5, 2024
1 parent
3f1eea7
commit 3f17306
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,39 @@ | ||
import {data} from '/dist/version.js' | ||
|
||
async function getData() { | ||
const url = `${process.env.API_URL}/api/v1.0/system/version`; | ||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error(`Response status: ${response.status}`); | ||
} | ||
const json = await response.json(); | ||
return json.data; | ||
} | ||
|
||
async function gatherData() { | ||
const version = data.version; | ||
const dataFrGit = await getData(); | ||
const gitVersion = dataFrGit.version; | ||
const gitVersionSummary = dataFrGit.git_version; | ||
console.log("Data:") | ||
console.log(version) | ||
|
||
console.log("dataFrGit:") | ||
console.log(dataFrGit) | ||
console.log(gitVersion) | ||
console.log(gitVersionSummary) | ||
console.log(gitVersionSummary.includes(version)) | ||
if(!gitVersionSummary.includes(version)) { | ||
window.dispatchEvent(new CustomEvent('versionchanged', { detail: version })); | ||
} | ||
} | ||
|
||
function start() { | ||
setInterval(gatherData, 8000); | ||
} | ||
|
||
window.addEventListener('versionchanged', function (e) { | ||
alert('Unmacthed version. New UI version available!'); | ||
}); | ||
|
||
window.addEventListener('load', start); |