diff --git a/API.md b/API.md
index 887dc4e5..39b6faf2 100644
--- a/API.md
+++ b/API.md
@@ -2409,7 +2409,26 @@ Uninstalls the GeoLite2 database
### update
-Check for Tautulli updates on Github.
+Update Tautulli.
+
+
+### update_check
+Check for Tautulli updates.
+
+```
+Required parameters:
+ None
+
+Optional parameters:
+ None
+
+Returns:
+ json
+ {"result": "success",
+ "update": true,
+ "message": "An update for Tautulli is available."
+ }
+```
### update_metadata_details
diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html
index 7c76a193..22eaeb29 100644
--- a/data/interfaces/default/base.html
+++ b/data/interfaces/default/base.html
@@ -44,16 +44,18 @@
% if _session['user_group'] == 'admin':
% if plexpy.CONFIG.CHECK_GITHUB and not plexpy.CURRENT_VERSION:
- You're running an unknown version of Tautulli.
+ You are running an unknown version of Tautulli.
Update or
Close
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win':
A
- newer version is available.
- You're ${plexpy.COMMITS_BEHIND} commits behind.
+ newer version is available!
+ You are ${plexpy.COMMITS_BEHIND} commits behind.
Update or
Close
+ % else:
+
% endif
% endif
@@ -296,7 +298,37 @@ ${next.modalIncludes()}
});
if (!getCookie('updateDismiss')) {
- $('#updatebar').show();
+ if ($('#updatebar').html().length > 0) {
+ $('#updatebar').show();
+ }
+ }
+
+ function checkUpdate(_callback) {
+ // Allow the update bar to show again if previously dismissed.
+ setCookie('updateDismiss', 'true', 0);
+ $.ajax({
+ url: 'update_check',
+ complete: function (xhr, status) {
+ var result = $.parseJSON(xhr.responseText);
+ var msg = '';
+ if (result.update === true) {
+ msg = 'A newer version is available! ' +
+ 'You are '+ result.commits_behind + ' commits behind. ' +
+ 'Update or Close .';
+ $('#updatebar').html(msg).show();
+ } else if (result.update === false) {
+ showMsg(' ' + result.message, false, true, 2000);
+ } else if (result.update === null) {
+ msg = 'You are running an unknown version of Tautulli. ' +
+ 'Update or Close .';
+ $('#updatebar').html(msg).show();
+ }
+
+ if (_callback) {
+ _callback();
+ }
+ }
+ });
}
$("#nav-shutdown").click(function() {
@@ -315,11 +347,9 @@ ${next.modalIncludes()}
});
});
- $("#nav-update").first().one("click", function () {
- // Allow the update bar to show again if previously dismissed.
- setCookie('updateDismiss', 'true', 0);
- $(this).html(' Checking');
- window.location.href = "checkGithub";
+ $('#nav-update').click(function () {
+ $(this).html(' Checking');
+ checkUpdate(function () { $('#nav-update').html(' Check for Updates'); });
});
$('#donation_type a.crypto-donation').on('shown.bs.tab', function () {
diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index a8da270f..9b6b56aa 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -1648,11 +1648,11 @@ $(document).ready(function() {
});
$('#menu_link_update_check').click(function() {
- // Allow the update bar to show again if previously dismissed.
- setCookie('updateDismiss', 'true', 0);
- $(this).html(' Checking');
- $(this).prop('disabled', true);
- window.location.href = 'checkGithub';
+ $(this).html(' Checking').prop('disabled', true);
+ checkUpdate(function () {
+ $('#menu_link_update_check').html(' Check for Updates')
+ .prop('disabled', false);
+ });
});
$('#modal_link_restart').click(function() {
diff --git a/plexpy/api2.py b/plexpy/api2.py
index 84b52b6a..3124d987 100644
--- a/plexpy/api2.py
+++ b/plexpy/api2.py
@@ -335,14 +335,14 @@ class API2:
""" Restart Tautulli."""
plexpy.SIGNAL = 'restart'
- self._api_msg = 'Restarting plexpy'
+ self._api_msg = 'Restarting Tautulli'
self._api_result_type = 'success'
def update(self, **kwargs):
- """ Check for Tautulli updates on Github."""
+ """ Update Tautulli."""
plexpy.SIGNAL = 'update'
- self._api_msg = 'Updating plexpy'
+ self._api_msg = 'Updating Tautulli'
self._api_result_type = 'success'
def refresh_libraries_list(self, **kwargs):
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 98c3aea9..3b263fb7 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -3508,10 +3508,53 @@ class WebInterface(object):
return apikey
@cherrypy.expose
+ @cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
- def checkGithub(self, **kwargs):
+ @addtoapi()
+ def update_check(self, **kwargs):
+ """ Check for Tautulli updates.
+
+ ```
+ Required parameters:
+ None
+
+ Optional parameters:
+ None
+
+ Returns:
+ json
+ {"result": "success",
+ "update": true,
+ "message": "An update for Tautulli is available."
+ }
+ ```
+ """
versioncheck.checkGithub()
- raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "home")
+
+ if not plexpy.CURRENT_VERSION:
+ return {'result': 'error',
+ 'message': 'You are running an unknown version of Tautulli.',
+ 'update': None}
+
+ elif plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and \
+ plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win':
+ return {'result': 'success',
+ 'update': True,
+ 'message': 'An update for Tautulli is available.',
+ 'latest_version': plexpy.LATEST_VERSION,
+ 'commits_behind': plexpy.COMMITS_BEHIND,
+ 'compare_url': helpers.anon_url(
+ 'https://github.com/%s/%s/compare/%s...%s'
+ % (plexpy.CONFIG.GIT_USER,
+ plexpy.CONFIG.GIT_REPO,
+ plexpy.CURRENT_VERSION,
+ plexpy.LATEST_VERSION))
+ }
+
+ else:
+ return {'result': 'success',
+ 'update': False,
+ 'message': 'Tautulli is up to date.'}
@cherrypy.expose
@requireAuth(member_of("admin"))