Add tracks to user recently watched

* Clean up poster styles to match info pages
This commit is contained in:
Jonathan Wong 2015-09-13 23:28:42 -07:00
parent 5eebf6592a
commit 5ec9e41244
4 changed files with 154 additions and 62 deletions

View file

@ -778,36 +778,88 @@ a .dashboard-activity-metadata-user-thumb:hover {
font-weight: bold; font-weight: bold;
color: #F9AA03; color: #F9AA03;
} }
/*.dashboard-activity-instance-overlay {
position: relative;
top: -12px;
text-align: left;
height: 53px;
width: 250px;
border-radius: 0 0 3px 3px;
}*/
.dashboard-recent-media-row { .dashboard-recent-media-row {
width: 100%; width: 100%;
margin:0 auto; margin:0 auto;
text-align: center; text-align: center;
position: relative;
z-index: 0;
} }
.dashboard-recent-media { .dashboard-recent-media {
width: 100%; width: 100%;
margin: auto; margin: auto;
list-style: none; list-style: none;
} }
.dashboard-recent-media-instance {
}
.dashboard-recent-media li { .dashboard-recent-media li {
margin-right: 27px; float: left;
position: relative;
left: 0px;
margin-right: 25px;
margin-bottom: 25px;
}
.dashboard-recent-media-poster {
position: relative; position: relative;
float: left; float: left;
min-height: 340px; }
.dashboard-recent-media-cover {
position: relative;
margin-top: 75px;
float: left;
}
a:hover .dashboard-recent-media-poster,
a:hover .dashboard-recent-media-cover {
webkit-box-shadow: inset 0 0 0 2px #e9a049;
-moz-box-shadow: inset 0 0 0 2px #e9a049;
box-shadow: inset 0 0 0 2px #e9a049;
}
.dashboard-recent-media-poster-face {
background-position: center;
background-size: cover;
height: 225px;
width: 150px;
position: relative;
-webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
z-index: -2;
}
.dashboard-recent-media-cover-face {
background-position: center;
background-size: cover;
height: 150px;
width: 150px;
position: relative;
-webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
z-index: -2;
}
.dashboard-recent-media-overlay {
position: absolute;
left: 0;
right: 0;
bottom: 0;
text-align: left;
background: -moz-linear-gradient(top, rgba(0,0,0,0) 30%, rgba(0,0,0,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(30%,rgba(0,0,0,0)), color-stop(100%,rgba(0,0,0,1)));
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 30%,rgba(0,0,0,1) 100%);
background: -o-linear-gradient(top, rgba(0,0,0,0) 30%,rgba(0,0,0,1) 100%);
background: -ms-linear-gradient(top, rgba(0,0,0,0) 30%,rgba(0,0,0,1) 100%);
background: linear-gradient(to bottom, rgba(0,0,0,0) 30%,rgba(0,0,0,1) 100%);
height: 100%;
z-index: -1;
}
.dashboard-recent-media-overlay-text {
color: #aaa;
font-size: 12px;
float: left;
position: absolute;
left: 8px;
bottom: 5px;
} }
.dashboard-recent-media-metacontainer { .dashboard-recent-media-metacontainer {
width: 150px; width: 150px;
font-size: 13px; font-size: 13px;
margin-bottom: 20px;
clear: both; clear: both;
} }
.dashboard-recent-media-metacontainer h3 { .dashboard-recent-media-metacontainer h3 {
@ -825,6 +877,9 @@ a .dashboard-activity-metadata-user-thumb:hover {
text-align: left; text-align: left;
clear: both; clear: both;
} }
.dashboard-recent-media-metacontainer h3.text-muted {
color: #777;
}
.dashboard-recent-media-metacontainer .text-muted { .dashboard-recent-media-metacontainer .text-muted {
padding: 5px 3px 0 3px; padding: 5px 3px 0 3px;
text-overflow: ellipsis; text-overflow: ellipsis;

View file

@ -31,37 +31,48 @@ DOCUMENTATION :: END
<li> <li>
% if item['type'] == 'season' or item['type'] == 'movie': % if item['type'] == 'season' or item['type'] == 'movie':
<a href="info?item_id=${item['rating_key']}"> <a href="info?item_id=${item['rating_key']}">
<div class="poster"> <div class="dashboard-recent-media-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);"></div> <div class="dashboard-recent-media-poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);">
<div class="dashboard-recent-media-overlay">
<div class="dashboard-recent-media-overlay-text" id="added_at-${item['rating_key']}">
<script>
$('#added_at-${item['rating_key']}').text('Added ' + moment(${item['added_at']}, "X").fromNow())
</script>
</div>
</div>
</div>
</div> </div>
<div class="dashboard-recent-media-metacontainer"> <div class="dashboard-recent-media-metacontainer">
% if item['type'] == 'season': % if item['type'] == 'season':
<h3>${item['parent_title']}</h3> <h3>${item['parent_title']}</h3>
<h3>(${item['title']})</h3> <h3 class="text-muted">${item['title']}</h3>
% elif item['type'] == 'movie': % elif item['type'] == 'movie':
<h3>${item['title']}</h3> <h3>${item['title']}</h3>
<h3>(${item['year']})</h3> <h3 class="text-muted">${item['year']}</h3>
% endif % endif
<div class="text-muted" id="added_at-${item['rating_key']}">${item['added_at']}</div>
</div> </div>
</a> </a>
% elif item['type'] == 'album': % elif item['type'] == 'album':
<a href="info?item_id=${item['rating_key']}"> <a href="info?item_id=${item['rating_key']}">
<div class="poster"> <div class="dashboard-recent-media-cover">
<div class="cover-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=300&fallback=cover);"></div> <div class="dashboard-recent-media-cover-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=300&fallback=cover);">
<div class="dashboard-recent-media-overlay">
<div class="dashboard-recent-media-overlay-text" id="added_at-${item['rating_key']}">
<script>
$('#added_at-${item['rating_key']}').text('Added ' + moment(${item['added_at']}, "X").fromNow())
</script>
</div>
</div>
</div>
</div> </div>
<div class="dashboard-recent-media-metacontainer"> <div class="dashboard-recent-media-metacontainer">
<h3>${item['parent_title']}</h3> <h3>${item['parent_title']}</h3>
<h3>${item['title']}</h3> <h3 class="text-muted">${item['title']}</h3>
<div class="text-muted" id="added_at-${item['rating_key']}">${item['added_at']}</div>
</div> </div>
</a> </a>
% endif % endif
</li> </li>
</div> </div>
<script>
$('#added_at-${item['rating_key']}').html('Added ' + moment(${item['added_at']}, "X").fromNow())
</script>
% endfor % endfor
</ul> </ul>
</div> </div>

View file

@ -32,29 +32,54 @@ DOCUMENTATION :: END
<div class="dashboard-recent-media-row"> <div class="dashboard-recent-media-row">
<ul class="dashboard-recent-media list-unstyled"> <ul class="dashboard-recent-media list-unstyled">
% for item in data: % for item in data:
<div class="dashboard-recent-media-instance"> <li>
<li> % if item['type'] == 'episode' or item['type'] == 'movie':
<a href="info?source=history&item_id=${item['row_id']}"> <a href="info?source=history&item_id=${item['row_id']}">
<div class="poster"> <div class="dashboard-recent-media-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);"></div> <div class="dashboard-recent-media-poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);">
<div class="dashboard-recent-media-overlay">
<div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
<script>
$('#time-${item['time']}').text('Watched ' + moment(${item['time']}, "X").fromNow())
</script>
</div>
</div>
</div> </div>
<div class="dashboard-recent-media-metacontainer"> </div>
% if item['type'] == 'episode': <div class="dashboard-recent-media-metacontainer">
<h3>${item['parent_title']}</h3> % if item['type'] == 'episode':
<h3>${item['title']}</h3> <h3>${item['grandparent_title']}</h3>
<h3>(Season ${item['parent_index']}, Episode ${item['index']})</h3> <h3>${item['title']}</h3>
% elif item['type'] == 'movie': <h3 class="text-muted">S${item['parent_index']} &middot; E${item['index']}</h3>
<h3>${item['title']}</h3> % elif item['type'] == 'movie':
<h3>(${item['year']})</h3> <h3>${item['title']}</h3>
% endif <h3 class="text-muted">${item['year']}</h3>
<div class="text-muted" id="time-${item['time']}">${item['time']}</div> % endif
</div> <div class="text-muted" id="time-${item['time']}">
</a> </div>
</li> </div>
</div> </a>
<script> % elif item['type'] == 'track':
$('#time-${item['time']}').html('Watched ' + moment(${item['time']}, "X").fromNow()) <a href="info?source=history&item_id=${item['row_id']}">
</script> <div class="dashboard-recent-media-cover">
<div class="dashboard-recent-media-cover-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=300&fallback=cover);">
<div class="dashboard-recent-media-overlay">
<div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
<script>
$('#time-${item['time']}').text('Watched ' + moment(${item['time']}, "X").fromNow())
</script>
</div>
</div>
</div>
</div>
<div class="dashboard-recent-media-metacontainer">
<h3>${item['grandparent_title']}</h3>
<h3>${item['title']}</h3>
<h3 class="text-muted">${item['parent_title']}</h3>
</div>
</a>
% endif
</li>
% endfor % endfor
</ul> </ul>
</div> </div>

View file

@ -524,23 +524,23 @@ class DataFactory(object):
try: try:
if user_id: if user_id:
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \ 'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
'FROM session_history_metadata ' \ 'FROM session_history_metadata ' \
'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \
'WHERE user_id = ? AND session_history.media_type != "track" ORDER BY started DESC LIMIT ?' 'WHERE user_id = ? ORDER BY started DESC LIMIT ?'
result = monitor_db.select(query, args=[user_id, limit]) result = monitor_db.select(query, args=[user_id, limit])
elif user: elif user:
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \ 'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
'FROM session_history_metadata ' \ 'FROM session_history_metadata ' \
'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \
'WHERE user = ? AND session_history.media_type != "track" ORDER BY started DESC LIMIT ?' 'WHERE user = ? ORDER BY started DESC LIMIT ?'
result = monitor_db.select(query, args=[user, limit]) result = monitor_db.select(query, args=[user, limit])
else: else:
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \ 'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
'FROM session_history_metadata WHERE session_history.media_type != "track"' \ 'FROM session_history_metadata ' \
'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \
'ORDER BY started DESC LIMIT ?' 'ORDER BY started DESC LIMIT ?'
result = monitor_db.select(query, args=[limit]) result = monitor_db.select(query, args=[limit])
@ -549,24 +549,25 @@ class DataFactory(object):
return None return None
for row in result: for row in result:
if row[1] == 'episode' and row[6]: if row[1] == 'episode' and row[7]:
thumb = row[6]
elif row[1] == 'episode':
thumb = row[7] thumb = row[7]
elif row[1] == 'episode':
thumb = row[8]
else: else:
thumb = row[5] thumb = row[6]
recent_output = {'row_id': row[0], recent_output = {'row_id': row[0],
'type': row[1], 'type': row[1],
'rating_key': row[2], 'rating_key': row[2],
'title': row[3], 'title': row[3],
'parent_title': row[4], 'parent_title': row[4],
'grandparent_title': row[5],
'thumb': thumb, 'thumb': thumb,
'index': row[8], 'index': row[9],
'parent_index': row[9], 'parent_index': row[10],
'year': row[10], 'year': row[11],
'time': row[11], 'time': row[12],
'user': row[12] 'user': row[13]
} }
recently_watched.append(recent_output) recently_watched.append(recent_output)