fixes #1001 - Support downloading

This commit is contained in:
Luke Pulverenti 2015-02-06 00:39:07 -05:00
parent 0fa6a27827
commit 622daeb572
13 changed files with 73 additions and 286 deletions

View File

@ -66,6 +66,12 @@ body {
overflow-y: hidden !important;
}
.jqmButtonNoText {
padding: 3px 4px!important;
border-radius: 4px!important;
vertical-align: top;
}
.textlink {
text-decoration: none;
}

View File

@ -134,7 +134,7 @@
<a class="btnPlayExternalTrailer hide" data-role="button" data-icon="video" data-inline="true" data-mini="true" href="#" target="_blank">${ButtonPlayTrailer}</a>
<a class="btnPlayExternal hide" data-role="button" data-icon="play" data-inline="true" data-mini="true" href="#" target="_blank">${ButtonPlay}</a>
<a class="btnSync hide" data-role="button" data-icon="cloud" data-inline="true" data-mini="true" href="#">${ButtonSync}</a>
<button class="btnMoreCommands hide" type="button" data-icon="ellipsis-v" data-inline="true" data-mini="true">${ButtonMore}</button>
<button class="btnMoreCommands hide jqmButtonNoText" type="button" data-icon="ellipsis-v" data-inline="true" data-mini="true" data-iconpos="notext">${ButtonMore}</button>
</div>
</div>
</div>
@ -161,7 +161,7 @@
<a class="btnPlayExternalTrailer hide" data-role="button" data-icon="video" data-inline="true" data-mini="true" href="#" target="_blank">${ButtonPlayTrailer}</a>
<a class="btnPlayExternal hide" data-role="button" data-icon="play" data-inline="true" data-mini="true" href="#" target="_blank">${ButtonPlay}</a>
<a class="btnSync hide" data-role="button" data-icon="cloud" data-inline="true" data-mini="true" href="#">${ButtonSync}</a>
<button class="btnMoreCommands hide" type="button" data-icon="ellipsis-v" data-inline="true" data-mini="true">${ButtonMore}</button>
<button class="btnMoreCommands hide jqmButtonNoText" type="button" data-icon="ellipsis-v" data-inline="true" data-mini="true" data-iconpos="notext">${ButtonMore}</button>
</div>
<p id="artist"></p>
<p class="itemGenres"></p>

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>${TitleMediaBrowser}</title>
</head>
<body>
<div id="itemGalleryPage" data-role="page" class="page libraryPage">
<div data-role="content">
<div class="ehsContent">
<br />
<div class="parentName" style="display: none;">
</div>
<h1 class="itemName"></h1>
<div id="galleryCollapsible" class="detailSection">
<div class="detailSectionHeader">
${HeaderGallery}
</div>
<div id="galleryContent" class="detailSectionContent"></div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,35 +0,0 @@
(function ($, document) {
var currentItem;
function reload(page) {
Dashboard.showLoadingMsg();
ApiClient.getItem(Dashboard.getCurrentUserId(), getParameterByName('id')).done(function (item) {
currentItem = item;
LibraryBrowser.renderName(item, $('.itemName', page), true);
LibraryBrowser.renderParentName(item, $('.parentName', page));
$('#galleryContent', page).html(LibraryBrowser.getGalleryHtml(currentItem)).trigger('create');
Dashboard.hideLoadingMsg();
});
}
$(document).on('pageshow', "#itemGalleryPage", function () {
var page = this;
reload(page);
}).on('pagehide', "#itemGalleryPage", function () {
var page = this;
currentItem = null;
});
})(jQuery, document);

View File

@ -310,15 +310,7 @@
if (item.Type == 'BoxSet' || item.Type == 'Playlist') {
commands.push('delete');
}
else if (user.Policy.EnableContentDeletion &&
item.Type != "TvChannel" &&
item.Type != "Genre" &&
item.Type != "Studio" &&
item.Type != "MusicGenre" &&
item.Type != "GameGenre" &&
item.Type != "Person" &&
item.Type != "MusicArtist" &&
item.Type != "CollectionFolder") {
else if (item.CanDelete) {
commands.push('delete');
}
@ -334,6 +326,10 @@
commands.push('sync');
}
if (item.CanDownload) {
commands.push('download');
}
return commands;
},
@ -382,23 +378,31 @@
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
if (commands.indexOf('addtocollection') != -1) {
html += '<li><a href="#" onclick="$(\'.playFlyout\').popup(\'close\');BoxSetEditor.showPanel([\'' + itemId + '\']);">' + Globalize.translate('ButtonAddToCollection') + '</a></li>';
html += '<li data-icon="plus"><a href="#" onclick="$(\'.playFlyout\').popup(\'close\');BoxSetEditor.showPanel([\'' + itemId + '\']);">' + Globalize.translate('ButtonAddToCollection') + '</a></li>';
}
if (commands.indexOf('playlist') != -1) {
html += '<li><a href="#" onclick="$(\'.playFlyout\').popup(\'close\');PlaylistManager.showPanel([\'' + itemId + '\']);">' + Globalize.translate('ButtonAddToPlaylist') + '</a></li>';
}
if (commands.indexOf('edit') != -1) {
html += '<li><a href="edititemmetadata.html?id=' + itemId + '">' + Globalize.translate('ButtonEdit') + '</a></li>';
}
if (commands.indexOf('refresh') != -1) {
html += '<li><a class="btnMoreMenuRefresh" href="#">' + Globalize.translate('ButtonRefresh') + '</a></li>';
html += '<li data-icon="plus"><a href="#" onclick="$(\'.playFlyout\').popup(\'close\');PlaylistManager.showPanel([\'' + itemId + '\']);">' + Globalize.translate('ButtonAddToPlaylist') + '</a></li>';
}
if (commands.indexOf('delete') != -1) {
html += '<li><a class="btnMoreMenuDelete" href="#" onclick="$(\'.playFlyout\').popup(\'close\');LibraryBrowser.deleteItem([\'' + itemId + '\']);">' + Globalize.translate('ButtonDelete') + '</a></li>';
html += '<li data-icon="delete"><a class="btnMoreMenuDelete" href="#" onclick="$(\'.playFlyout\').popup(\'close\');LibraryBrowser.deleteItem([\'' + itemId + '\']);">' + Globalize.translate('ButtonDelete') + '</a></li>';
}
if (commands.indexOf('download') != -1) {
var downloadHref = ApiClient.getUrl("Items/" + itemId + "/Download", {
api_key: ApiClient.accessToken()
});
html += '<li data-icon="arrow-d"><a class="btnMoreMenuDownload" data-ajax="false" href="' + downloadHref + '" onclick="$(\'.playFlyout\').popup(\'close\');">' + Globalize.translate('ButtonDownload') + '</a></li>';
}
if (commands.indexOf('edit') != -1) {
html += '<li data-icon="edit"><a href="edititemmetadata.html?id=' + itemId + '">' + Globalize.translate('ButtonEdit') + '</a></li>';
}
if (commands.indexOf('refresh') != -1) {
html += '<li data-icon="refresh"><a class="btnMoreMenuRefresh" href="#">' + Globalize.translate('ButtonRefresh') + '</a></li>';
}
html += '</ul>';
@ -919,7 +923,10 @@
// There's no detail page with a dedicated delete function
if (item.Type == 'Playlist' || item.Type == 'BoxSet') {
itemCommands.push('delete');
if (item.CanDelete) {
itemCommands.push('delete');
}
}
if (SyncManager.isAvailable(item)) {
@ -2197,22 +2204,12 @@
}
if (!href) {
href = "itemgallery.html?id=" + item.Id;
href = "#";
}
var linkToGallery = LibraryBrowser.shouldDisplayGallery(item);
html += '<div style="position:relative;">';
if (linkToGallery) {
html += "<a class='itemDetailGalleryLink' href='" + href + "'>";
}
html += "<img class='itemDetailImage' src='" + url + "' />";
if (linkToGallery) {
html += "</a>";
}
var progressHtml = item.IsFolder ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
if (progressHtml) {
@ -2322,15 +2319,10 @@
}
if (!href) {
href = "itemgallery.html?id=" + item.Id;
href = "#";
}
var linkToGallery = LibraryBrowser.shouldDisplayGallery(item);
html += '<div style="position:relative;">';
if (linkToGallery) {
html += "<a class='itemDetailGalleryLink' href='" + href + "'>";
}
if (detectRatio && item.PrimaryImageAspectRatio) {
@ -2343,10 +2335,6 @@
html += "<img class='itemDetailImage' src='" + url + "' />";
if (linkToGallery) {
html += "</a>";
}
var progressHtml = item.IsFolder ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
if (progressHtml) {
@ -2663,161 +2651,7 @@
$('#itemBackdrop', page).addClass('noBackdrop').css('background-image', 'none');
}
},
shouldDisplayGallery: function (item) {
var imageTags = item.ImageTags || {};
if (imageTags.Primary) {
return true;
}
if (imageTags.Banner) {
return true;
}
if (imageTags.Logo) {
return true;
}
if (imageTags.Thumb) {
return true;
}
if (imageTags.Art) {
return true;
}
if (imageTags.Menu) {
return true;
}
if (imageTags.Disc) {
return true;
}
if (imageTags.Box) {
return true;
}
if (imageTags.BoxRear) {
return true;
}
if (item.BackdropImageTags && item.BackdropImageTags.length) {
return true;
}
if (item.ScreenshotImageTags && item.ScreenshotImageTags.length) {
return true;
}
return false;
},
getGalleryHtml: function (item) {
var html = '';
var i, length;
var imageTags = item.ImageTags || {};
if (imageTags.Primary) {
html += LibraryBrowser.createGalleryImage(item, "Primary", imageTags.Primary);
}
if (imageTags.Banner) {
html += LibraryBrowser.createGalleryImage(item, "Banner", imageTags.Banner);
}
if (imageTags.Logo) {
html += LibraryBrowser.createGalleryImage(item, "Logo", imageTags.Logo);
}
if (imageTags.Thumb) {
html += LibraryBrowser.createGalleryImage(item, "Thumb", imageTags.Thumb);
}
if (imageTags.Art) {
html += LibraryBrowser.createGalleryImage(item, "Art", imageTags.Art);
}
if (imageTags.Menu) {
html += LibraryBrowser.createGalleryImage(item, "Menu", imageTags.Menu);
}
if (imageTags.Box) {
html += LibraryBrowser.createGalleryImage(item, "Box", imageTags.Box);
}
if (imageTags.BoxRear) {
html += LibraryBrowser.createGalleryImage(item, "BoxRear", imageTags.BoxRear);
}
if (item.BackdropImageTags) {
for (i = 0, length = item.BackdropImageTags.length; i < length; i++) {
html += LibraryBrowser.createGalleryImage(item, "Backdrop", item.BackdropImageTags[i], i);
}
}
if (item.ScreenshotImageTags) {
for (i = 0, length = item.ScreenshotImageTags.length; i < length; i++) {
html += LibraryBrowser.createGalleryImage(item, "Screenshot", item.ScreenshotImageTags[i], i);
}
}
if (imageTags.Disc) {
html += LibraryBrowser.createGalleryImage(item, "Disc", imageTags.Disc);
}
return html;
},
createGalleryImage: function (item, type, tag, index) {
var screenWidth = Math.max(screen.height, screen.width);
var html = '';
if (typeof (index) == "undefined") index = 0;
html += '<div class="galleryImageContainer">';
html += '<a href="#pop_' + index + '_' + tag + '" data-rel="popup" data-position-to="window">';
html += '<img class="galleryImage" src="' + LibraryBrowser.getImageUrl(item, type, index, {
maxWidth: screenWidth,
tag: tag
}) + '" />';
html += '</div>';
html += '<div class="galleryPopup" id="pop_' + index + '_' + tag + '" data-role="popup">';
html += '<a href="#" data-rel="back" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right">' + Globalize.translate('ButtonClose') + '</a>';
html += '<img class="" src="' + LibraryBrowser.getImageUrl(item, type, index, {
maxWidth: screenWidth,
tag: tag
}) + '" />';
html += '</div>';
return html;
}
};
})(window, document, jQuery, screen, window.store);

View File

@ -396,6 +396,10 @@
html += '<li data-icon="plus"><a href="#" class="btnAddToPlaylist" data-itemid="' + itemId + '">' + Globalize.translate('ButtonAddToPlaylist') + '</a></li>';
}
if (commands.indexOf('delete') != -1) {
html += '<li data-icon="delete"><a href="#" class="btnDelete" data-itemId="' + itemId + '">' + Globalize.translate('ButtonDelete') + '</a></li>';
}
if (user.Policy.IsAdministrator && commands.indexOf('edit') != -1) {
html += '<li data-icon="edit"><a href="edititemmetadata.html?id=' + itemId + '">' + Globalize.translate('ButtonEdit') + '</a></li>';
}
@ -450,10 +454,6 @@
html += '<li data-icon="cloud"><a href="#" class="btnSync" data-itemId="' + itemId + '">' + Globalize.translate('ButtonSync') + '</a></li>';
}
if (commands.indexOf('delete') != -1) {
html += '<li data-icon="delete"><a href="#" class="btnDelete" data-itemId="' + itemId + '">' + Globalize.translate('ButtonDelete') + '</a></li>';
}
html += '</ul>';
html += '</div>';

View File

@ -63,21 +63,17 @@
$('.recordingStatus', page).html('Status:&nbsp;&nbsp;&nbsp;' + item.Status);
Dashboard.getCurrentUser().done(function (user) {
if (MediaController.canPlay(item)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
if (MediaController.canPlay(item)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
if (user.Policy.IsAdministrator && item.LocationType !== "Offline") {
$('#deleteButtonContainer', page).show();
} else {
$('#deleteButtonContainer', page).hide();
}
});
if (item.CanDelete) {
$('#deleteButtonContainer', page).show();
} else {
$('#deleteButtonContainer', page).hide();
}
LiveTvHelpers.renderOriginalAirDate($('.airDate', page), item);

View File

@ -1059,6 +1059,7 @@
VideoCodec: mp4Quality.videoCodec,
AudioCodec: mp4Quality.audioCodec,
profile: 'high',
//EnableAutoStreamCopy: false,
level: '41'
}));

View File

@ -106,9 +106,14 @@
// Chrome, Firefox or IE with plugin installed
// For some reason in chrome pausing mp4 is causing the video to fail.
// So for now it will have to prioritize webm
if (self.canPlayWebm() && ($.browser.chrome || $.browser.msie)) {
if (self.canPlayWebm()) {
return '.webm';
if ($.browser.msie) {
return '.webm';
}
if ($.browser.chrome) {
return '.webm';
}
}
return '.mp4';
@ -551,8 +556,8 @@
ApiClient.getJSON(ApiClient.getUrl('Items/' + item.Id + '/MediaInfo', {
userId: Dashboard.getCurrentUserId()
})).done(function(result) {
})).done(function (result) {
self.currentItem = item;
self.currentMediaSource = getOptimalMediaSource(item.MediaType, result.MediaSources);

View File

@ -9,7 +9,7 @@
SortOrder: "Ascending",
IncludeItemTypes: "BoxSet",
Recursive: true,
Fields: "PrimaryImageAspectRatio,SortName,SyncInfo",
Fields: "PrimaryImageAspectRatio,SortName,SyncInfo,CanDelete",
StartIndex: 0,
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"

View File

@ -9,7 +9,7 @@
SortOrder: "Ascending",
IncludeItemTypes: "Playlist",
Recursive: true,
Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks",
Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete",
StartIndex: 0
};

View File

@ -27,7 +27,9 @@
$('#chkIsHidden', page).checked(user.Policy.IsHidden).checkboxradio("refresh");
$('#chkRemoteControlSharedDevices', page).checked(user.Policy.EnableSharedDeviceControl).checkboxradio("refresh");
$('#chkEnableRemoteControlOtherUsers', page).checked(user.Policy.EnableRemoteControlOfOtherUsers).checkboxradio("refresh");
$('#chkEnableMediaPlayback', page).checked(user.Policy.EnableMediaPlayback).checkboxradio("refresh");
$('#chkEnableDownloading', page).checked(user.Policy.EnableContentDownloading).checkboxradio("refresh");
$('#chkManageLiveTv', page).checked(user.Policy.EnableLiveTvManagement).checkboxradio("refresh");
$('#chkEnableLiveTvAccess', page).checked(user.Policy.EnableLiveTvAccess).checkboxradio("refresh");
@ -68,12 +70,14 @@
user.Policy.IsDisabled = $('#chkDisabled', page).checked();
user.Policy.EnableRemoteControlOfOtherUsers = $('#chkEnableRemoteControlOtherUsers', page).checked();
user.Policy.EnableLiveTvManagement = $('#chkManageLiveTv', page).checked();
user.Policy.EnableMediaPlayback = $('#chkEnableMediaPlayback', page).checked();
user.Policy.EnableLiveTvAccess = $('#chkEnableLiveTvAccess', page).checked();
user.Policy.EnableContentDeletion = $('#chkEnableContentDeletion', page).checked();
user.Policy.EnableUserPreferenceAccess = !$('#chkDisableUserPreferences', page).checked();
user.Policy.EnableSharedDeviceControl = $('#chkRemoteControlSharedDevices', page).checked();
user.Policy.EnableMediaPlayback = $('#chkEnableMediaPlayback', page).checked();
user.Policy.EnableContentDownloading = $('#chkEnableDownloading', page).checked();
user.Policy.EnableSync = $('#chkEnableSync', page).checked();
ApiClient.updateUser(user).done(function () {

View File

@ -41,14 +41,16 @@
</ul>
<fieldset id="featureAccessFields" data-role="controlgroup">
<legend>${HeaderFeatureAccess}</legend>
<input type="checkbox" id="chkEnableContentDeletion" name="chkEnableContentDeletion" />
<label for="chkEnableContentDeletion">${OptionAllowDeleteLibraryContent}</label>
<input type="checkbox" id="chkEnableDownloading" />
<label for="chkEnableDownloading">${OptionAllowContentDownloading}</label>
<input type="checkbox" id="chkEnableMediaPlayback" name="chkEnableMediaPlayback" />
<label for="chkEnableMediaPlayback">${OptionAllowMediaPlayback}</label>
<input type="checkbox" id="chkEnableLiveTvAccess" name="chkEnableLiveTvAccess" />
<label for="chkEnableLiveTvAccess">${OptionAllowBrowsingLiveTv}</label>
<input type="checkbox" id="chkManageLiveTv" name="chkManageLiveTv" />
<label for="chkManageLiveTv">${OptionAllowManageLiveTv}</label>
<input type="checkbox" id="chkEnableContentDeletion" name="chkEnableContentDeletion" />
<label for="chkEnableContentDeletion">${OptionAllowDeleteLibraryContent}</label>
<input type="checkbox" id="chkEnableSync" />
<label for="chkEnableSync">${OptionAllowSyncContent}</label>
</fieldset>