mirror of
https://github.com/ViViDboarder/bitwarden_rs.git
synced 2024-11-22 05:06:37 +00:00
Fixed wrong status if there is an update.
- Checking the sha hash first if this is also in the server version. - Added a badge to show if you are on a branched build.
This commit is contained in:
parent
fac3cb687d
commit
325691e588
@ -9,6 +9,7 @@
|
|||||||
<dt class="col-sm-5">Server Installed
|
<dt class="col-sm-5">Server Installed
|
||||||
<span class="badge badge-success d-none" id="server-success" title="Latest version is installed.">Ok</span>
|
<span class="badge badge-success d-none" id="server-success" title="Latest version is installed.">Ok</span>
|
||||||
<span class="badge badge-warning d-none" id="server-warning" title="There seems to be an update available.">Update</span>
|
<span class="badge badge-warning d-none" id="server-warning" title="There seems to be an update available.">Update</span>
|
||||||
|
<span class="badge badge-info d-none" id="server-branch" title="This is a branched version.">Branched</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
<span id="server-installed">{{version}}</span>
|
<span id="server-installed">{{version}}</span>
|
||||||
@ -66,7 +67,7 @@
|
|||||||
(() => {
|
(() => {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
const year = d.getUTCFullYear();
|
const year = d.getUTCFullYear();
|
||||||
const month = String((d.getUTCMonth()+1)).padStart(2, '0');
|
const month = String(d.getUTCMonth()+1).padStart(2, '0');
|
||||||
const day = String(d.getUTCDate()).padStart(2, '0');
|
const day = String(d.getUTCDate()).padStart(2, '0');
|
||||||
const hour = String(d.getUTCHours()).padStart(2, '0');
|
const hour = String(d.getUTCHours()).padStart(2, '0');
|
||||||
const minute = String(d.getUTCMinutes()).padStart(2, '0');
|
const minute = String(d.getUTCMinutes()).padStart(2, '0');
|
||||||
@ -92,27 +93,57 @@
|
|||||||
|
|
||||||
let serverInstalled = document.getElementById('server-installed').innerText;
|
let serverInstalled = document.getElementById('server-installed').innerText;
|
||||||
let serverLatest = document.getElementById('server-latest').innerText;
|
let serverLatest = document.getElementById('server-latest').innerText;
|
||||||
if (serverInstalled.indexOf('-') > -1 && serverLatest !== '-') {
|
let serverLatestCommit = document.getElementById('server-latest-commit').innerText.replace('-', '');
|
||||||
|
if (serverInstalled.indexOf('-') !== -1 && serverLatest !== '-' && serverLatestCommit !== '-') {
|
||||||
document.getElementById('server-latest-commit').classList.remove('d-none');
|
document.getElementById('server-latest-commit').classList.remove('d-none');
|
||||||
serverLatest += document.getElementById('server-latest-commit').innerText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const webInstalled = document.getElementById('web-installed').innerText;
|
const webInstalled = document.getElementById('web-installed').innerText;
|
||||||
const webLatest = document.getElementById('web-latest').innerText;
|
const webLatest = document.getElementById('web-latest').innerText;
|
||||||
|
|
||||||
checkVersions('server', serverInstalled, serverLatest);
|
checkVersions('server', serverInstalled, serverLatest, serverLatestCommit);
|
||||||
checkVersions('web', webInstalled, webLatest);
|
checkVersions('web', webInstalled, webLatest);
|
||||||
|
|
||||||
function checkVersions(platform, installed, latest) {
|
function checkVersions(platform, installed, latest, commit=null) {
|
||||||
if (installed === '-' || latest === '-') {
|
if (installed === '-' || latest === '-') {
|
||||||
document.getElementById(platform + '-failed').classList.remove('d-none');
|
document.getElementById(platform + '-failed').classList.remove('d-none');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installed !== latest) {
|
// Only check basic versions, no commit revisions
|
||||||
document.getElementById(platform + '-warning').classList.remove('d-none');
|
if (commit === null || installed.indexOf('-') === -1) {
|
||||||
|
if (installed !== latest) {
|
||||||
|
document.getElementById(platform + '-warning').classList.remove('d-none');
|
||||||
|
} else {
|
||||||
|
document.getElementById(platform + '-success').classList.remove('d-none');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementById(platform + '-success').classList.remove('d-none');
|
// Check if this is a branched version.
|
||||||
|
const branchRegex = /(?:\s)\((.*?)\)/;
|
||||||
|
const branchMatch = installed.match(branchRegex);
|
||||||
|
if (branchMatch !== null) {
|
||||||
|
document.getElementById(platform + '-branch').classList.remove('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will remove branch info and check if there is a commit hash
|
||||||
|
const installedRegex = /(\d+\.\d+\.\d+)-(\w+)/;
|
||||||
|
const instMatch = installed.match(installedRegex);
|
||||||
|
|
||||||
|
// It could be that a new tagged version has the same commit hash.
|
||||||
|
// In this case the version is the same but only the number is different
|
||||||
|
if (instMatch !== null) {
|
||||||
|
if (instMatch[2] === commit) {
|
||||||
|
// The commit hashes are the same, so latest version is installed
|
||||||
|
document.getElementById(platform + '-success').classList.remove('d-none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (installed === latest) {
|
||||||
|
document.getElementById(platform + '-success').classList.remove('d-none');
|
||||||
|
} else {
|
||||||
|
document.getElementById(platform + '-warning').classList.remove('d-none');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user