mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
added GameGenre
This commit is contained in:
parent
58e6a91984
commit
d1a8e37334
8 changed files with 274 additions and 11 deletions
189
ApiClient.js
189
ApiClient.js
|
@ -497,6 +497,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.refreshGameGenre = function (name, force) {
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("GameGenres/" + self.encodeName(name) + "/Refresh", {
|
||||
|
||||
forced: force || false
|
||||
|
||||
});
|
||||
|
||||
return self.ajax({
|
||||
type: "POST",
|
||||
url: url
|
||||
});
|
||||
};
|
||||
|
||||
self.refreshPerson = function (name, force) {
|
||||
|
||||
if (!name) {
|
||||
|
@ -1263,6 +1281,27 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.getGameGenre = function (name, userId) {
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var options = {};
|
||||
|
||||
if (userId) {
|
||||
options.userId = userId;
|
||||
}
|
||||
|
||||
var url = self.getUrl("GameGenres/" + self.encodeName(name), options);
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an artist
|
||||
*/
|
||||
|
@ -1552,6 +1591,41 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
return self.getUrl(url, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a url for a genre image
|
||||
* @param {String} name
|
||||
* @param {Object} options
|
||||
* Options supports the following properties:
|
||||
* width - download the image at a fixed width
|
||||
* height - download the image at a fixed height
|
||||
* maxWidth - download the image at a maxWidth
|
||||
* maxHeight - download the image at a maxHeight
|
||||
* quality - A scale of 0-100. This should almost always be omitted as the default will suffice.
|
||||
* For best results do not specify both width and height together, as aspect ratio might be altered.
|
||||
*/
|
||||
self.getGameGenreImageUrl = function (name, options) {
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
options = options || {
|
||||
|
||||
};
|
||||
|
||||
var url = "GameGenres/" + self.encodeName(name) + "/Images/" + options.type;
|
||||
|
||||
if (options.index != null) {
|
||||
url += "/" + options.index;
|
||||
}
|
||||
|
||||
// Don't put these on the query string
|
||||
delete options.type;
|
||||
delete options.index;
|
||||
|
||||
return self.getUrl(url, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a url for a artist image
|
||||
* @param {String} name
|
||||
|
@ -1922,7 +1996,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.updateMusicGenres = function (item) {
|
||||
self.updateMusicGenre = function (item) {
|
||||
|
||||
if (!item) {
|
||||
throw new Error("null item");
|
||||
|
@ -1938,6 +2012,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.updateGameGenre = function (item) {
|
||||
|
||||
if (!item) {
|
||||
throw new Error("null item");
|
||||
}
|
||||
|
||||
var url = self.getUrl("GameGenres/" + self.encodeName(item.Name));
|
||||
|
||||
return self.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: JSON.stringify(item),
|
||||
contentType: "application/json"
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates plugin security info
|
||||
*/
|
||||
|
@ -2136,6 +2226,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.getGameGenres = function (userId, options) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
options.userId = userId;
|
||||
|
||||
var url = self.getUrl("GameGenres", options);
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Gets people from an item
|
||||
*/
|
||||
|
@ -2484,6 +2592,26 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.updateFavoriteGameGenreStatus = function (userId, name, isFavorite) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("Users/" + userId + "/Favorites/GameGenres/" + self.encodeName(name));
|
||||
|
||||
var method = isFavorite ? "POST" : "DELETE";
|
||||
|
||||
return self.ajax({
|
||||
type: method,
|
||||
url: url
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a user's rating for an item by name.
|
||||
* @param {String} userId
|
||||
|
@ -2590,6 +2718,26 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.updateGameGenreRating = function (userId, name, likes) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("Users/" + userId + "/Ratings/GameGenres/" + self.encodeName(name), {
|
||||
likes: likes
|
||||
});
|
||||
|
||||
return self.ajax({
|
||||
type: "POST",
|
||||
url: url
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears a user's rating for an item by name.
|
||||
* @param {String} userId
|
||||
|
@ -2685,6 +2833,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.clearGameGenreRating = function (userId, name) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("Users/" + userId + "/Ratings/GameGenres/" + self.encodeName(name));
|
||||
|
||||
return self.ajax({
|
||||
type: "DELETE",
|
||||
url: url
|
||||
});
|
||||
};
|
||||
|
||||
self.getItemCounts = function (userId) {
|
||||
|
||||
var options = {};
|
||||
|
@ -2771,6 +2937,27 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.getGameGenreItemCounts = function (userId, name) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("GameGenres/" + self.encodeName(name) + "/Counts", {
|
||||
userId: userId
|
||||
});
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Gets a variety of item counts that an artist appears in
|
||||
*/
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
return ApiClient.getMusicGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('gamegenre');
|
||||
|
||||
if (name) {
|
||||
return ApiClient.getGameGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('artist');
|
||||
|
||||
if (name) {
|
||||
|
@ -52,7 +58,7 @@
|
|||
LibraryBrowser.renderName(item, $('.itemName', page), true);
|
||||
LibraryBrowser.renderParentName(item, $('.parentName', page));
|
||||
|
||||
if (item.Type == "Person" || item.Type == "Studio" || item.Type == "MusicGenre" || item.Type == "Genre" || item.Type == "Artist") {
|
||||
if (item.Type == "Person" || item.Type == "Studio" || item.Type == "MusicGenre" || item.Type == "Genre" || item.Type == "Artist" || item.Type == "GameGenre") {
|
||||
$('#peopleTab', page).hide();
|
||||
} else {
|
||||
$('#peopleTab', page).show();
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
return ApiClient.getMusicGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('gamegenre');
|
||||
|
||||
if (name) {
|
||||
return ApiClient.getGameGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('artist');
|
||||
|
||||
if (name) {
|
||||
|
@ -522,6 +528,9 @@
|
|||
else if (currentItem.Type == "MusicGenre") {
|
||||
updatePromise = ApiClient.updateMusicGenre(item);
|
||||
}
|
||||
else if (currentItem.Type == "GameGenre") {
|
||||
updatePromise = ApiClient.updateGameGenre(item);
|
||||
}
|
||||
else if (currentItem.Type == "Person") {
|
||||
updatePromise = ApiClient.updatePerson(item);
|
||||
}
|
||||
|
@ -597,6 +606,9 @@
|
|||
else if (currentItem.Type == "MusicGenre") {
|
||||
refreshPromise = ApiClient.refreshMusicGenre(currentItem.Name, true);
|
||||
}
|
||||
else if (currentItem.Type == "GameGenre") {
|
||||
refreshPromise = ApiClient.refreshGameGenre(currentItem.Name, true);
|
||||
}
|
||||
else if (currentItem.Type == "Person") {
|
||||
refreshPromise = ApiClient.refreshPerson(currentItem.Name, true);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
SortBy: "SortName",
|
||||
SortOrder: "Ascending",
|
||||
MediaTypes: "Game",
|
||||
Recursive: true,
|
||||
Fields: "ItemCounts,DateCreated,UserData",
|
||||
StartIndex: 0
|
||||
|
@ -15,7 +14,7 @@
|
|||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) {
|
||||
ApiClient.getGameGenres(Dashboard.getCurrentUserId(), query).done(function (result) {
|
||||
|
||||
// Scroll back up so they can see the results from the beginning
|
||||
$(document).scrollTop(0);
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
return ApiClient.getMusicGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('gamegenre');
|
||||
|
||||
if (name) {
|
||||
return ApiClient.getGameGenre(name, Dashboard.getCurrentUserId());
|
||||
}
|
||||
|
||||
name = getParameterByName('artist');
|
||||
|
||||
if (name) {
|
||||
|
@ -125,7 +131,7 @@
|
|||
if (context == "music" && item.Type == "Artist") {
|
||||
$('#artistTabs', page).show();
|
||||
}
|
||||
if (context == "games" && item.Type == "Genre") {
|
||||
if (context == "games" && item.Type == "GameGenre") {
|
||||
$('#gameGenreTabs', page).show();
|
||||
}
|
||||
if (context == "games" && item.Type == "Studio") {
|
||||
|
@ -146,6 +152,9 @@
|
|||
else if (item.Type == "MusicGenre") {
|
||||
promise = ApiClient.getMusicGenreItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
||||
}
|
||||
else if (item.Type == "GameGenre") {
|
||||
promise = ApiClient.getGameGenreItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
||||
}
|
||||
else if (item.Type == "Studio") {
|
||||
promise = ApiClient.getStudioItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
||||
}
|
||||
|
@ -383,6 +392,9 @@
|
|||
else if (currentItem.Type == "MusicGenre") {
|
||||
query.Genres = currentItem.Name;
|
||||
}
|
||||
else if (currentItem.Type == "GameGenre") {
|
||||
query.Genres = currentItem.Name;
|
||||
}
|
||||
else if (currentItem.Type == "Studio") {
|
||||
query.Studios = currentItem.Name;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
imgUrl = "css/images/items/list/game.png";
|
||||
isDefault = true;
|
||||
}
|
||||
else if (item.Type == "Studio" || item.Type == "Genre" || item.Type == "MusicGenre") {
|
||||
else if (item.Type == "Studio" || item.Type == "Genre" || item.Type == "MusicGenre" || item.Type == "GameGenre") {
|
||||
|
||||
if (options.context == "games") {
|
||||
|
||||
|
@ -180,7 +180,7 @@
|
|||
|
||||
html += '<p class="itemMiscInfo">' + childText + '</p>';
|
||||
}
|
||||
else if (item.Type == "Genre" || item.Type == "Studio" || item.Type == "Person" || item.Type == "Artist" || item.Type == "MusicGenre") {
|
||||
else if (item.Type == "Genre" || item.Type == "Studio" || item.Type == "Person" || item.Type == "Artist" || item.Type == "MusicGenre" || item.Type == "GameGenre") {
|
||||
|
||||
childText = item.ChildCount == 1 ? "1 " + options.countNameSingular : item.ChildCount + " " + options.countNamePlural;
|
||||
|
||||
|
@ -369,6 +369,9 @@
|
|||
if (item.Type == "MusicGenre") {
|
||||
return "itembynamedetails.html?musicgenre=" + ApiClient.encodeName(item.Name) + "&context=" + itemByNameContext;
|
||||
}
|
||||
if (item.Type == "GameGenre") {
|
||||
return "itembynamedetails.html?gamegenre=" + ApiClient.encodeName(item.Name) + "&context=" + itemByNameContext;
|
||||
}
|
||||
if (item.Type == "Studio") {
|
||||
return "itembynamedetails.html?studio=" + ApiClient.encodeName(item.Name) + "&context=" + itemByNameContext;
|
||||
}
|
||||
|
@ -418,6 +421,10 @@
|
|||
|
||||
return ApiClient.getMusicGenreImageUrl(item.Name, options);
|
||||
}
|
||||
if (item.Type == "GameGenre") {
|
||||
|
||||
return ApiClient.getGameGenreImageUrl(item.Name, options);
|
||||
}
|
||||
if (item.Type == "Artist") {
|
||||
|
||||
return ApiClient.getArtistImageUrl(item.Name, options);
|
||||
|
@ -604,7 +611,7 @@
|
|||
return '<div class="posterRibbon">' + item.RecentlyAddedItemCount + ' New</div>';
|
||||
}
|
||||
|
||||
if (!item.IsFolder && item.Type !== "Genre" && item.Type !== "Studio" && item.Type !== "Person" && item.Type !== "Artist" && item.Type !== "MusicGenre") {
|
||||
if (!item.IsFolder && item.Type !== "Genre" && item.Type !== "Studio" && item.Type !== "Person" && item.Type !== "Artist" && item.Type !== "MusicGenre" && item.Type !== "GameGenre") {
|
||||
|
||||
var date = item.DateCreated;
|
||||
|
||||
|
@ -959,6 +966,9 @@
|
|||
else if (type == "MusicGenre") {
|
||||
itemId = item.Name;
|
||||
}
|
||||
else if (type == "GameGenre") {
|
||||
itemId = item.Name;
|
||||
}
|
||||
else if (type == "Artist") {
|
||||
itemId = item.Name;
|
||||
}
|
||||
|
@ -1036,6 +1046,9 @@
|
|||
else if (type == "MusicGenre") {
|
||||
ApiClient.updateFavoriteMusicGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
||||
}
|
||||
else if (type == "GameGenre") {
|
||||
ApiClient.updateFavoriteGameGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
||||
}
|
||||
else {
|
||||
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
||||
}
|
||||
|
@ -1120,6 +1133,9 @@
|
|||
else if (type == "MusicGenre") {
|
||||
ApiClient.updateMusicGenreRating(Dashboard.getCurrentUserId(), id, likes);
|
||||
}
|
||||
else if (type == "GameGenre") {
|
||||
ApiClient.updateGameGenreRating(Dashboard.getCurrentUserId(), id, likes);
|
||||
}
|
||||
else {
|
||||
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, likes);
|
||||
}
|
||||
|
@ -1142,6 +1158,9 @@
|
|||
else if (type == "MusicGenre") {
|
||||
ApiClient.clearMusicGenreRating(Dashboard.getCurrentUserId(), id);
|
||||
}
|
||||
else if (type == "GameGenre") {
|
||||
ApiClient.clearGameGenreRating(Dashboard.getCurrentUserId(), id);
|
||||
}
|
||||
else {
|
||||
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
||||
}
|
||||
|
@ -1178,6 +1197,13 @@
|
|||
type: "Primary"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "GameGenre") {
|
||||
url = ApiClient.getGameGenreImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
tag: imageTags.Primary,
|
||||
type: "Primary"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "Studio") {
|
||||
url = ApiClient.getStudioImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
|
@ -1223,6 +1249,13 @@
|
|||
type: "Backdrop"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "GameGenre") {
|
||||
url = ApiClient.getGameGenreImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
tag: item.BackdropImageTags[0],
|
||||
type: "Backdrop"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "Studio") {
|
||||
url = ApiClient.getStudioImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
|
@ -1268,6 +1301,13 @@
|
|||
type: "Thumb"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "GameGenre") {
|
||||
url = ApiClient.getGameGenreImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
tag: imageTags.Thumb,
|
||||
type: "Thumb"
|
||||
});
|
||||
}
|
||||
else if (item.Type == "Studio") {
|
||||
url = ApiClient.getStudioImageUrl(item.Name, {
|
||||
maxheight: 480,
|
||||
|
@ -1301,7 +1341,7 @@
|
|||
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicGenre") {
|
||||
url = "css/images/items/detail/audio.png";
|
||||
}
|
||||
else if (item.MediaType == "Game") {
|
||||
else if (item.MediaType == "Game" || item.Type == "GameGenre") {
|
||||
url = "css/images/items/detail/game.png";
|
||||
}
|
||||
else if (item.Type == "Person") {
|
||||
|
@ -1317,7 +1357,7 @@
|
|||
var identifierName = "id";
|
||||
var identifierValue = item.Id;
|
||||
|
||||
if (item.Type == "Person" || item.Type == "Genre" || item.Type == "Studio" || item.Type == "Artist" || item.Type == "MusicGenre") {
|
||||
if (item.Type == "Person" || item.Type == "Genre" || item.Type == "Studio" || item.Type == "Artist" || item.Type == "MusicGenre" || item.Type == "GameGenre") {
|
||||
identifierName = item.Type;
|
||||
identifierValue = ApiClient.encodeName(item.Name);
|
||||
}
|
||||
|
@ -1491,6 +1531,10 @@
|
|||
|
||||
var param = item.Type == "Audio" || item.Type == "Artist" || item.Type == "MusicArtist" || item.Type == "MusicAlbum" ? "musicgenre" : "genre";
|
||||
|
||||
if (item.MediaType == "Game") {
|
||||
param = "gamegenre";
|
||||
}
|
||||
|
||||
html += '<a class="textlink" href="itembynamedetails.html?context=' + context + '&' + param + '=' + ApiClient.encodeName(item.Genres[i]) + '">' + item.Genres[i] + '</a>';
|
||||
}
|
||||
|
||||
|
|
|
@ -944,6 +944,9 @@ var Dashboard = {
|
|||
else if (type == "musicgenre") {
|
||||
url = "itembynamedetails.html?musicgenre=" + ApiClient.encodeName(cmd.ItemName) + "&context=" + (context || "music");
|
||||
}
|
||||
else if (type == "gamegenre") {
|
||||
url = "itembynamedetails.html?gamegenre=" + ApiClient.encodeName(cmd.ItemName) + "&context=" + (context || "games");
|
||||
}
|
||||
else if (type == "studio") {
|
||||
url = "itembynamedetails.html?studio=" + ApiClient.encodeName(cmd.ItemName) + "&context=" + context;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.130" targetFramework="net45" />
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.131" targetFramework="net45" />
|
||||
<package id="ServiceStack.Common" version="3.9.54" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.54" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue