diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index e76baaf9a9..46688d53ad 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -782,7 +782,7 @@ a.itemTag:hover { background: rgba(248, 58, 34, .8); } -.unplayedIndicator { +.unplayedIndicator, .playedIndicator { display: block; position: absolute; top: 5px; @@ -798,7 +798,7 @@ a.itemTag:hover { background: rgba(82, 181, 75, .8); } - .unplayedIndicator div:after { + .unplayedIndicator div:after, .playedIndicator div:after { background-color: transparent !important; } diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 12c37ab58a..441265e0db 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -339,7 +339,7 @@ closePlayMenu: function () { $('.playFlyout').popup("close").remove(); }, - + getHref: function (item, context) { var href = LibraryBrowser.getHrefInternal(item); @@ -737,6 +737,10 @@ var href = options.linkItem === false ? '#' : LibraryBrowser.getHref(item, options.context); + if (item.UserData) { + cssClass += ' posterItemUserData' + item.UserData.Key; + } + html += ''; var style = ""; @@ -793,7 +797,7 @@ if (!options.overlayText) { if (progressHtml) { - html += '
'; + html += '
'; html += "
"; html += progressHtml; html += "
"; @@ -854,7 +858,7 @@ if (options.overlayText) { if (progressHtml) { - html += "
"; + html += "
"; html += progressHtml || " "; html += "
"; } @@ -1053,14 +1057,8 @@ return '
' + item.RecursiveUnplayedItemCount + '
'; } - if (item.PlayedPercentage == 100) { - return '
'; - } - - var userData = item.UserData || {}; - - if (userData.Played) { - return '
'; + if (item.PlayedPercentage == 100 || (item.UserData && item.UserData.Played)) { + return '
'; } } diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index 15845a0497..d0331edcff 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -320,7 +320,7 @@ Dashboard.showLoadingMsg(); $.ajax({ - + type: "POST", url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') }) @@ -335,9 +335,9 @@ } }); } - + function addToCollection(page) { - + var selection = getSelectedItems(page); if (selection.length < 1) { @@ -377,4 +377,48 @@ }); + function renderUserDataChanges(posterItem, userData) { + + if (userData.Played) { + + if (!$('.playedIndicator', posterItem).length) { + + var html = '
'; + + $(html).insertAfter($('.posterItemOverlayTarget', posterItem)); + } + + } else { + $('.playedIndicator', posterItem).remove(); + } + + // TODO: Handle progress bar + // $('.posterItemProgressContainer').remove(); + } + + function onUserDataChanged(userData) { + + $('.posterItemUserData' + userData.Key).each(function () { + renderUserDataChanges(this, userData); + }); + } + + function onWebSocketMessage(e, data) { + + var msg = data; + + if (msg.MessageType === "UserDataChanged") { + + if (msg.Data.UserId == Dashboard.getCurrentUserId()) { + + for (var i = 0, length = msg.Data.UserDataList.length; i < length; i++) { + onUserDataChanged(msg.Data.UserDataList[i]); + } + } + } + + } + + $(ApiClient).on('websocketmessage', onWebSocketMessage); + })(jQuery, document, window); \ No newline at end of file