X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=web%2Findex.html;fp=web%2Findex.html;h=13aa53c6e4d44ae4222f7518133f942a0fb92d53;hb=51b6f39da5a5ded1042b627909a87e5b7681a54e;hp=e2a2e07d3c34c60dcdb243d8dc016a628ff26e49;hpb=4881477c649e2c10350319364086990c7b61130b;p=netdata.git diff --git a/web/index.html b/web/index.html index e2a2e07d..13aa53c6 100644 --- a/web/index.html +++ b/web/index.html @@ -2259,6 +2259,7 @@ // update the dashboard hostname document.getElementById('hostname').innerHTML = options.hostname; document.getElementById('hostname').href = NETDATA.serverDefault; + document.getElementById('netdataVersion').innerHTML = options.version; // update the dashboard title document.title = options.hostname + ' netdata dashboard'; @@ -2290,8 +2291,23 @@ document.getElementById('versionCheckLog').innerHTML = msg; } - function getNetdataVersion(callback) { - versionLog('Downloading installed version info from netdata...'); + function getNetdataCommitIdFromVersion() { + var s = options.version.split('-'); + + if(s.length !== 3) return null; + if(s[2][0] == 'g') { + var v = s[2].split('_')[0].substring(1, 8); + if(v.length === 7) { + versionLog('Installed git commit id of netdata is ' + v); + document.getElementById('netdataCommitId').innerHTML = v; + return v; + } + } + return null; + } + + function getNetdataCommitId(force, callback) { + versionLog('Downloading installed git commit id from netdata...'); $.ajax({ url: 'version.txt', @@ -2302,23 +2318,31 @@ .done(function(data) { data = data.replace(/(\r\n|\n|\r| |\t)/gm,""); if(data.length !== 40) { - versionLog('Received version string is invalid.'); - callback(null); + var c = getNetdataCommitIdFromVersion(); + if(c === null) versionLog('Cannot find the git commit id of netdata.'); + callback(c); } else { - versionLog('Installed version of netdata is ' + data); - document.getElementById('netdataVersion').innerHTML = data; + versionLog('Installed git commit id of netdata is ' + data); + document.getElementById('netdataCommitId').innerHTML = data.substring(0, 7); callback(data); } }) .fail(function() { - versionLog('Failed to download installed version info from netdata!'); - callback(null); + versionLog('Failed to download installed git commit id from netdata!'); + + if(force === true) { + var c = getNetdataCommitIdFromVersion(); + if(c === null) versionLog('Cannot find the git commit id of netdata.'); + callback(c); + } + else + callback(null); }); } function getGithubLatestCommit(callback) { - versionLog('Downloading latest version info from github...'); + versionLog('Downloading latest git commit id info from github...'); $.ajax({ url: 'https://api.github.com/repos/firehol/netdata/commits', @@ -2326,17 +2350,17 @@ cache: false }) .done(function(data) { - versionLog('Latest version info from github is ' + data[0].sha); + versionLog('Latest git commit id from github is ' + data[0].sha); callback(data[0].sha); }) .fail(function() { - versionLog('Failed to download installed version info from github!'); + versionLog('Failed to download installed git commit id from github!'); callback(null); }); } - function checkForUpdate(callback) { - getNetdataVersion(function(sha1) { + function checkForUpdate(force, callback) { + getNetdataCommitId(force, function(sha1) { if(sha1 === null) callback(null, null); getGithubLatestCommit(function(sha2) { @@ -2366,26 +2390,26 @@ } } - checkForUpdate(function(sha1, sha2) { + checkForUpdate(force, function(sha1, sha2) { var save = false; if(sha1 === null) { save = false; - versionLog('

Failed to get your netdata version!

You can always get the latest version of netdata from its github page.

'); + versionLog('

Failed to get your netdata git commit id!

You can always get the latest netdata from its github page.

'); } else if(sha2 === null) { save = false; - versionLog('

Failed to get the latest version from github.

You can always get the latest version of netdata from its github page.

'); + versionLog('

Failed to get the latest git commit id from github.

You can always get the latest netdata from its github page.

'); } else if(sha1 === sha2) { save = true; - versionLog('

You already have the latest version of netdata!

No update yet?
Probably, we need some motivation to keep going on!

If you haven\'t already, give netdata a Star at its github page.

'); + versionLog('

You already have the latest netdata!

No update yet?
Probably, we need some motivation to keep going on!

If you haven\'t already, give netdata a Star at its github page.

'); } else { save = true; var compare = 'https://github.com/firehol/netdata/compare/' + sha1.toString() + '...' + sha2.toString(); - versionLog('

New version of netdata available!

Latest version: ' + sha2.toString() + '

Click here for the changes log since your installed version, and
click here for directions on updating your netdata installation.

We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.
Keeping your netdata updated, is generally a good idea.

'); + versionLog('

New version of netdata available!

Latest commit: ' + sha2.substring(0, 7).toString() + '

Click here for the changes log since your installed version, and
click here for directions on updating your netdata installation.

We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.
Keeping your netdata updated, is generally a good idea.

'); document.getElementById('update_badge').innerHTML = '!'; } @@ -3314,7 +3338,8 @@