mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 21:45:47 +01:00
Merge branch 'master' into fix-vendors
This commit is contained in:
@@ -8,6 +8,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
graphs: false
|
||||
},
|
||||
isMobile = false,
|
||||
isPrerelease = /^v?\d+\.\d+\.\d+-.+$/,
|
||||
graphData = {
|
||||
rooms: {},
|
||||
traffic: {}
|
||||
@@ -22,7 +23,17 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
graphInterval: 15000,
|
||||
realtimeInterval: 1500
|
||||
};
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
clearInterval(intervals.rooms);
|
||||
clearInterval(intervals.graphs);
|
||||
|
||||
intervals.rooms = null;
|
||||
intervals.graphs = null;
|
||||
graphData.rooms = null;
|
||||
graphData.traffic = null;
|
||||
usedTopicColors.length = 0;
|
||||
});
|
||||
|
||||
Admin.init = function() {
|
||||
app.enterRoom('admin');
|
||||
@@ -30,37 +41,34 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
|
||||
isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
clearInterval(intervals.rooms);
|
||||
clearInterval(intervals.graphs);
|
||||
|
||||
intervals.rooms = null;
|
||||
intervals.graphs = null;
|
||||
graphData.rooms = null;
|
||||
graphData.traffic = null;
|
||||
usedTopicColors.length = 0;
|
||||
});
|
||||
|
||||
$.get('https://api.github.com/repos/NodeBB/NodeBB/tags', function(releases) {
|
||||
// Re-sort the releases, as they do not follow Semver (wrt pre-releases)
|
||||
releases = releases.sort(function(a, b) {
|
||||
a = a.name.replace(/^v/, '');
|
||||
b = b.name.replace(/^v/, '');
|
||||
return semver.lt(a, b) ? 1 : -1;
|
||||
}).filter(function(version) {
|
||||
return !isPrerelease.test(version.name); // filter out automated prerelease versions
|
||||
});
|
||||
|
||||
var version = $('#version').html(),
|
||||
latestVersion = releases[0].name.slice(1),
|
||||
checkEl = $('.version-check');
|
||||
checkEl.html($('.version-check').html().replace('<i class="fa fa-spinner fa-spin"></i>', 'v' + latestVersion));
|
||||
|
||||
// Alter box colour accordingly
|
||||
if (semver.eq(latestVersion, version)) {
|
||||
checkEl.removeClass('alert-info').addClass('alert-success');
|
||||
checkEl.append('<p>You are <strong>up-to-date</strong> <i class="fa fa-check"></i></p>');
|
||||
} else if (semver.gt(latestVersion, version)) {
|
||||
checkEl.removeClass('alert-info').addClass('alert-danger');
|
||||
checkEl.append('<p>A new version (v' + latestVersion + ') has been released. Consider <a href="https://docs.nodebb.org/en/latest/upgrading/index.html">upgrading your NodeBB</a>.</p>');
|
||||
checkEl.removeClass('alert-info').addClass('alert-warning');
|
||||
if (!isPrerelease.test(version)) {
|
||||
checkEl.append('<p>A new version (v' + latestVersion + ') has been released. Consider <a href="https://docs.nodebb.org/en/latest/upgrading/index.html">upgrading your NodeBB</a>.</p>');
|
||||
} else {
|
||||
checkEl.append('<p>This is an outdated pre-release version of NodeBB. A new version (v' + latestVersion + ') has been released. Consider <a href="https://docs.nodebb.org/en/latest/upgrading/index.html">upgrading your NodeBB</a>.</p>');
|
||||
}
|
||||
} else if (isPrerelease.test(version)) {
|
||||
checkEl.removeClass('alert-info').addClass('alert-info');
|
||||
checkEl.append('<p>This is a <strong>pre-release</strong> version of NodeBB. Unintended bugs may occur. <i class="fa fa-exclamation-triangle"></i>.</p>');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -158,6 +166,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
|
||||
if (isMobile) {
|
||||
Chart.defaults.global.showTooltips = false;
|
||||
Chart.defaults.global.animation = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
@@ -186,7 +195,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
]
|
||||
};
|
||||
|
||||
trafficCanvas.width = $(trafficCanvas).parent().width(); // is this necessary
|
||||
trafficCanvas.width = $(trafficCanvas).parent().width();
|
||||
graphs.traffic = new Chart(trafficCtx).Line(data, {
|
||||
responsive: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user