Move refresh interval setting to homepage

This commit is contained in:
JonnyWong16 2018-03-26 08:53:40 -07:00
parent 084732706d
commit 749e1fcebe
4 changed files with 48 additions and 25 deletions

View file

@ -294,10 +294,6 @@ object {
font-weight: bold; font-weight: bold;
text-transform: uppercase; text-transform: uppercase;
} }
.padded-header h3 small {
font-size: 13px;
text-transform: none;
}
.btn { .btn {
outline:0px !important; outline:0px !important;
} }
@ -2377,6 +2373,18 @@ a .library-user-instance-box:hover {
margin-top: 9px; margin-top: 9px;
width: 175px; width: 175px;
} }
.home-padded-header .info-bar {
float: left;
margin-left: 15px;
line-height: 35px;
}
.home-padded-header .info-bar small {
font-size: 13px;
font-weight: normal;
text-transform: none;
line-height: 1;
color: #777;
}
.home-padded-header .button-bar { .home-padded-header .button-bar {
float: left; float: left;
} }

View file

@ -10,8 +10,16 @@
% if section == 'current_activity': % if section == 'current_activity':
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="padded-header" id="current-activity-header"> <div class="home-padded-header padded-header" id="current-activity-header">
<h3><span id="sessions-shortcut">Activity</span> &nbsp;&nbsp; <h3 class="pull-left"><span id="sessions-shortcut">Current Activity</span></h3>
<div class="button-bar">
<div class="input-group pull-left" style="width: 1px; margin-right: 3px" id="activity-refresh-interval-selection">
<span class="input-group-addon btn-dark inactive">Refresh every</span>
<input type="number" class="form-control number-input" name="activity-refresh-interval" id="activity-refresh-interval" value="${config['home_refresh_interval']}" min="2" data-default="2" data-toggle="tooltip" title="Min: 2 seconds" />
<span class="input-group-addon btn-dark inactive">seconds</span>
</div>
</div>
<div class="info-bar">
<small> <small>
<span id="currentActivityHeader" style="display: none;"> <span id="currentActivityHeader" style="display: none;">
Streams: <span id="currentActivityHeader-streams"></span> | Streams: <span id="currentActivityHeader-streams"></span> |
@ -19,7 +27,7 @@
<span id="currentActivityHeader-bandwidth-tooltip" data-toggle="tooltip" title="Streaming Brain Estimate (Required Bandwidth)"><i class="fa fa-info-circle"></i></span> <span id="currentActivityHeader-bandwidth-tooltip" data-toggle="tooltip" title="Streaming Brain Estimate (Required Bandwidth)"><i class="fa fa-info-circle"></i></span>
</span> </span>
</small> </small>
</h3> </div>
</div> </div>
<div id="currentActivity"> <div id="currentActivity">
<% from plexpy import PLEX_SERVER_UP %> <% from plexpy import PLEX_SERVER_UP %>
@ -585,11 +593,16 @@
} }
getCurrentActivity(); getCurrentActivity();
setInterval(function () {
if (!(create_instances.length) && activity_ready) { function refreshActivity(seconds) {
getCurrentActivity(); return setInterval(function () {
} if (!(create_instances.length) && activity_ready) {
}, ${config['home_refresh_interval'] * 1000}); getCurrentActivity();
}
}, seconds * 1000);
}
var refresh_interval = $('#activity-refresh-interval').val();
var activityRefresh = refreshActivity(refresh_interval);
setInterval(function(){ setInterval(function(){
$('.progress_time_offset').each(function () { $('.progress_time_offset').each(function () {
@ -685,6 +698,16 @@
window.open(sessions_url, '_blank'); window.open(sessions_url, '_blank');
}); });
}); });
$('#activity-refresh-interval').change(function () {
forceMinMax($(this));
clearInterval(activityRefresh);
refresh_interval = $(this).val();
activityRefresh = refreshActivity(refresh_interval);
$.post('set_home_stats_config', { refresh_interval: refresh_interval });
});
$('#activity-refresh-interval').tooltip({ container: 'body', placement: 'top', html: true });
% endif % endif
</script> </script>
% endif % endif

View file

@ -271,17 +271,6 @@
<h3>Activity</h3> <h3>Activity</h3>
</div> </div>
<div class="form-group">
<label for="home_refresh_interval">Activty Refresh Interval</label>
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-parsley-type="integer" id="home_refresh_interval" name="home_refresh_interval" value="${config['home_refresh_interval']}" size="5" data-parsley-min="2" data-parsley-trigger="change" data-parsley-errors-container="#home_refresh_interval_error" required>
</div>
<div id="home_refresh_interval_error" class="alert alert-danger settings-alert" role="alert"></div>
</div>
<p class="help-block">Set the interval (in seconds) to refresh the current activity on the homepage. Minimum 2.</p>
</div>
<div class="padded-header"> <div class="padded-header">
<h3>Sections</h3> <h3>Sections</h3>
</div> </div>

View file

@ -286,7 +286,11 @@ class WebInterface(object):
@cherrypy.expose @cherrypy.expose
@requireAuth(member_of("admin")) @requireAuth(member_of("admin"))
def set_home_stats_config(self, time_range=None, stats_type=None, stats_count=None, recently_added_count=None, **kwargs): def set_home_stats_config(self, refresh_interval=None, time_range=None, stats_type=None, stats_count=None,
recently_added_count=None, **kwargs):
if refresh_interval:
plexpy.CONFIG.__setattr__('HOME_REFRESH_INTERVAL', refresh_interval)
plexpy.CONFIG.write()
if time_range: if time_range:
plexpy.CONFIG.__setattr__('HOME_STATS_LENGTH', time_range) plexpy.CONFIG.__setattr__('HOME_STATS_LENGTH', time_range)
plexpy.CONFIG.write() plexpy.CONFIG.write()
@ -2643,7 +2647,6 @@ class WebInterface(object):
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS), "home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
"home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS), "home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS), "home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
"home_refresh_interval": plexpy.CONFIG.HOME_REFRESH_INTERVAL,
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD, "buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT, "buffer_wait": plexpy.CONFIG.BUFFER_WAIT,
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES), "group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES),