mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Style the home stats.
Add some error catching.
This commit is contained in:
parent
3fcf0d83cb
commit
c99e3c5e4a
4 changed files with 156 additions and 102 deletions
|
@ -8102,3 +8102,51 @@ ol.test >li {
|
|||
.charts-slider-title-views {
|
||||
float: right;
|
||||
}
|
||||
|
||||
|
||||
.home-platforms-instance-poster {
|
||||
float: left;
|
||||
height: 120px;
|
||||
padding: 5px 10px 5px 10px;
|
||||
}
|
||||
|
||||
.home-platforms-instance-box {
|
||||
float: left;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
padding: 25px 10px 25px 10px;
|
||||
}
|
||||
|
||||
.home-platforms-instance-oval {
|
||||
float: left;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
padding: 25px 10px 25px 10px;
|
||||
-webkit-border-radius: 50%;
|
||||
-moz-border-radius: 50%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.home-platforms-instance-name {
|
||||
float: left;
|
||||
color: #fff;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
font-weight: bold;
|
||||
width: 180px;
|
||||
margin-left: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.home-platforms-instance {
|
||||
float: left;
|
||||
width: 300px;
|
||||
height: 130px;
|
||||
padding: 5px;
|
||||
background-color: #282828;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
|
@ -1,67 +1,79 @@
|
|||
% if stats[0]['rows']:
|
||||
<div class="dashboard-recent-media-row">
|
||||
<ul class="dashboard-recent-media">
|
||||
% if stats != None:
|
||||
% if stats[0]['rows']:
|
||||
<div class="user-platforms">
|
||||
<ul>
|
||||
% for a in stats:
|
||||
<div class="dashboard-recent-media-instance">
|
||||
% if a['stat_id'] == 'top_tv':
|
||||
<div class="home-platforms-instance">
|
||||
<li>
|
||||
<div class="poster">
|
||||
<h5>Most watched TV</h5><br/>
|
||||
<div class="poster-face">
|
||||
<span>
|
||||
<a href="info?rating_key=${a['rows'][0]['rating_key']}">
|
||||
% if a['rows'][0]['grandparent_thumb'] != '':
|
||||
<img src="pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=153&height=225" class="poster-face">
|
||||
<img class="home-platforms-instance-poster" src="pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=153&height=225">
|
||||
% else:
|
||||
<img src="interfaces/default/images/poster.png" class="poster-face">
|
||||
<img class="home-platforms-instance-poster" src="interfaces/default/images/poster.png">
|
||||
% endif
|
||||
</a>
|
||||
</span>
|
||||
<div class="home-platforms-instance-name">
|
||||
<h4>Most Popular TV</h4>
|
||||
<a href="info?rating_key=${a['rows'][0]['rating_key']}">
|
||||
<h5>${a['rows'][0]['orig_title']}</h5>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
<h3>${a['rows'][0]['orig_title']}</h3>
|
||||
<div class="muted">Plays: ${a['rows'][0]['total_plays']}</div>
|
||||
<div class="user-platforms-instance-playcount">
|
||||
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
% elif a['stat_id'] == 'top_users':
|
||||
<div class="home-platforms-instance">
|
||||
<li>
|
||||
<div class="poster">
|
||||
<h5>Most active user</h5><br/>
|
||||
<div class="poster-face">
|
||||
<span>
|
||||
<a href="user?user=${a['rows'][0]['user']}">
|
||||
% if a['rows'][0]['thumb'] != '':
|
||||
<img src="${a['rows'][0]['thumb']}" class="poster-face">
|
||||
<img class="home-platforms-instance-oval" src="${a['rows'][0]['thumb']}" class="poster-face">
|
||||
% else:
|
||||
<img src="interfaces/default/images/gravatar-default.png" class="poster-face">
|
||||
<img class="home-platforms-instance-oval" src="interfaces/default/images/gravatar-default.png">
|
||||
% endif
|
||||
</a>
|
||||
</span>
|
||||
<div class="home-platforms-instance-name">
|
||||
<h4>Most Active User</h4>
|
||||
<a href="user?user=${a['rows'][0]['user']}">
|
||||
<h5>${a['rows'][0]['user']}</h5>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
<h3>${a['rows'][0]['user']}</h3>
|
||||
<div class="muted">Plays: ${a['rows'][0]['total_plays']}</div>
|
||||
<div class="user-platforms-instance-playcount">
|
||||
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
% elif a['stat_id'] == 'top_platforms':
|
||||
<div class="home-platforms-instance">
|
||||
<li>
|
||||
<div class="poster">
|
||||
<h5>Most used platform</h5><br/>
|
||||
<div class="poster-face" id="platform-face">
|
||||
<img src="interfaces/default/images/platforms/default.png" class="poster-face">
|
||||
<div id="platform-stat">
|
||||
<img class="home-platforms-instance-box" src="interfaces/default/images/platforms/default.png">
|
||||
</div>
|
||||
<div class="home-platforms-instance-name">
|
||||
<h4>Most Active Platform</h4>
|
||||
<h5>${a['rows'][0]['platform_type']}</h5>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
<h3>${a['rows'][0]['platform_type']}</h3>
|
||||
<div class="muted">Plays: ${a['rows'][0]['total_plays']}</div>
|
||||
<div class="user-platforms-instance-playcount">
|
||||
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
<script>
|
||||
$("#platform-face").html("<img class='user-platforms-instance-poster' src='" + getPlatformImagePath('${a['rows'][0]['platform_type']}') + "'>");
|
||||
$("#platform-stat").html("<img class='home-platforms-instance-box' src='" + getPlatformImagePath('${a['rows'][0]['platform_type']}') + "'>");
|
||||
</script>
|
||||
% endif
|
||||
</div>
|
||||
% endfor
|
||||
</ul>
|
||||
</div>
|
||||
% else:
|
||||
</div>
|
||||
% else:
|
||||
<div class="muted">No stats for selected period.</div><br>
|
||||
% endif
|
||||
% else:
|
||||
<div class="muted">There was an error loading your PlexWatch data. Please check your <a href="config">settings</a>.</div><br>
|
||||
% endif
|
|
@ -31,14 +31,10 @@
|
|||
<div class="wellbg">
|
||||
<div class="wellheader">
|
||||
<div class="dashboard-wellheader">
|
||||
<h3>Statistics
|
||||
<span class="muted"> | <a href="javascript:void(0)" id="stats-7">7 days</a></span>
|
||||
<span class="muted"> | <a href="javascript:void(0)" id="stats-30">30 days</a></span>
|
||||
<span class="muted"> | <a href="javascript:void(0)" id="stats-90">90 days</a></span>
|
||||
</h3>
|
||||
<h3>Statistics (Past 30 days)</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div id="home-stats">
|
||||
<div id="home-stats" class="user-platforms">
|
||||
<div class='muted'><i class="fa fa-refresh fa-spin"></i> Loading stats...</div><br>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -129,22 +125,7 @@
|
|||
});
|
||||
});
|
||||
|
||||
getHomeStats(7);
|
||||
|
||||
$('#stats-7').click(function() {
|
||||
$('#home-stats').html('<div class="muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div><br>');
|
||||
getHomeStats(7);
|
||||
});
|
||||
|
||||
$('#stats-30').click(function() {
|
||||
$('#home-stats').html('<div class="muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div><br>');
|
||||
getHomeStats(30);
|
||||
});
|
||||
|
||||
$('#stats-90').click(function() {
|
||||
$('#home-stats').html('<div class="muted"><i class="fa fa-refresh fa-spin"></i> Loading stats...</div><br>');
|
||||
getHomeStats(90);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -581,6 +581,7 @@ class PlexWatch(object):
|
|||
for stat in stats_queries:
|
||||
if 'top_tv' in stat:
|
||||
top_tv = []
|
||||
try:
|
||||
query = 'SELECT orig_title, COUNT(orig_title) as total_plays, grandparentRatingKey, MAX(time) as last_watch, xml ' \
|
||||
'FROM %s ' \
|
||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||
|
@ -588,6 +589,9 @@ class PlexWatch(object):
|
|||
'GROUP BY orig_title ' \
|
||||
'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range)
|
||||
result = myDB.select(query)
|
||||
except:
|
||||
logger.warn("Unable to open PlexWatch database.")
|
||||
return None
|
||||
|
||||
for item in result:
|
||||
xml_data = helpers.latinToAscii(item[4])
|
||||
|
@ -619,12 +623,16 @@ class PlexWatch(object):
|
|||
|
||||
elif 'top_users' in stat:
|
||||
top_users = []
|
||||
try:
|
||||
query = 'SELECT user, COUNT(id) as total_plays, MAX(time) as last_watch ' \
|
||||
'FROM %s ' \
|
||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||
'GROUP BY user ' \
|
||||
'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range)
|
||||
result = myDB.select(query)
|
||||
except:
|
||||
logger.warn("Unable to open PlexWatch database.")
|
||||
return None
|
||||
|
||||
for item in result:
|
||||
thumb = self.get_user_gravatar_image(item[0])
|
||||
|
@ -640,12 +648,17 @@ class PlexWatch(object):
|
|||
|
||||
elif 'top_platforms' in stat:
|
||||
top_platform = []
|
||||
|
||||
try:
|
||||
query = 'SELECT platform, COUNT(id) as total_plays, MAX(time) as last_watch, xml ' \
|
||||
'FROM %s ' \
|
||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||
'GROUP BY platform ' \
|
||||
'ORDER BY total_plays DESC' % (self.get_user_table_name(), time_range)
|
||||
result = myDB.select(query)
|
||||
except:
|
||||
logger.warn("Unable to open PlexWatch database.")
|
||||
return None
|
||||
|
||||
for item in result:
|
||||
xml_data = helpers.latinToAscii(item[3])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue