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>
<span id="debugLogCheck" style="color: #eb8600; padding-left: 10px;"></span>
<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>
</div>
@ -1895,6 +1895,16 @@ $(document).ready(function() {
$.get("/osxnotifyregister", { 'app': osx_notify_app }, function (data) { showMsg("<div class='msg'><span class='ui-icon ui-icon-check'></span>" + data + "</div>", false, true, 3000); });
})
$.ajax({
url: 'get_server_identity',
async: true,
success: function(data) {
var version = data.version.split('.')
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("checked", true);
} else {
$.ajax({
url: 'get_server_pref',
data: { pref: 'logDebug' },
@ -1903,21 +1913,11 @@ $(document).ready(function() {
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);
}
}
});
$.ajax({
url: 'get_server_pref',
data: { pref: 'PublishServerOnPlexOnlineKey' },
async: true,
success: function(data) {
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.")
$("#monitor_remote_access").attr("disabled", true);
}
}
});
// Check to see if our logs folder is set before allowing IP logging to be enabled.
checkLogsPath();
@ -1929,11 +1929,27 @@ $(document).ready(function() {
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("");
}
}
}
}
});
$.ajax({
url: 'get_server_pref',
data: { pref: 'PublishServerOnPlexOnlineKey' },
async: true,
success: function(data) {
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.");
$("#monitor_remote_access").attr("disabled", true);
}
}
});
var accordion_session = new Accordion($('#accordion-session'), false);
var accordion_timeline = new Accordion($('#accordion-timeline'), false);

View file

@ -1943,7 +1943,7 @@ class WebInterface(object):
@cherrypy.expose
@addtoapi()
def get_servers_info(self, **kwargs):
""" Graps info about the server
""" Grabs list of info about the servers
Returns:
json:
@ -1956,8 +1956,6 @@ class WebInterface(object):
}
]
```
"""
pms_connect = pmsconnect.PmsConnect()
@ -1969,6 +1967,30 @@ class WebInterface(object):
else:
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
@addtoapi()
def get_server_friendly_name(self, **kwargs):