mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Add Plex token check and error message to settings page
This commit is contained in:
parent
bb1d324ac2
commit
323a13ae17
3 changed files with 36 additions and 11 deletions
|
@ -3223,7 +3223,7 @@ div.dataTables_info {
|
||||||
#libraries-to-purge > li {
|
#libraries-to-purge > li {
|
||||||
color: #e9a049;
|
color: #e9a049;
|
||||||
}
|
}
|
||||||
#updatebar {
|
#updatebar, #token_error_bar {
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
opacity: 0.95;
|
opacity: 0.95;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
|
@ -3238,32 +3238,35 @@ div.dataTables_info {
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
#updatebar .msg {
|
#updatebar .msg, #token_error_bar .msg {
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
#updatebar .loader {
|
#updatebar .loader, #token_error_bar .loader {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
}
|
}
|
||||||
#updatebar.success {
|
#updatebar.success, #token_error_bar.success {
|
||||||
padding: 15px 10px;
|
padding: 15px 10px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
#updatebar.error {
|
#updatebar.error, #token_error_bar.error {
|
||||||
padding: 15px 10px;
|
padding: 15px 10px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
#updatebar .ui-icon {
|
#updatebar .ui-icon, #token_error_bar .ui-icon {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: -20px;
|
margin-left: -20px;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
}
|
}
|
||||||
#updatebar a:hover {
|
#updatebar a:hover, #token_error_bar a:hover {
|
||||||
color: #e9a049;
|
color: #e9a049;
|
||||||
}
|
}
|
||||||
|
#token_error_bar {
|
||||||
|
background-color: rgba(255,0,0,0.5) !important;
|
||||||
|
}
|
||||||
.body-container {
|
.body-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
|
|
|
@ -71,8 +71,9 @@ function refreshTab() {
|
||||||
function showMsg(msg, loader, timeout, ms, error) {
|
function showMsg(msg, loader, timeout, ms, error) {
|
||||||
var feedback = $("#ajaxMsg");
|
var feedback = $("#ajaxMsg");
|
||||||
var update = $("#updatebar");
|
var update = $("#updatebar");
|
||||||
if (update.is(":visible")) {
|
var token_error = $("#token_error_bar");
|
||||||
var height = update.height() + 35;
|
if (update.is(":visible") || token_error.is(":visible")) {
|
||||||
|
var height = (update.is(":visible") ? update.height() : 0) + (token_error.is(":visible") ? token_error.height() : 0) + 35;
|
||||||
feedback.css("bottom", height + "px");
|
feedback.css("bottom", height + "px");
|
||||||
} else {
|
} else {
|
||||||
feedback.removeAttr("style");
|
feedback.removeAttr("style");
|
||||||
|
@ -131,8 +132,9 @@ function doAjaxCall(url, elem, reload, form, showMsg, callback) {
|
||||||
// Set Message
|
// Set Message
|
||||||
var feedback = (showMsg) ? $("#ajaxMsg") : $();
|
var feedback = (showMsg) ? $("#ajaxMsg") : $();
|
||||||
var update = $("#updatebar");
|
var update = $("#updatebar");
|
||||||
if (update.is(":visible")) {
|
var token_error = $("#token_error_bar");
|
||||||
var height = update.height() + 35;
|
if (update.is(":visible") || token_error.is(":visible")) {
|
||||||
|
var height = (update.is(":visible") ? update.height() : 0) + (token_error.is(":visible") ? token_error.height() : 0) + 35;
|
||||||
feedback.css("bottom", height + "px");
|
feedback.css("bottom", height + "px");
|
||||||
} else {
|
} else {
|
||||||
feedback.removeAttr("style");
|
feedback.removeAttr("style");
|
||||||
|
|
|
@ -1558,6 +1558,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="token_error_bar" style="display: none;">
|
||||||
|
<i class="fa fa-exclamation-triangle"></i> Your Plex.tv token is no longer valid.<br>
|
||||||
|
Please <a data-tab-destination="plex_media_server" data-target="pms_token">fetch a new token</a>.
|
||||||
|
</div>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="modalIncludes()">
|
<%def name="modalIncludes()">
|
||||||
|
@ -2648,12 +2652,28 @@ $(document).ready(function() {
|
||||||
window.open(pms_web_url, '_blank');
|
window.open(pms_web_url, '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "https://plex.tv/api/resources",
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('X-Plex-Token', $('#pms_token').val());
|
||||||
|
},
|
||||||
|
statusCode: {
|
||||||
|
401: function (xhr, status) {
|
||||||
|
$("#updatebar").hide();
|
||||||
|
$("#token_error_bar").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function OAuthPreFunction() {
|
function OAuthPreFunction() {
|
||||||
$("#token_verify").html('<i class="fa fa-refresh fa-spin"></i>').fadeIn('fast');
|
$("#token_verify").html('<i class="fa fa-refresh fa-spin"></i>').fadeIn('fast');
|
||||||
}
|
}
|
||||||
function OAuthSuccessCallback(authToken) {
|
function OAuthSuccessCallback(authToken) {
|
||||||
$("#pms_token").val(authToken);
|
$("#pms_token").val(authToken);
|
||||||
$("#token_verify").html('<i class="fa fa-check"></i>').fadeIn('fast');
|
$("#token_verify").html('<i class="fa fa-check"></i>').fadeIn('fast');
|
||||||
|
$('#token_error_bar').hide();
|
||||||
getServerOptions(authToken);
|
getServerOptions(authToken);
|
||||||
}
|
}
|
||||||
function OAuthErrorCallback() {
|
function OAuthErrorCallback() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue