mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
Check for updates without refreshing the page
This commit is contained in:
parent
16f270691d
commit
cab8b1c041
5 changed files with 112 additions and 20 deletions
21
API.md
21
API.md
|
@ -2409,7 +2409,26 @@ Uninstalls the GeoLite2 database
|
||||||
|
|
||||||
|
|
||||||
### update
|
### 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
|
### update_metadata_details
|
||||||
|
|
|
@ -44,16 +44,18 @@
|
||||||
% if _session['user_group'] == 'admin':
|
% if _session['user_group'] == 'admin':
|
||||||
% if plexpy.CONFIG.CHECK_GITHUB and not plexpy.CURRENT_VERSION:
|
% if plexpy.CONFIG.CHECK_GITHUB and not plexpy.CURRENT_VERSION:
|
||||||
<div id="updatebar" style="display: none;">
|
<div id="updatebar" style="display: none;">
|
||||||
You're running an unknown version of Tautulli.<br />
|
You are running an unknown version of Tautulli.<br />
|
||||||
<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>
|
<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>
|
||||||
</div>
|
</div>
|
||||||
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win':
|
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win':
|
||||||
<div id="updatebar" style="display: none;">
|
<div id="updatebar" style="display: none;">
|
||||||
A <a href="${anon_url('https://github.com/%s/%s/compare/%s...%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION, plexpy.LATEST_VERSION))}" target="_blank">
|
A <a href="${anon_url('https://github.com/%s/%s/compare/%s...%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION, plexpy.LATEST_VERSION))}" target="_blank">
|
||||||
newer version</a> is available.<br />
|
newer version</a> is available!<br />
|
||||||
You're ${plexpy.COMMITS_BEHIND} commits behind.<br />
|
You are ${plexpy.COMMITS_BEHIND} commits behind.<br />
|
||||||
<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>
|
<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>
|
||||||
</div>
|
</div>
|
||||||
|
% else:
|
||||||
|
<div id="updatebar" style="display: none;"></div>
|
||||||
% endif
|
% endif
|
||||||
% endif
|
% endif
|
||||||
<nav class="navbar navbar-fixed-top">
|
<nav class="navbar navbar-fixed-top">
|
||||||
|
@ -296,7 +298,37 @@ ${next.modalIncludes()}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!getCookie('updateDismiss')) {
|
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 <a href="' + result.compare_url + '" target="_blank">newer version</a> is available!<br />' +
|
||||||
|
'You are '+ result.commits_behind + ' commits behind.<br />' +
|
||||||
|
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>.';
|
||||||
|
$('#updatebar').html(msg).show();
|
||||||
|
} else if (result.update === false) {
|
||||||
|
showMsg('<i class="fa fa-check"></i> ' + result.message, false, true, 2000);
|
||||||
|
} else if (result.update === null) {
|
||||||
|
msg = 'You are running an unknown version of Tautulli.<br />' +
|
||||||
|
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Close</a>.';
|
||||||
|
$('#updatebar').html(msg).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_callback) {
|
||||||
|
_callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#nav-shutdown").click(function() {
|
$("#nav-shutdown").click(function() {
|
||||||
|
@ -315,11 +347,9 @@ ${next.modalIncludes()}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#nav-update").first().one("click", function () {
|
$('#nav-update').click(function () {
|
||||||
// Allow the update bar to show again if previously dismissed.
|
$(this).html('<i class="fa fa-fw fa-spin fa-refresh"></i> Checking');
|
||||||
setCookie('updateDismiss', 'true', 0);
|
checkUpdate(function () { $('#nav-update').html('<i class="fa fa-fw fa-arrow-circle-up"></i> Check for Updates'); });
|
||||||
$(this).html('<i class="fa fa-spin fa-refresh"></i> Checking');
|
|
||||||
window.location.href = "checkGithub";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#donation_type a.crypto-donation').on('shown.bs.tab', function () {
|
$('#donation_type a.crypto-donation').on('shown.bs.tab', function () {
|
||||||
|
|
|
@ -1648,11 +1648,11 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#menu_link_update_check').click(function() {
|
$('#menu_link_update_check').click(function() {
|
||||||
// Allow the update bar to show again if previously dismissed.
|
$(this).html('<i class="fa fa-spin fa-refresh"></i> Checking').prop('disabled', true);
|
||||||
setCookie('updateDismiss', 'true', 0);
|
checkUpdate(function () {
|
||||||
$(this).html('<i class="fa fa-spin fa-refresh"></i> Checking');
|
$('#menu_link_update_check').html('<i class="fa fa-arrow-circle-up"></i> Check for Updates')
|
||||||
$(this).prop('disabled', true);
|
.prop('disabled', false);
|
||||||
window.location.href = 'checkGithub';
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#modal_link_restart').click(function() {
|
$('#modal_link_restart').click(function() {
|
||||||
|
|
|
@ -335,14 +335,14 @@ class API2:
|
||||||
""" Restart Tautulli."""
|
""" Restart Tautulli."""
|
||||||
|
|
||||||
plexpy.SIGNAL = 'restart'
|
plexpy.SIGNAL = 'restart'
|
||||||
self._api_msg = 'Restarting plexpy'
|
self._api_msg = 'Restarting Tautulli'
|
||||||
self._api_result_type = 'success'
|
self._api_result_type = 'success'
|
||||||
|
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
""" Check for Tautulli updates on Github."""
|
""" Update Tautulli."""
|
||||||
|
|
||||||
plexpy.SIGNAL = 'update'
|
plexpy.SIGNAL = 'update'
|
||||||
self._api_msg = 'Updating plexpy'
|
self._api_msg = 'Updating Tautulli'
|
||||||
self._api_result_type = 'success'
|
self._api_result_type = 'success'
|
||||||
|
|
||||||
def refresh_libraries_list(self, **kwargs):
|
def refresh_libraries_list(self, **kwargs):
|
||||||
|
|
|
@ -3508,10 +3508,53 @@ class WebInterface(object):
|
||||||
return apikey
|
return apikey
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth(member_of("admin"))
|
@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()
|
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
|
@cherrypy.expose
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue