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
|
@ -8101,4 +8101,52 @@ ol.test >li {
|
||||||
}
|
}
|
||||||
.charts-slider-title-views {
|
.charts-slider-title-views {
|
||||||
float: right;
|
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']:
|
% if stats != None:
|
||||||
<div class="dashboard-recent-media-row">
|
% if stats[0]['rows']:
|
||||||
<ul class="dashboard-recent-media">
|
<div class="user-platforms">
|
||||||
% for a in stats:
|
<ul>
|
||||||
<div class="dashboard-recent-media-instance">
|
% for a in stats:
|
||||||
% if a['stat_id'] == 'top_tv':
|
% if a['stat_id'] == 'top_tv':
|
||||||
<li>
|
<div class="home-platforms-instance">
|
||||||
<div class="poster">
|
<li>
|
||||||
<h5>Most watched TV</h5><br/>
|
<span>
|
||||||
<div class="poster-face">
|
<a href="info?rating_key=${a['rows'][0]['rating_key']}">
|
||||||
<a href="info?rating_key=${a['rows'][0]['rating_key']}">
|
% if a['rows'][0]['grandparent_thumb'] != '':
|
||||||
% if a['rows'][0]['grandparent_thumb'] != '':
|
<img class="home-platforms-instance-poster" src="pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=153&height=225">
|
||||||
<img src="pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=153&height=225" class="poster-face">
|
% else:
|
||||||
% else:
|
<img class="home-platforms-instance-poster" src="interfaces/default/images/poster.png">
|
||||||
<img src="interfaces/default/images/poster.png" class="poster-face">
|
% endif
|
||||||
% endif
|
</a>
|
||||||
</a>
|
</span>
|
||||||
</div>
|
<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 class="user-platforms-instance-playcount">
|
||||||
|
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-recent-media-metacontainer">
|
% elif a['stat_id'] == 'top_users':
|
||||||
<h3>${a['rows'][0]['orig_title']}</h3>
|
<div class="home-platforms-instance">
|
||||||
<div class="muted">Plays: ${a['rows'][0]['total_plays']}</div>
|
<li>
|
||||||
|
<span>
|
||||||
|
<a href="user?user=${a['rows'][0]['user']}">
|
||||||
|
% if a['rows'][0]['thumb'] != '':
|
||||||
|
<img class="home-platforms-instance-oval" src="${a['rows'][0]['thumb']}" class="poster-face">
|
||||||
|
% else:
|
||||||
|
<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 class="user-platforms-instance-playcount">
|
||||||
|
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
% elif a['stat_id'] == 'top_platforms':
|
||||||
% elif a['stat_id'] == 'top_users':
|
<div class="home-platforms-instance">
|
||||||
<li>
|
<li>
|
||||||
<div class="poster">
|
<div id="platform-stat">
|
||||||
<h5>Most active user</h5><br/>
|
<img class="home-platforms-instance-box" src="interfaces/default/images/platforms/default.png">
|
||||||
<div class="poster-face">
|
</div>
|
||||||
<a href="user?user=${a['rows'][0]['user']}">
|
<div class="home-platforms-instance-name">
|
||||||
% if a['rows'][0]['thumb'] != '':
|
<h4>Most Active Platform</h4>
|
||||||
<img src="${a['rows'][0]['thumb']}" class="poster-face">
|
<h5>${a['rows'][0]['platform_type']}</h5>
|
||||||
% else:
|
</div>
|
||||||
<img src="interfaces/default/images/gravatar-default.png" class="poster-face">
|
<div class="user-platforms-instance-playcount">
|
||||||
% endif
|
<h3>${a['rows'][0]['total_plays']}</h3><p> plays</p>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-recent-media-metacontainer">
|
<script>
|
||||||
<h3>${a['rows'][0]['user']}</h3>
|
$("#platform-stat").html("<img class='home-platforms-instance-box' src='" + getPlatformImagePath('${a['rows'][0]['platform_type']}') + "'>");
|
||||||
<div class="muted">Plays: ${a['rows'][0]['total_plays']}</div>
|
</script>
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
% elif a['stat_id'] == 'top_platforms':
|
|
||||||
<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>
|
|
||||||
</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>
|
|
||||||
</li>
|
|
||||||
<script>
|
|
||||||
$("#platform-face").html("<img class='user-platforms-instance-poster' src='" + getPlatformImagePath('${a['rows'][0]['platform_type']}') + "'>");
|
|
||||||
</script>
|
|
||||||
% endif
|
% endif
|
||||||
</div>
|
% endfor
|
||||||
% endfor
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
% else:
|
||||||
|
<div class="muted">No stats for selected period.</div><br>
|
||||||
|
% endif
|
||||||
% else:
|
% else:
|
||||||
<div class="muted">No stats for selected period.</div><br>
|
<div class="muted">There was an error loading your PlexWatch data. Please check your <a href="config">settings</a>.</div><br>
|
||||||
% endif
|
% endif
|
|
@ -31,14 +31,10 @@
|
||||||
<div class="wellbg">
|
<div class="wellbg">
|
||||||
<div class="wellheader">
|
<div class="wellheader">
|
||||||
<div class="dashboard-wellheader">
|
<div class="dashboard-wellheader">
|
||||||
<h3>Statistics
|
<h3>Statistics (Past 30 days)</h3>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</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 class='muted'><i class="fa fa-refresh fa-spin"></i> Loading stats...</div><br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,22 +125,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
getHomeStats(7);
|
getHomeStats(30);
|
||||||
|
|
||||||
$('#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>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -581,13 +581,17 @@ class PlexWatch(object):
|
||||||
for stat in stats_queries:
|
for stat in stats_queries:
|
||||||
if 'top_tv' in stat:
|
if 'top_tv' in stat:
|
||||||
top_tv = []
|
top_tv = []
|
||||||
query = 'SELECT orig_title, COUNT(orig_title) as total_plays, grandparentRatingKey, MAX(time) as last_watch, xml ' \
|
try:
|
||||||
'FROM %s ' \
|
query = 'SELECT orig_title, COUNT(orig_title) as total_plays, grandparentRatingKey, MAX(time) as last_watch, xml ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'FROM %s ' \
|
||||||
'AND episode != "" ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||||
'GROUP BY orig_title ' \
|
'AND episode != "" ' \
|
||||||
'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range)
|
'GROUP BY orig_title ' \
|
||||||
result = myDB.select(query)
|
'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:
|
for item in result:
|
||||||
xml_data = helpers.latinToAscii(item[4])
|
xml_data = helpers.latinToAscii(item[4])
|
||||||
|
@ -619,12 +623,16 @@ class PlexWatch(object):
|
||||||
|
|
||||||
elif 'top_users' in stat:
|
elif 'top_users' in stat:
|
||||||
top_users = []
|
top_users = []
|
||||||
query = 'SELECT user, COUNT(id) as total_plays, MAX(time) as last_watch ' \
|
try:
|
||||||
'FROM %s ' \
|
query = 'SELECT user, COUNT(id) as total_plays, MAX(time) as last_watch ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'FROM %s ' \
|
||||||
'GROUP BY user ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||||
'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range)
|
'GROUP BY user ' \
|
||||||
result = myDB.select(query)
|
'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:
|
for item in result:
|
||||||
thumb = self.get_user_gravatar_image(item[0])
|
thumb = self.get_user_gravatar_image(item[0])
|
||||||
|
@ -640,12 +648,17 @@ class PlexWatch(object):
|
||||||
|
|
||||||
elif 'top_platforms' in stat:
|
elif 'top_platforms' in stat:
|
||||||
top_platform = []
|
top_platform = []
|
||||||
query = 'SELECT platform, COUNT(id) as total_plays, MAX(time) as last_watch, xml ' \
|
|
||||||
'FROM %s ' \
|
try:
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
query = 'SELECT platform, COUNT(id) as total_plays, MAX(time) as last_watch, xml ' \
|
||||||
'GROUP BY platform ' \
|
'FROM %s ' \
|
||||||
'ORDER BY total_plays DESC' % (self.get_user_table_name(), time_range)
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
||||||
result = myDB.select(query)
|
'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:
|
for item in result:
|
||||||
xml_data = helpers.latinToAscii(item[3])
|
xml_data = helpers.latinToAscii(item[3])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue