Disable IP logging checkbox depending on server version

This commit is contained in:
JonnyWong16 2016-02-19 21:02:48 -08:00
parent de86516a0a
commit eab6365af9
2 changed files with 63 additions and 25 deletions

View file

@ -658,7 +658,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</label> </label>
<span id="debugLogCheck" style="color: #eb8600; padding-left: 10px;"></span> <span id="debugLogCheck" style="color: #eb8600; padding-left: 10px;"></span>
<p class="help-block"> <p class="help-block">
Enable this to attempt to log the IP address of the user (for PMS 0.9.12 and below, IP address is automatically logged for PMS 0.9.14 and above). Enable this to attempt to log the IP address of the user.
</p> </p>
</div> </div>
@ -1896,13 +1896,45 @@ $(document).ready(function() {
}) })
$.ajax({ $.ajax({
url: 'get_server_pref', url: 'get_server_identity',
data: { pref: 'logDebug' },
async: true, async: true,
success: function(data) { success: function(data) {
if (data !== 'true') { var version = data.version.split('.')
$("#debugLogCheck").html("Debug logging must be enabled on your Plex Server. <a target='_blank' href='${anon_url('https://support.plex.tv/hc/en-us/articles/201643703-Reporting-issues-with-Plex-Media-Server')}'>Click here</a> for help."); if (parseInt(version[0]) >= 0 && parseInt(version[1]) >= 9 && parseInt(version[2]) >= 14) {
$("#debugLogCheck").html("IP address is automatically logged for PMS version 0.9.14 and above.");
$("#ip_logging_enable").attr("disabled", true); $("#ip_logging_enable").attr("disabled", true);
$("#ip_logging_enable").attr("checked", true);
} else {
$.ajax({
url: 'get_server_pref',
data: { pref: 'logDebug' },
async: true,
success: function(data) {
if (data !== 'true') {
$("#debugLogCheck").html("Debug logging must be enabled on your Plex Server. <a target='_blank' href='${anon_url('https://support.plex.tv/hc/en-us/articles/201643703-Reporting-issues-with-Plex-Media-Server')}'>Click here</a> for help.");
$("#ip_logging_enable").attr("disabled", true);
$("#ip_logging_enable").attr("checked", false);
}
}
});
// Check to see if our logs folder is set before allowing IP logging to be enabled.
checkLogsPath();
$("#pms_logs_folder").change(function() {
checkLogsPath();
});
function checkLogsPath() {
if ($("#pms_logs_folder").val() == '') {
$("#debugLogCheck").html("You must first define your Plex Server Logs folder path under the Plex Media Server tab.");
$("#ip_logging_enable").attr("disabled", true);
$("#ip_logging_enable").attr("checked", false);
} else {
$("#ip_logging_enable").attr("disabled", false);
$("#debugLogCheck").html("");
}
}
} }
} }
}); });
@ -1913,27 +1945,11 @@ $(document).ready(function() {
async: true, async: true,
success: function(data) { success: function(data) {
if (data !== 'true') { if (data !== 'true') {
$("#remoteAccessCheck").html("Remote access must be enabled on your Plex Server. <a target='_blank' href='${anon_url('https://support.plex.tv/hc/en-us/articles/200484543-Enabling-Remote-Access-for-a-Server')}'>Click here</a> for help.") $("#remoteAccessCheck").html("Remote access must be enabled on your Plex Server. <a target='_blank' href='${anon_url('https://support.plex.tv/hc/en-us/articles/200484543-Enabling-Remote-Access-for-a-Server')}'>Click here</a> for help.");
$("#monitor_remote_access").attr("disabled", true); $("#monitor_remote_access").attr("disabled", true);
} }
} }
}); });
// Check to see if our logs folder is set before allowing IP logging to be enabled.
checkLogsPath();
$("#pms_logs_folder").change(function() {
checkLogsPath();
});
function checkLogsPath() {
if ($("#pms_logs_folder").val() == '') {
$("#debugLogCheck").html("You must first define your Plex Server Logs folder path under the Plex Media Server tab.");
$("#ip_logging_enable").attr("disabled", true);
} else {
$("#ip_logging_enable").attr("disabled", false);
$("#debugLogCheck").html("");
}
}
var accordion_session = new Accordion($('#accordion-session'), false); var accordion_session = new Accordion($('#accordion-session'), false);
var accordion_timeline = new Accordion($('#accordion-timeline'), false); var accordion_timeline = new Accordion($('#accordion-timeline'), false);

View file

@ -1943,7 +1943,7 @@ class WebInterface(object):
@cherrypy.expose @cherrypy.expose
@addtoapi() @addtoapi()
def get_servers_info(self, **kwargs): def get_servers_info(self, **kwargs):
""" Graps info about the server """ Grabs list of info about the servers
Returns: Returns:
json: json:
@ -1956,8 +1956,6 @@ class WebInterface(object):
} }
] ]
``` ```
""" """
pms_connect = pmsconnect.PmsConnect() pms_connect = pmsconnect.PmsConnect()
@ -1969,6 +1967,30 @@ class WebInterface(object):
else: else:
logger.warn(u"Unable to retrieve data for get_servers_info.") logger.warn(u"Unable to retrieve data for get_servers_info.")
@cherrypy.expose
@addtoapi()
def get_server_identity(self, **kwargs):
""" Grabs info about the local server
Returns:
json:
```
[{"machine_identifier": "1234",
"version": "0.9.15.x.xxx-xxxxxxx"
}
]
```
"""
pms_connect = pmsconnect.PmsConnect()
result = pms_connect.get_server_identity()
if result:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(result)
else:
logger.warn(u"Unable to retrieve data for get_server_identity.")
@cherrypy.expose @cherrypy.expose
@addtoapi() @addtoapi()
def get_server_friendly_name(self, **kwargs): def get_server_friendly_name(self, **kwargs):