summaryrefslogtreecommitdiffstats
path: root/web/gui/main.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-21 19:34:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-21 19:34:01 +0000
commit66564c2324abc58b24327b763e1113ff781156a2 (patch)
tree2480212cd47149a3fda5225b57689d0126546e23 /web/gui/main.js
parentAdding upstream version 1.12.0. (diff)
downloadnetdata-66564c2324abc58b24327b763e1113ff781156a2.tar.xz
netdata-66564c2324abc58b24327b763e1113ff781156a2.zip
Adding upstream version 1.12.1.upstream/1.12.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/gui/main.js')
-rw-r--r--web/gui/main.js91
1 files changed, 76 insertions, 15 deletions
diff --git a/web/gui/main.js b/web/gui/main.js
index b6478f6cf..86dca62ff 100644
--- a/web/gui/main.js
+++ b/web/gui/main.js
@@ -1037,6 +1037,7 @@ var options = {
data: null,
hostname: 'netdata_server', // will be overwritten by the netdata server
version: 'unknown',
+ release_channel: 'unknown',
hosts: [],
duration: 0, // the default duration of the charts
@@ -2700,6 +2701,7 @@ function initializeDynamicDashboardWithData(data) {
options.hostname = data.hostname;
options.data = data;
options.version = data.version;
+ options.release_channel = data.release_channel;
netdataDashboard.os = data.os;
if (typeof data.hosts !== 'undefined') {
@@ -2740,6 +2742,9 @@ function initializeDynamicDashboardWithData(data) {
// render all charts
renderChartsAndMenu(data);
+
+ // Ensure MyNetdata menu is rendered with latest host info #5370
+ renderMyNetdataMenu(isSignedIn() ? cloudAgents : registryAgents);
}
}
@@ -2829,12 +2834,33 @@ function versionsMatch(v1, v2) {
if (v1 == v2) {
return true;
} else {
- var s1=v1.split('-');
- var s2=v2.split('-');
- if (s1.length !== s2.length) return false;
- if (s1.length === 4) s1.pop();
- if (s2.length === 4) s2.pop();
- return (s1.join('-') === s2.join('-'));
+ let s1=v1.split('.');
+ let s2=v2.split('.');
+ // Check major version
+ let n1 = parseInt(s1[0].substring(1,2),10);
+ let n2 = parseInt(s2[0].substring(1,2), 10);
+ if ( n1 < n2 ) return false;
+ else if ( n1 > n2 ) return true;
+
+ // Check minor version
+ n1 = parseInt(s1[1],10);
+ n2 = parseInt(s2[1],10);
+ if ( n1 < n2 ) return false;
+ else if ( n1 > n2 ) return true;
+
+ // Split patch: format could be e.g. 0-22-nightly
+ s1=s1[2].split('-');
+ s2=s2[2].split('-');
+
+ n1 = parseInt(s1[0],10);
+ n2 = parseInt(s2[0],10);
+ if ( n1 < n2 ) return false;
+ else if ( n1 > n2 ) return true;
+
+ n1 = (s1.length > 1) ? parseInt(s1[1],10) : 0;
+ n2 = (s2.length > 1) ? parseInt(s2[1],10) : 0;
+ if ( n1 < n2 ) return false;
+ else return true;
}
}
@@ -2842,26 +2868,61 @@ function getGithubLatestVersion(callback) {
versionLog('Downloading latest version id from github...');
$.ajax({
- url: 'https://api.github.com/repositories/10744183/contents/packaging/version?ref=master',
+ url: 'https://api.github.com/repos/netdata/netdata/releases/latest',
async: true,
cache: false
})
.done(function (data) {
- data = atob(data.content.replace(/(\r\n|\n|\r| |\t)/gm, ""));
- versionLog('Latest version from github is ' + data);
+ data = data.tag_name.replace(/(\r\n|\n|\r| |\t)/gm, "");
+ versionLog('Latest stable version from github is ' + data);
callback(data);
})
.fail(function () {
- versionLog('Failed to download the latest version id from github!');
+ versionLog('Failed to download the latest stable version id from github!');
callback(null);
});
}
+function getGCSLatestVersion(callback) {
+ versionLog('Downloading latest version id from GCS...');
+ $.ajax({
+ url: "https://www.googleapis.com/storage/v1/b/netdata-nightlies/o/latest-version.txt",
+ async: true,
+ cache: false
+ })
+ .done(function (response) {
+ $.ajax({
+ url: response.mediaLink,
+ async: true,
+ cache: false
+ })
+ .done(function (data) {
+ data = data.replace(/(\r\n|\n|\r| |\t)/gm, "");
+ versionLog('Latest nightly version from GCS is ' + data);
+ callback(data);
+ })
+ .fail(function (xhr, textStatus, errorThrown) {
+ versionLog('Failed to download the latest nightly version id from GCS!');
+ callback(null);
+ });
+ })
+ .fail(function (xhr, textStatus, errorThrown) {
+ versionLog('Failed to download the latest nightly version from GCS!');
+ callback(null);
+ });
+}
+
+
function checkForUpdateByVersion(force, callback) {
- getGithubLatestVersion(function (sha2) {
+ if (options.release_channel === 'stable') {
+ getGithubLatestVersion(function (sha2) {
callback(options.version, sha2);
- });
-
+ });
+ } else {
+ getGCSLatestVersion(function (sha2) {
+ callback(options.version, sha2);
+ });
+ }
return null;
}
@@ -2893,10 +2954,10 @@ function notifyForUpdate(force) {
versionLog('<p><big>Failed to get your netdata version!</big></p><p>You can always get the latest netdata from <a href="https://github.com/netdata/netdata" target="_blank">its github page</a>.</p>');
} else if (sha2 === null) {
save = false;
- versionLog('<p><big>Failed to get the latest netdata version github.</big></p><p>You can always get the latest netdata from <a href="https://github.com/netdata/netdata" target="_blank">its github page</a>.</p>');
+ versionLog('<p><big>Failed to get the latest netdata version.</big></p><p>You can always get the latest netdata from <a href="https://github.com/netdata/netdata" target="_blank">its github page</a>.</p>');
} else if (versionsMatch(sha1, sha2)) {
save = true;
- versionLog('<p><big>You already have the latest netdata!</big></p><p>No update yet?<br/>Probably, we need some motivation to keep going on!</p><p>If you haven\'t already, <a href="https://github.com/netdata/netdata" target="_blank">give netdata a <b><i class="fas fa-star"></i></b> at its github page</a>.</p>');
+ versionLog('<p><big>You already have the latest netdata!</big></p><p>No update yet?<br/>We probably need some motivation to keep going on!</p><p>If you haven\'t already, <a href="https://github.com/netdata/netdata" target="_blank">give netdata a <b><i class="fas fa-star"></i></b> at its github page</a>.</p>');
} else {
save = true;
var compare = 'https://docs.netdata.cloud/changelog/';