From 1fbbb143fe7e5018cfca7cc4fde89e546a2aad35 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 22 Jan 2014 21:19:04 -0500 Subject: [PATCH] fixes #683 - Support disabling playback per user --- dashboard-ui/css/librarybrowser.css | 2 +- dashboard-ui/scripts/itembynamedetailpage.js | 12 ++--- dashboard-ui/scripts/itemdetailpage.js | 49 ++++++++++---------- dashboard-ui/scripts/librarybrowser.js | 4 +- dashboard-ui/scripts/livetvchannel.js | 12 ++--- dashboard-ui/scripts/livetvrecording.js | 12 ++--- dashboard-ui/scripts/mediaplayer.js | 6 ++- dashboard-ui/scripts/useredit.js | 2 + dashboard-ui/useredit.html | 18 ++++--- 9 files changed, 63 insertions(+), 54 deletions(-) diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index 2498c9b13c..b12d074d91 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -385,7 +385,7 @@ a.itemTag:hover { background-size: cover; background-position: center 15%; background-repeat: no-repeat; - height: 580px; + height: 600px; border-bottom: 1px solid #111; position: relative; } diff --git a/dashboard-ui/scripts/itembynamedetailpage.js b/dashboard-ui/scripts/itembynamedetailpage.js index 802ce0673e..9a5e9dd069 100644 --- a/dashboard-ui/scripts/itembynamedetailpage.js +++ b/dashboard-ui/scripts/itembynamedetailpage.js @@ -79,14 +79,14 @@ ApiClient.sendWebSocketMessage("Context", vals.join('|')); } - if (MediaPlayer.canPlay(item)) { - $('#playButtonContainer', page).show(); - } else { - $('#playButtonContainer', page).hide(); - } - Dashboard.getCurrentUser().done(function (user) { + if (MediaPlayer.canPlay(item, user)) { + $('#playButtonContainer', page).show(); + } else { + $('#playButtonContainer', page).hide(); + } + var editImagesHref = user.Configuration.IsAdministrator ? 'edititemimages.html' + window.location.search : null; $('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item, editImagesHref)); diff --git a/dashboard-ui/scripts/itemdetailpage.js b/dashboard-ui/scripts/itemdetailpage.js index 39bad760d0..1cc9b64d5b 100644 --- a/dashboard-ui/scripts/itemdetailpage.js +++ b/dashboard-ui/scripts/itemdetailpage.js @@ -35,6 +35,30 @@ $('#editButtonContainer', page).hide(); } + if (MediaPlayer.canPlay(item, user) && item.LocationType !== "Offline" && item.LocationType !== "Virtual") { + + var url = MediaPlayer.getPlayUrl(item); + + if (url) { + $('#playExternalButtonContainer', page).show(); + $('#playButtonContainer', page).hide(); + } else { + $('#playButtonContainer', page).show(); + $('#playExternalButtonContainer', page).hide(); + } + + $('#btnPlayExternal', page).attr('href', url || '#'); + + } else { + $('#playButtonContainer', page).hide(); + $('#playExternalButtonContainer', page).hide(); + } + + if (item.LocalTrailerCount && item.LocationType !== "Offline" && user.Configuration.EnableMediaPlayback) { + $('#trailerButtonContainer', page).show(); + } else { + $('#trailerButtonContainer', page).hide(); + } }); if (item.LocationType == "Offline") { @@ -65,31 +89,6 @@ $('#missingIndicator', page).hide(); } - if (MediaPlayer.canPlay(item) && item.LocationType !== "Offline" && item.LocationType !== "Virtual") { - - var url = MediaPlayer.getPlayUrl(item); - - if (url) { - $('#playExternalButtonContainer', page).show(); - $('#playButtonContainer', page).hide(); - } else { - $('#playButtonContainer', page).show(); - $('#playExternalButtonContainer', page).hide(); - } - - $('#btnPlayExternal', page).attr('href', url || '#'); - - } else { - $('#playButtonContainer', page).hide(); - $('#playExternalButtonContainer', page).hide(); - } - - if (item.LocalTrailerCount && item.LocationType !== "Offline") { - $('#trailerButtonContainer', page).show(); - } else { - $('#trailerButtonContainer', page).hide(); - } - $(".autoNumeric").autoNumeric('init'); setPeopleHeader(page, item); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 588fd157c1..c98334839f 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -2527,7 +2527,7 @@ var buttonCount = 0; - if (MediaPlayer.canPlay(item)) { + if (MediaPlayer.canPlay(item, currentUser)) { var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0; var onPlayClick = 'LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'' + item.Type + '\', \'' + item.MediaType + '\', ' + resumePosition + ');return false;'; @@ -2541,7 +2541,7 @@ } } - if (item.LocalTrailerCount) { + if (item.LocalTrailerCount && currentUser.Configuration.EnableMediaPlayback) { html += ''; buttonCount++; } diff --git a/dashboard-ui/scripts/livetvchannel.js b/dashboard-ui/scripts/livetvchannel.js index 7e0177b4b6..b76c896987 100644 --- a/dashboard-ui/scripts/livetvchannel.js +++ b/dashboard-ui/scripts/livetvchannel.js @@ -144,14 +144,14 @@ ApiClient.sendWebSocketMessage("Context", vals.join('|')); } - if (MediaPlayer.canPlay(item)) { - $('#playButtonContainer', page).show(); - } else { - $('#playButtonContainer', page).hide(); - } - Dashboard.getCurrentUser().done(function (user) { + if (MediaPlayer.canPlay(item, user)) { + $('#playButtonContainer', page).show(); + } else { + $('#playButtonContainer', page).hide(); + } + if (user.Configuration.IsAdministrator && item.LocationType !== "Offline") { $('#editButtonContainer', page).show(); } else { diff --git a/dashboard-ui/scripts/livetvrecording.js b/dashboard-ui/scripts/livetvrecording.js index 9eab912b83..ab58ae78d1 100644 --- a/dashboard-ui/scripts/livetvrecording.js +++ b/dashboard-ui/scripts/livetvrecording.js @@ -64,16 +64,16 @@ ApiClient.sendWebSocketMessage("Context", vals.join('|')); } - if (MediaPlayer.canPlay(item)) { - $('#playButtonContainer', page).show(); - } else { - $('#playButtonContainer', page).hide(); - } - $('.status', page).html('Status:   ' + item.Status); Dashboard.getCurrentUser().done(function (user) { + if (MediaPlayer.canPlay(item, user)) { + $('#playButtonContainer', page).show(); + } else { + $('#playButtonContainer', page).hide(); + } + if (user.Configuration.IsAdministrator && item.LocationType !== "Offline") { $('#deleteButtonContainer', page).show(); } else { diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 39aed1c255..1d01336179 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -999,8 +999,12 @@ }, 4000); } - self.canPlay = function (item) { + self.canPlay = function (item, user) { + if (!user.Configuration.EnableMediaPlayback) { + return false; + } + if (item.LocationType == "Virtual") { return false; } diff --git a/dashboard-ui/scripts/useredit.js b/dashboard-ui/scripts/useredit.js index a3f9865193..07749682d3 100644 --- a/dashboard-ui/scripts/useredit.js +++ b/dashboard-ui/scripts/useredit.js @@ -22,6 +22,7 @@ $('#chkDisabled', page).checked(user.Configuration.IsDisabled || false).checkboxradio("refresh"); $('#chkIsHidden', page).checked(user.Configuration.IsHidden || false).checkboxradio("refresh"); $('#chkEnableRemoteControlOtherUsers', page).checked(user.Configuration.EnableRemoteControlOfOtherUsers || false).checkboxradio("refresh"); + $('#chkEnableMediaPlayback', page).checked(user.Configuration.EnableMediaPlayback || false).checkboxradio("refresh"); $('#chkManageLiveTv', page).checked(user.Configuration.EnableLiveTvManagement || false).checkboxradio("refresh"); @@ -55,6 +56,7 @@ user.Configuration.IsDisabled = $('#chkDisabled', page).checked(); user.Configuration.EnableRemoteControlOfOtherUsers = $('#chkEnableRemoteControlOtherUsers', page).checked(); user.Configuration.EnableLiveTvManagement = $('#chkManageLiveTv', page).checked(); + user.Configuration.EnableMediaPlayback = $('#chkEnableMediaPlayback', page).checked(); var userId = getParameterByName("userId"); diff --git a/dashboard-ui/useredit.html b/dashboard-ui/useredit.html index 7780fd7def..ec145922f2 100644 --- a/dashboard-ui/useredit.html +++ b/dashboard-ui/useredit.html @@ -29,24 +29,28 @@

Feature Access

- + + +
+
+
- - + +