mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Combine activity header into one activity function
This commit is contained in:
parent
e80d88c9ff
commit
99f93a8d50
3 changed files with 43 additions and 22 deletions
|
@ -66,7 +66,7 @@ DOCUMENTATION :: END
|
|||
import plexpy
|
||||
%>
|
||||
<% sk = data['session_key'] %>
|
||||
<div class="dashboard-activity-instance" id="instance-${sk}" data-key="${sk}" data-id="${data['session_id']}"
|
||||
<div class="dashboard-activity-instance" id="activity-instance-${sk}" data-key="${sk}" data-id="${data['session_id']}"
|
||||
data-rating_key="${data['rating_key']}" data-parent_rating_key="${data['parent_rating_key']}" data-grandparent_rating_key="${data['grandparent_rating_key']}">
|
||||
<div class="dashboard-activity-container">
|
||||
<div class="dashboard-activity-background-overlay">
|
||||
|
@ -94,15 +94,15 @@ DOCUMENTATION :: END
|
|||
<div id="poster-${sk}" class="dashboard-activity-cover" style="background-image: url(pms_image_proxy?img=${data['parent_thumb']}&width=300&height=300&fallback=cover&refresh=true);"></div>
|
||||
</a>
|
||||
% elif data['media_type'] in ('photo', 'clip'):
|
||||
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(pms_image_proxy?img=${data['parent_thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
||||
<div id="poster-${sk}" class="dashboard-activity-poster hidden-xs" style="background-image: url(pms_image_proxy?img=${data['parent_thumb']}&width=300&height=450&fallback=poster&refresh=true);"></div>
|
||||
% else:
|
||||
<div id="poster-${sk}" class="dashboard-activity-poster" style="background-image: url(images/art.png);"></div>
|
||||
<div id="poster-${sk}" class="dashboard-activity-poster hidden-xs" style="background-image: url(images/art.png);"></div>
|
||||
% endif
|
||||
% else:
|
||||
% if data['channel_icon'].startswith('http'):
|
||||
<div id="poster-${sk}" class="dashboard-activity-cover" style="background-image: url(${data['channel_icon']});"></div>
|
||||
<div id="poster-${sk}" class="dashboard-activity-cover hidden-xs" style="background-image: url(${data['channel_icon']});"></div>
|
||||
% else:
|
||||
<div id="poster-${sk}" class="dashboard-activity-cover" style="background-image: url(pms_image_proxy?img=${data['channel_icon']}&width=300&height=300&fallback=cover&refresh=true);"></div>
|
||||
<div id="poster-${sk}" class="dashboard-activity-cover hidden-xs" style="background-image: url(pms_image_proxy?img=${data['channel_icon']}&width=300&height=300&fallback=cover&refresh=true);"></div>
|
||||
% endif
|
||||
% endif
|
||||
<div class="dashboard-activity-info-icon">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="padded-header" id="current-activity-header">
|
||||
<h3>Activity</h3>
|
||||
<h3>Activity <small><span id="currentActivityHeader"></span></small></h3>
|
||||
</div>
|
||||
<div id="currentActivity">
|
||||
<div class="text-muted" id="dashboard-checking-activity"><i class="fa fa-refresh fa-spin"></i> Checking for activity...</div>
|
||||
|
@ -217,17 +217,6 @@
|
|||
</script>
|
||||
% if 'current_activity' in config['home_sections']:
|
||||
<script>
|
||||
function currentActivityHeader() {
|
||||
$.ajax({
|
||||
url: 'get_current_activity_header',
|
||||
cache: false,
|
||||
async: true,
|
||||
complete: function (xhr, status) {
|
||||
$("#current-activity-header").html(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCurrentActivity() {
|
||||
$.ajax({
|
||||
url: 'get_activity',
|
||||
|
@ -249,6 +238,7 @@
|
|||
}
|
||||
|
||||
if (!(current_activity)) {
|
||||
$('#currentActivityHeader').text('');
|
||||
$('#currentActivity').html('<div id="dashboard-no-activity" class="text-muted">There was an error communicating with your Plex Server.</div>');
|
||||
return
|
||||
}
|
||||
|
@ -259,10 +249,28 @@
|
|||
if (stream_count) {
|
||||
$('#dashboard-no-activity').remove();
|
||||
|
||||
// Update the header stream counts
|
||||
var sc_dp = current_activity.stream_count_direct_play,
|
||||
sc_ds = current_activity.stream_count_direct_stream,
|
||||
sc_tc = current_activity.stream_count_transcode;
|
||||
var header_count = stream_count + ' stream' + (stream_count > 1 ? 's' : '') + ' (';
|
||||
if (sc_dp) {
|
||||
header_count += sc_dp + ' direct play' + (sc_dp > 1 ? 's' : '') + ', ';
|
||||
}
|
||||
if (sc_ds) {
|
||||
header_count += sc_ds + ' direct stream' + (sc_ds > 1 ? 's' : '') + ', ';
|
||||
}
|
||||
if (sc_tc) {
|
||||
header_count += sc_tc + ' transcode' + (sc_tc > 1 ? 's' : '') + ', ';
|
||||
}
|
||||
header_count = header_count.replace(/, $/, '');
|
||||
header_count += ')';
|
||||
$('#currentActivityHeader').text(header_count);
|
||||
|
||||
sessions.forEach(function (s) {
|
||||
var key = s.session_key;
|
||||
var session_id = s.session_id;
|
||||
var instance = $('#instance-' + key);
|
||||
var instance = $('#activity-instance-' + key);
|
||||
|
||||
// Create a new instance if it doesn't exist
|
||||
if (!(instance.length)) {
|
||||
|
@ -454,8 +462,7 @@
|
|||
});
|
||||
|
||||
// Remove finished instances
|
||||
var all_instances = $('div[id^=instance-]');
|
||||
all_instances.each(function (i, instance) {
|
||||
$('div[id^=activity-instance-]').each(function (i, instance) {
|
||||
if ($(instance).hasClass('updated-temp')) {
|
||||
$(instance).removeClass('updated-temp');
|
||||
} else {
|
||||
|
@ -465,6 +472,7 @@
|
|||
});
|
||||
|
||||
} else {
|
||||
$('#currentActivityHeader').text('');
|
||||
$('#currentActivity').html('<div id="dashboard-no-activity" class="text-muted">Nothing is currently being played.</div>');
|
||||
}
|
||||
}
|
||||
|
@ -487,10 +495,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
currentActivityHeader();
|
||||
getCurrentActivity();
|
||||
setInterval(function () {
|
||||
currentActivityHeader();
|
||||
getCurrentActivity();
|
||||
}, 2000);
|
||||
|
||||
|
|
|
@ -4424,6 +4424,21 @@ class WebInterface(object):
|
|||
if session_key:
|
||||
return next((s for s in result['sessions'] if s['session_key'] == session_key), {})
|
||||
|
||||
|
||||
counts = {'stream_count_direct_play': 0,
|
||||
'stream_count_direct_stream': 0,
|
||||
'stream_count_transcode': 0}
|
||||
|
||||
for s in result['sessions']:
|
||||
if s['transcode_decision'] == 'transcode':
|
||||
counts['stream_count_transcode'] += 1
|
||||
elif s['transcode_decision'] == 'copy':
|
||||
counts['stream_count_direct_stream'] += 1
|
||||
else:
|
||||
counts['stream_count_direct_play'] += 1
|
||||
|
||||
result.update(counts)
|
||||
|
||||
return result
|
||||
else:
|
||||
logger.warn(u"Unable to retrieve data for get_activity.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue