2020-08-14 08:46:34 +02:00
|
|
|
import listView from '../components/listview/listview';
|
|
|
|
import cardBuilder from '../components/cardbuilder/cardBuilder';
|
|
|
|
import imageLoader from '../components/images/imageLoader';
|
|
|
|
import globalize from './globalize';
|
|
|
|
import '../elements/emby-itemscontainer/emby-itemscontainer';
|
|
|
|
import '../elements/emby-button/emby-button';
|
2020-10-17 19:08:56 +01:00
|
|
|
import ServerConnections from '../components/ServerConnections';
|
2020-08-04 19:33:20 +02:00
|
|
|
|
|
|
|
function renderItems(page, item) {
|
|
|
|
const sections = [];
|
|
|
|
|
|
|
|
if (item.ArtistCount) {
|
|
|
|
sections.push({
|
2020-08-11 23:36:35 +09:00
|
|
|
name: globalize.translate('Artists'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'MusicArtist'
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.ProgramCount && item.Type === 'Person') {
|
|
|
|
sections.push({
|
|
|
|
name: globalize.translate('HeaderUpcomingOnTV'),
|
|
|
|
type: 'Program'
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.MovieCount) {
|
|
|
|
sections.push({
|
2020-08-13 21:38:57 +09:00
|
|
|
name: globalize.translate('Movies'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'Movie'
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.SeriesCount) {
|
|
|
|
sections.push({
|
2020-08-13 21:31:29 +09:00
|
|
|
name: globalize.translate('Shows'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'Series'
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.EpisodeCount) {
|
|
|
|
sections.push({
|
2020-08-16 20:34:39 +09:00
|
|
|
name: globalize.translate('Episodes'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'Episode'
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.TrailerCount) {
|
|
|
|
sections.push({
|
2020-08-16 20:34:39 +09:00
|
|
|
name: globalize.translate('Trailers'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'Trailer'
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.AlbumCount) {
|
|
|
|
sections.push({
|
2020-08-13 21:23:51 +09:00
|
|
|
name: globalize.translate('Albums'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'MusicAlbum'
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.MusicVideoCount) {
|
|
|
|
sections.push({
|
2020-08-24 08:39:26 +09:00
|
|
|
name: globalize.translate('MusicVideos'),
|
2020-08-04 19:33:20 +02:00
|
|
|
type: 'MusicVideo'
|
2019-10-08 00:57:40 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
const elem = page.querySelector('#childrenContent');
|
|
|
|
elem.innerHTML = sections.map(function (section) {
|
|
|
|
let html = '';
|
|
|
|
let sectionClass = 'verticalSection';
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (section.type === 'Audio') {
|
|
|
|
sectionClass += ' verticalSection-extrabottompadding';
|
2019-10-08 00:57:40 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
html += '<div class="' + sectionClass + '" data-type="' + section.type + '">';
|
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
|
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
|
|
|
html += section.name;
|
|
|
|
html += '</h2>';
|
|
|
|
html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + globalize.translate('ButtonMore') + '</button></a>';
|
|
|
|
html += '</div>';
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-right">';
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
return html;
|
|
|
|
}).join('');
|
|
|
|
const sectionElems = elem.querySelectorAll('.verticalSection');
|
|
|
|
|
|
|
|
for (let i = 0, length = sectionElems.length; i < length; i++) {
|
2022-05-06 23:33:06 +03:00
|
|
|
renderSection(item, sectionElems[i], sectionElems[i].getAttribute('data-type'));
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-06 23:33:06 +03:00
|
|
|
function renderSection(item, element, type) {
|
2020-08-04 19:33:20 +02:00
|
|
|
switch (type) {
|
|
|
|
case 'Program':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Program',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 10,
|
|
|
|
SortBy: 'StartDate'
|
|
|
|
}, {
|
|
|
|
shape: 'overflowBackdrop',
|
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
preferThumb: true,
|
|
|
|
overlayText: false,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Movie':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Movie',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 10,
|
2024-05-15 02:39:50 -04:00
|
|
|
SortOrder: 'Descending,Descending,Ascending',
|
2023-10-16 13:06:35 -07:00
|
|
|
SortBy: 'PremiereDate,ProductionYear,SortName'
|
2020-08-04 19:33:20 +02:00
|
|
|
}, {
|
|
|
|
shape: 'overflowPortrait',
|
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
overlayText: false,
|
|
|
|
showYear: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'MusicVideo':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'MusicVideo',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 10,
|
|
|
|
SortBy: 'SortName'
|
|
|
|
}, {
|
2021-04-09 18:48:15 +02:00
|
|
|
shape: 'overflowBackdrop',
|
2020-08-04 19:33:20 +02:00
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Trailer':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Trailer',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 10,
|
|
|
|
SortBy: 'SortName'
|
|
|
|
}, {
|
|
|
|
shape: 'overflowPortrait',
|
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Series':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Series',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 10,
|
|
|
|
SortBy: 'SortName'
|
|
|
|
}, {
|
|
|
|
shape: 'overflowPortrait',
|
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayMoreButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'MusicAlbum':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'MusicAlbum',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
2024-05-15 02:39:50 -04:00
|
|
|
SortOrder: 'Descending,Descending,Ascending',
|
2020-12-25 15:57:33 +01:00
|
|
|
SortBy: 'PremiereDate,ProductionYear,Sortname'
|
2020-08-04 19:33:20 +02:00
|
|
|
}, {
|
|
|
|
shape: 'overflowSquare',
|
|
|
|
playFromHere: true,
|
|
|
|
showTitle: true,
|
|
|
|
showYear: true,
|
|
|
|
coverImage: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'MusicArtist':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'MusicArtist',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 8,
|
|
|
|
SortBy: 'SortName'
|
|
|
|
}, {
|
|
|
|
shape: 'overflowSquare',
|
|
|
|
playFromHere: true,
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
coverImage: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Episode':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Episode',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
Limit: 6,
|
|
|
|
SortBy: 'SortName'
|
|
|
|
}, {
|
|
|
|
shape: 'overflowBackdrop',
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Audio':
|
|
|
|
loadItems(element, item, type, {
|
|
|
|
MediaTypes: '',
|
|
|
|
IncludeItemTypes: 'Audio',
|
|
|
|
PersonTypes: '',
|
|
|
|
ArtistIds: '',
|
|
|
|
AlbumArtistIds: '',
|
|
|
|
SortBy: 'AlbumArtist,Album,SortName'
|
|
|
|
}, {
|
|
|
|
playFromHere: true,
|
|
|
|
action: 'playallfromhere',
|
|
|
|
smallIcon: true,
|
|
|
|
artist: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadItems(element, item, type, query, listOptions) {
|
|
|
|
query = getQuery(query, item);
|
|
|
|
getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) {
|
2022-05-11 23:13:02 -04:00
|
|
|
// If results are empty, hide the section
|
|
|
|
if (!result.Items?.length) {
|
|
|
|
element.classList.add('hide');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
let html = '';
|
|
|
|
|
|
|
|
if (query.Limit && result.TotalRecordCount > query.Limit) {
|
|
|
|
const link = element.querySelector('a');
|
|
|
|
link.classList.remove('hide');
|
|
|
|
link.setAttribute('href', getMoreItemsHref(item, type));
|
|
|
|
} else {
|
|
|
|
element.querySelector('a').classList.add('hide');
|
2019-10-08 00:57:40 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
listOptions.items = result.Items;
|
|
|
|
const itemsContainer = element.querySelector('.itemsContainer');
|
|
|
|
|
|
|
|
if (type === 'Audio') {
|
|
|
|
html = listView.getListViewHtml(listOptions);
|
|
|
|
itemsContainer.classList.remove('vertical-wrap');
|
|
|
|
itemsContainer.classList.add('vertical-list');
|
|
|
|
} else {
|
|
|
|
html = cardBuilder.getCardsHtml(listOptions);
|
|
|
|
itemsContainer.classList.add('vertical-wrap');
|
|
|
|
itemsContainer.classList.remove('vertical-list');
|
2019-10-08 00:57:40 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
itemsContainer.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(itemsContainer);
|
|
|
|
});
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
function getMoreItemsHref(item, type) {
|
|
|
|
if (item.Type === 'Genre') {
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&genreId=' + item.Id + '&serverId=' + item.ServerId;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.Type === 'MusicGenre') {
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&musicGenreId=' + item.Id + '&serverId=' + item.ServerId;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.Type === 'Studio') {
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&studioId=' + item.Id + '&serverId=' + item.ServerId;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.Type === 'MusicArtist') {
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&artistId=' + item.Id + '&serverId=' + item.ServerId;
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (item.Type === 'Person') {
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&personId=' + item.Id + '&serverId=' + item.ServerId;
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2022-06-09 14:54:39 -04:00
|
|
|
return '#/list.html?type=' + type + '&parentId=' + item.Id + '&serverId=' + item.ServerId;
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function addCurrentItemToQuery(query, item) {
|
|
|
|
if (item.Type === 'Person') {
|
|
|
|
query.PersonIds = item.Id;
|
|
|
|
} else if (item.Type === 'Genre') {
|
|
|
|
query.Genres = item.Name;
|
|
|
|
} else if (item.Type === 'MusicGenre') {
|
|
|
|
query.Genres = item.Name;
|
|
|
|
} else if (item.Type === 'Studio') {
|
|
|
|
query.StudioIds = item.Id;
|
|
|
|
} else if (item.Type === 'MusicArtist') {
|
2022-05-11 23:13:02 -04:00
|
|
|
query.AlbumArtistIds = item.Id;
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getQuery(options, item) {
|
|
|
|
let query = {
|
|
|
|
SortOrder: 'Ascending',
|
|
|
|
IncludeItemTypes: '',
|
|
|
|
Recursive: true,
|
Remove nonexistent ItemField AudioInfo
Fixes
```
System.FormatException: AudioInfo is not a valid value for ItemFields.
---> System.ArgumentException: Requested value 'AudioInfo' was not found.
at System.Enum.TryParseByName[TStorage](RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, TStorage& result)
at System.Enum.TryParseByValueOrName[TUnderlying,TStorage](RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, TUnderlying& result)
at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
--- End of inner exception stack trace ---
at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Jellyfin.Api.ModelBinders.CommaDelimitedArrayModelBinder.GetParsedResult(IReadOnlyList`1 values, Type elementType, TypeConverter converter) in /home/bond/dev/jellyfin/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs:line 67
```
2024-04-23 11:19:56 +02:00
|
|
|
Fields: 'ParentId,PrimaryImageAspectRatio',
|
2020-08-04 19:33:20 +02:00
|
|
|
Limit: 100,
|
|
|
|
StartIndex: 0,
|
|
|
|
CollapseBoxSetItems: false
|
|
|
|
};
|
|
|
|
query = Object.assign(query, options || {});
|
|
|
|
addCurrentItemToQuery(query, item);
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemsFunction(options, item) {
|
|
|
|
const query = getQuery(options, item);
|
|
|
|
return function (index, limit, fields) {
|
|
|
|
query.StartIndex = index;
|
|
|
|
query.Limit = limit;
|
|
|
|
|
|
|
|
if (fields) {
|
|
|
|
query.Fields += ',' + fields;
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-10-17 19:08:56 +01:00
|
|
|
const apiClient = ServerConnections.getApiClient(item.ServerId);
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
if (query.IncludeItemTypes === 'MusicArtist') {
|
|
|
|
query.IncludeItemTypes = null;
|
|
|
|
return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query);
|
|
|
|
}
|
2019-10-08 00:57:40 +03:00
|
|
|
|
2020-08-04 19:33:20 +02:00
|
|
|
return apiClient.getItems(apiClient.getCurrentUserId(), query);
|
2019-10-08 00:57:40 +03:00
|
|
|
};
|
2020-08-04 19:33:20 +02:00
|
|
|
}
|
|
|
|
|
2022-05-04 03:36:40 +03:00
|
|
|
const ItemsByName = {
|
2022-05-09 19:03:55 +03:00
|
|
|
renderItems
|
2020-08-04 19:33:20 +02:00
|
|
|
};
|
2022-05-04 03:36:40 +03:00
|
|
|
|
|
|
|
export default ItemsByName;
|