mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Group library statistic cards by library type
This commit is contained in:
parent
b22ae58f79
commit
359273e26e
4 changed files with 83 additions and 81 deletions
|
@ -1188,6 +1188,9 @@ a .dashboard-activity-metadata-user-thumb:hover {
|
||||||
-webkit-flex-grow: 1;
|
-webkit-flex-grow: 1;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
.dashboard-stats-info-title.library h4 {
|
||||||
|
flex-basis: 200px;
|
||||||
|
}
|
||||||
.dashboard-stats-info-title .dashboard-stats-stats-units {
|
.dashboard-stats-info-title .dashboard-stats-stats-units {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
@ -1198,6 +1201,9 @@ a .dashboard-activity-metadata-user-thumb:hover {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-width: 125px;
|
max-width: 125px;
|
||||||
}
|
}
|
||||||
|
.dashboard-stats-info-title .dashboard-stats-stats-units.library {
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
.dashboard-stats-info-scroller {
|
.dashboard-stats-info-scroller {
|
||||||
height: 120px;
|
height: 120px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -1238,7 +1244,7 @@ a .dashboard-activity-metadata-user-thumb:hover {
|
||||||
.dashboard-stats-info-item:last-of-type {
|
.dashboard-stats-info-item:last-of-type {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.dashboard-stats-info-item .sub-heading {
|
.dashboard-stats-info-item .sub-list {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
|
@ -1269,6 +1275,16 @@ a .dashboard-activity-metadata-user-thumb:hover {
|
||||||
-webkit-flex-shrink: 0;
|
-webkit-flex-shrink: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
.dashboard-stats-info-item .sub-divider {
|
||||||
|
height: 100%;
|
||||||
|
margin-left: 10px;
|
||||||
|
color: #aaa;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: left;
|
||||||
|
text-transform: uppercase;
|
||||||
|
-webkit-flex-shrink: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
.dashboard-stats-info-item.expanded {
|
.dashboard-stats-info-item.expanded {
|
||||||
padding: 5px 5px;
|
padding: 5px 5px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
@ -1282,6 +1298,9 @@ a .dashboard-activity-metadata-user-thumb:hover {
|
||||||
.dashboard-stats-info-item.expanded .sub-count {
|
.dashboard-stats-info-item.expanded .sub-count {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
.dashboard-stats-info-item.expanded .sub-divider {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
.dashboard-stats-info-item:hover {
|
.dashboard-stats-info-item:hover {
|
||||||
background-color: rgba(255,255,255,0.05);
|
background-color: rgba(255,255,255,0.05);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ DOCUMENTATION :: END
|
||||||
data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_type')}"
|
data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_type')}"
|
||||||
data-user_id="${row.get('user_id')}" data-friendly_name="${row.get('friendly_name')}"
|
data-user_id="${row.get('user_id')}" data-friendly_name="${row.get('friendly_name')}"
|
||||||
data-last_watch="${row.get('last_watch')}" data-started="${row.get('started')}">
|
data-last_watch="${row.get('last_watch')}" data-started="${row.get('started')}">
|
||||||
<div class="sub-heading">${loop.index + 1}</div>
|
<div class="sub-list">${loop.index + 1}</div>
|
||||||
<div class="sub-value">
|
<div class="sub-value">
|
||||||
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
||||||
% if top_stat['rows'][loop.index]['rating_key']:
|
% if top_stat['rows'][loop.index]['rating_key']:
|
||||||
|
|
|
@ -24,75 +24,55 @@ DOCUMENTATION :: END
|
||||||
</%doc>
|
</%doc>
|
||||||
|
|
||||||
% if data:
|
% if data:
|
||||||
% for library in data:
|
|
||||||
<%
|
<%
|
||||||
section_id = library['section_id']
|
types = ('movie', 'show', 'artist', 'photo')
|
||||||
|
headers = {'movie': ('Movie Libraries', ('Movies', '', '')),
|
||||||
|
'show': ('TV Show Libraries', ('Shows', 'Seasons', 'Episodes')),
|
||||||
|
'artist': ('Music Libraries', ('Artists', 'Albums', 'Tracks')),
|
||||||
|
'photo': ('Photo Libraries', ('Albums', '', 'Photos'))}
|
||||||
%>
|
%>
|
||||||
<div class="dashboard-stats-instance" id="library-stats-instance-${section_id}" data-section_id="${section_id}">
|
% for section_type in types:
|
||||||
|
% if section_type in data:
|
||||||
|
<div class="dashboard-stats-instance" id="library-stats-instance-${section_type}" data-section_type="${section_type}">
|
||||||
<div class="dashboard-stats-container">
|
<div class="dashboard-stats-container">
|
||||||
<div class="dashboard-stats-background-overlay">
|
<div class="dashboard-stats-background-overlay">
|
||||||
<div id="library-stats-background-${section_id}" class="dashboard-stats-background" style="background-image: url(pms_image_proxy?img=${library['art']}&width=500&height=280&fallback=art);"></div>
|
<div id="library-stats-background-${section_type}" class="dashboard-stats-background" style="background-image: url(pms_image_proxy?img=/:/resources/${section_type}-fanart.jpg&width=500&height=280&fallback=art);"></div>
|
||||||
<a href="library?section_id=${library['section_id']}" title="${library['section_name']}">
|
<div id="library-stats-thumb-${section_type}" class="dashboard-stats-library hidden-xs" style="background-image: url(pms_image_proxy?img=/:/resources/${section_type}.png&width=300&height=300&fallback=cover);"></div>
|
||||||
% if library['thumb'].startswith("http"):
|
|
||||||
<div id="library-stats-thumb-${section_id}" class="dashboard-stats-library hidden-xs" style="background-image: url(${library['thumb']});"></div>
|
|
||||||
% else:
|
|
||||||
<div id="library-stats-thumb-${section_id}" class="dashboard-stats-library hidden-xs" style="background-image: url(pms_image_proxy?img=${library['thumb']}&width=300&height=300&fallback=cover);"></div>
|
|
||||||
% endif
|
|
||||||
</a>
|
|
||||||
<div class="dashboard-stats-info-container">
|
<div class="dashboard-stats-info-container">
|
||||||
<div id="library-stats-title-${section_id}" class="dashboard-stats-info-title">
|
<div id="library-stats-title-${section_type}" class="dashboard-stats-info-title library">
|
||||||
<h4>
|
<h4>${headers[section_type][0]}</h4>
|
||||||
<a href="library?section_id=${library['section_id']}" title="${library['section_name']}">${library['section_name']}</a>
|
<span class="dashboard-stats-stats-units library">${' / '.join(u for u in headers[section_type][1] if u)}</span>
|
||||||
</h4>
|
|
||||||
<span class="dashboard-stats-stats-units">items</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-stats-info-scroller scrollbar-macosx">
|
<div class="dashboard-stats-info-scroller scrollbar-macosx">
|
||||||
<div class="dashboard-stats-info scoller-content">
|
<div class="dashboard-stats-info scoller-content">
|
||||||
<ul class="list-unstyled dashboard-stats-info-list">
|
<ul class="list-unstyled dashboard-stats-info-list">
|
||||||
<%
|
% for section in data[section_type]:
|
||||||
h1 = h2 = h3 = ''
|
<li class="dashboard-stats-info-item ${'expanded' if loop.index == 0 else ''}">
|
||||||
if library['section_type'] == 'movie':
|
<div class="sub-list">${loop.index + 1}</div>
|
||||||
h1 = 'Movies'
|
|
||||||
if library['section_type'] == 'show':
|
|
||||||
h1, h2, h3 = 'Shows', 'Seasons', 'Episodes'
|
|
||||||
elif library['section_type'] == 'artist':
|
|
||||||
h1, h2, h3 = 'Artists', 'Albums', 'Tracks'
|
|
||||||
elif library['section_type'] == 'photo':
|
|
||||||
h1, h3 = 'Albums', 'Photos'
|
|
||||||
%>
|
|
||||||
% if h1:
|
|
||||||
<li class="dashboard-stats-info-item expanded">
|
|
||||||
<div class="sub-heading">•</div>
|
|
||||||
<div class="sub-value">
|
<div class="sub-value">
|
||||||
${h1}
|
<a href="library?section_id=${section['section_id']}" title="${section['section_name']}">
|
||||||
|
${section['section_name']}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
% if headers[section_type][1][0]:
|
||||||
<div class="sub-count">
|
<div class="sub-count">
|
||||||
${library['count']}
|
${section['count']}
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
% endif
|
|
||||||
% if h2:
|
|
||||||
<li class="dashboard-stats-info-item expanded">
|
|
||||||
<div class="sub-heading">•</div>
|
|
||||||
<div class="sub-value">
|
|
||||||
${h2}
|
|
||||||
</div>
|
</div>
|
||||||
|
% endif
|
||||||
|
% if headers[section_type][1][1]:
|
||||||
|
<div class="sub-divider"> / </div>
|
||||||
<div class="sub-count">
|
<div class="sub-count">
|
||||||
${library['parent_count']}
|
${section['child_count']}
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
% endif
|
|
||||||
% if h3:
|
|
||||||
<li class="dashboard-stats-info-item expanded">
|
|
||||||
<div class="sub-heading">•</div>
|
|
||||||
<div class="sub-value">
|
|
||||||
${h3}
|
|
||||||
</div>
|
</div>
|
||||||
|
% endif
|
||||||
|
% if headers[section_type][1][2]:
|
||||||
|
<div class="sub-divider"> / </div>
|
||||||
<div class="sub-count">
|
<div class="sub-count">
|
||||||
${library['child_count']}
|
${section['grandchild_count']}
|
||||||
</div>
|
</div>
|
||||||
|
% endif
|
||||||
</li>
|
</li>
|
||||||
% endif
|
% endfor
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -100,6 +80,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
% else:
|
% else:
|
||||||
<div class="text-muted">No stats to show.</div><br>
|
<div class="text-muted">No stats to show.</div><br>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from itertools import groupby
|
||||||
|
|
||||||
import plexpy
|
import plexpy
|
||||||
import common
|
import common
|
||||||
|
@ -832,36 +833,37 @@ class DataFactory(object):
|
||||||
|
|
||||||
library_stats = []
|
library_stats = []
|
||||||
|
|
||||||
for id in library_cards:
|
try:
|
||||||
if id.isdigit():
|
query = 'SELECT section_id, section_name, section_type, thumb AS library_thumb, ' \
|
||||||
try:
|
'custom_thumb_url AS custom_thumb, art, count, parent_count, child_count ' \
|
||||||
query = 'SELECT section_id, section_name, section_type, thumb AS library_thumb, ' \
|
'FROM library_sections ' \
|
||||||
'custom_thumb_url AS custom_thumb, art, count, parent_count, child_count ' \
|
'WHERE section_id IN (%s) ' \
|
||||||
'FROM library_sections ' \
|
'ORDER BY section_type, count DESC, parent_count DESC, child_count DESC ' % ','.join(library_cards)
|
||||||
'WHERE section_id = %s ' % id
|
result = monitor_db.select(query)
|
||||||
result = monitor_db.select(query)
|
except Exception as e:
|
||||||
except Exception as e:
|
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for get_library_stats: %s." % e)
|
||||||
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for get_library_stats: %s." % e)
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
for item in result:
|
for item in result:
|
||||||
if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
|
if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
|
||||||
library_thumb = item['custom_thumb']
|
library_thumb = item['custom_thumb']
|
||||||
elif item['library_thumb']:
|
elif item['library_thumb']:
|
||||||
library_thumb = item['library_thumb']
|
library_thumb = item['library_thumb']
|
||||||
else:
|
else:
|
||||||
library_thumb = common.DEFAULT_COVER_THUMB
|
library_thumb = common.DEFAULT_COVER_THUMB
|
||||||
|
|
||||||
library = {'section_id': item['section_id'],
|
library = {'section_id': item['section_id'],
|
||||||
'section_name': item['section_name'],
|
'section_name': item['section_name'],
|
||||||
'section_type': item['section_type'],
|
'section_type': item['section_type'],
|
||||||
'thumb': library_thumb,
|
'thumb': library_thumb,
|
||||||
'art': item['art'],
|
'art': item['art'],
|
||||||
'count': item['count'],
|
'count': item['count'],
|
||||||
'parent_count': item['parent_count'],
|
'child_count': item['parent_count'],
|
||||||
'child_count': item['child_count']
|
'grandchild_count': item['child_count']
|
||||||
}
|
}
|
||||||
library_stats.append(library)
|
library_stats.append(library)
|
||||||
|
|
||||||
|
library_stats = {k: list(v) for k, v in groupby(library_stats, key=lambda x: x['section_type'])}
|
||||||
|
|
||||||
return library_stats
|
return library_stats
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue