Add recently added to home screen.

This commit is contained in:
Tim 2015-06-16 23:22:03 +02:00
commit 473ea7513c
4 changed files with 195 additions and 1 deletions

View file

@ -26,11 +26,22 @@
</div>
</div>
</div>
<div class='row-fluid'>
<div class='wellbg'>
<div class='wellheader'>
<div class='dashboard-wellheader'>
<h3>Recently Added</h3>
</div>
</div>
<div id='recentlyAdded'><div id='recently-added-spinner' class='spinner'></div></div>
</div>
</div>
<footer></footer>
</div>
</%def>
<%def name="javascriptIncludes()">
<script src="interfaces/default/js/moment-with-locale.js"></script>
<script>
function currentActivity() {
$.ajax({
@ -58,6 +69,32 @@
currentActivityHeader();
setInterval(currentActivityHeader, 15000);
function recentlyAdded() {
var widthVal = $('body').find(".container-fluid").width();
var tmp = widthVal / 182;
if (tmp > 0) {
containerSize = parseInt(tmp);
} else {
containerSize = 1;
}
$.ajax({
url: 'get_recently_added',
type: "GET",
async: true,
data: { count : containerSize },
complete: function(xhr, status) {
$("#recentlyAdded").html(xhr.responseText);
}
});
}
$(document).ready(function () {
recentlyAdded();
$(window).resize(function() {
recentlyAdded();
});
});
</script>
</%def>

View file

@ -0,0 +1,36 @@
% if recently_added != None:
<div class="dashboard-recent-media-row">
<ul class="dashboard-recent-media">
% for item in recently_added:
<div class="dashboard-recent-media-instance">
<li>
<div class="poster">
<div class="poster-face">
<a href="info?rating_key=${item['ratingKey']}">
% if item['thumb'] != '':
<img src="pms_image_proxy?img=${item['thumb']}&width=153&height=225" class="poster-face">
% else:
<img src="interfaces/default/images/poster.png" class="poster-face">
% endif
</a>
</div>
</div>
<div class="dashboard-recent-media-metacontainer">
% if item['type'] == 'season':
<h3>${item['title']}</h3>
% elif item['type'] == 'movie':
<h3>${item['title']} (${item['year']})</h3>
% endif
<h4><span id="addedAt-${item['ratingKey']}">${item['addedAt']}</span></h4>
</div>
</li>
</div>
<script>
$('#addedAt-${item['ratingKey']}').html('Added ' + moment(${item['addedAt']}, "X").fromNow())
</script>
% endfor
</ul>
</div>
% else:
<h4>No recently added items.</h4>
% endif