mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
added ability to mark IBN items as favorites
This commit is contained in:
parent
04e2e510e5
commit
5ea81ef66d
4 changed files with 101 additions and 49 deletions
54
ApiClient.js
54
ApiClient.js
|
@ -1724,12 +1724,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a user's favorite status for a person.
|
* Updates a user's favorite status for an item by name.
|
||||||
* @param {String} userId
|
* @param {String} userId
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @param {Boolean} isFavorite
|
* @param {Boolean} isFavorite
|
||||||
*/
|
*/
|
||||||
self.updateFavoritePersonStatus = function (userId, name, isFavorite) {
|
self.updateItemByNameFavoriteStatus = function (userId, name, isFavorite) {
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("null userId");
|
throw new Error("null userId");
|
||||||
|
@ -1739,7 +1739,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
throw new Error("null name");
|
throw new Error("null name");
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = self.getUrl("Users/" + userId + "/FavoritePersons/" + name);
|
var url = self.getUrl("Users/" + userId + "/ItemsByName/Favorites/" + name);
|
||||||
|
|
||||||
var method = isFavorite ? "POST" : "DELETE";
|
var method = isFavorite ? "POST" : "DELETE";
|
||||||
|
|
||||||
|
@ -1751,12 +1751,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a user's favorite status for a genre.
|
* Updates a user's rating for an item by name.
|
||||||
* @param {String} userId
|
* @param {String} userId
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @param {Boolean} isFavorite
|
* @param {Boolean} likes
|
||||||
*/
|
*/
|
||||||
self.updateFavoriteGenreStatus = function (userId, name, isFavorite) {
|
self.updateItemByNameRating = function (userId, name, likes) {
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("null userId");
|
throw new Error("null userId");
|
||||||
|
@ -1766,24 +1766,46 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
throw new Error("null name");
|
throw new Error("null name");
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = self.getUrl("Users/" + userId + "/FavoriteGenre/" + name);
|
var url = self.getUrl("Users/" + userId + "/ItemsByName/" + name + "/Rating", {
|
||||||
|
likes: likes
|
||||||
var method = isFavorite ? "POST" : "DELETE";
|
});
|
||||||
|
|
||||||
return self.ajax({
|
return self.ajax({
|
||||||
type: method,
|
type: "POST",
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears a user's rating for an item by name.
|
||||||
|
* @param {String} userId
|
||||||
|
* @param {String} name
|
||||||
|
*/
|
||||||
|
self.clearItemByNameRating = function (userId, name) {
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error("null userId");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
throw new Error("null name");
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = self.getUrl("Users/" + userId + "/ItemsByName/" + name + "/Rating");
|
||||||
|
|
||||||
|
return self.ajax({
|
||||||
|
type: "DELETE",
|
||||||
url: url,
|
url: url,
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a user's favorite status for a studio.
|
* Gets the full user data object for an item by name.
|
||||||
* @param {String} userId
|
* @param {String} userId
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @param {Boolean} isFavorite
|
|
||||||
*/
|
*/
|
||||||
self.updateFavoriteStudioStatus = function (userId, name, isFavorite) {
|
self.getItembyNameUserData = function (userId, name) {
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("null userId");
|
throw new Error("null userId");
|
||||||
|
@ -1793,12 +1815,10 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
throw new Error("null name");
|
throw new Error("null name");
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = self.getUrl("Users/" + userId + "/FavoriteStudios/" + name);
|
var url = self.getUrl("Users/" + userId + "/ItemsByName/" + name + "/UserData");
|
||||||
|
|
||||||
var method = isFavorite ? "POST" : "DELETE";
|
|
||||||
|
|
||||||
return self.ajax({
|
return self.ajax({
|
||||||
type: method,
|
type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,24 +6,40 @@
|
||||||
|
|
||||||
var getItemPromise;
|
var getItemPromise;
|
||||||
|
|
||||||
var person = getParameterByName('person');
|
var name = getParameterByName('person');
|
||||||
|
|
||||||
if (person) {
|
if (name) {
|
||||||
getItemPromise = ApiClient.getPerson(person);
|
getItemPromise = ApiClient.getPerson(name);
|
||||||
}
|
|
||||||
|
|
||||||
else if (getParameterByName('studio')) {
|
|
||||||
getItemPromise = ApiClient.getStudio(getParameterByName('studio'));
|
|
||||||
}
|
|
||||||
else if (getParameterByName('genre')) {
|
|
||||||
getItemPromise = ApiClient.getGenre(getParameterByName('genre'));
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
name = getParameterByName('studio');
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
|
||||||
|
getItemPromise = ApiClient.getStudio(name);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
name = getParameterByName('genre');
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
getItemPromise = ApiClient.getGenre(name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
throw new Error('Invalid request');
|
throw new Error('Invalid request');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getItemPromise.done(function (item) {
|
var getUserDataPromise = ApiClient.getItembyNameUserData(Dashboard.getCurrentUserId(), name);
|
||||||
|
|
||||||
var name = item.Name;
|
$.when(getItemPromise, getUserDataPromise).done(function (response1, response2) {
|
||||||
|
|
||||||
|
var item = response1[0];
|
||||||
|
var userdata = response2[0];
|
||||||
|
|
||||||
|
item.UserData = userdata;
|
||||||
|
name = item.Name;
|
||||||
|
|
||||||
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
|
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
|
||||||
|
|
||||||
|
|
|
@ -632,14 +632,8 @@
|
||||||
|
|
||||||
var markAsFavorite = $link.hasClass('imgFavoriteOff');
|
var markAsFavorite = $link.hasClass('imgFavoriteOff');
|
||||||
|
|
||||||
if (type == "Person") {
|
if (type == "Person" || type == "Studio" || type == "Genre") {
|
||||||
ApiClient.updateFavoritePersonStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
ApiClient.updateItemByNameFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
||||||
}
|
|
||||||
else if (type == "Studio") {
|
|
||||||
ApiClient.updateFavoriteStudioStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
||||||
}
|
|
||||||
else if (type == "Genre") {
|
|
||||||
ApiClient.updateFavoriteGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
||||||
|
@ -657,19 +651,30 @@
|
||||||
markLike: function (link) {
|
markLike: function (link) {
|
||||||
|
|
||||||
var id = link.getAttribute('data-itemid');
|
var id = link.getAttribute('data-itemid');
|
||||||
|
var type = link.getAttribute('data-type');
|
||||||
|
|
||||||
var $link = $(link);
|
var $link = $(link);
|
||||||
|
|
||||||
if ($link.hasClass('imgLikeOff')) {
|
if ($link.hasClass('imgLikeOff')) {
|
||||||
|
|
||||||
|
if (type == "Person" || type == "Studio" || type == "Genre") {
|
||||||
|
ApiClient.updateItemByNameRating(Dashboard.getCurrentUserId(), id, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true);
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true);
|
||||||
|
}
|
||||||
|
|
||||||
link.src = "css/images/userdata/thumbs_up_on.png";
|
link.src = "css/images/userdata/thumbs_up_on.png";
|
||||||
$link.addClass('imgLike').removeClass('imgLikeOff');
|
$link.addClass('imgLike').removeClass('imgLikeOff');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (type == "Person" || type == "Studio" || type == "Genre") {
|
||||||
|
ApiClient.clearItemByNameRating(Dashboard.getCurrentUserId(), id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
link.src = "css/images/userdata/thumbs_up_off.png";
|
link.src = "css/images/userdata/thumbs_up_off.png";
|
||||||
$link.addClass('imgLikeOff').removeClass('imgLike');
|
$link.addClass('imgLikeOff').removeClass('imgLike');
|
||||||
|
@ -683,19 +688,30 @@
|
||||||
markDislike: function (link) {
|
markDislike: function (link) {
|
||||||
|
|
||||||
var id = link.getAttribute('data-itemid');
|
var id = link.getAttribute('data-itemid');
|
||||||
|
var type = link.getAttribute('data-type');
|
||||||
|
|
||||||
var $link = $(link);
|
var $link = $(link);
|
||||||
|
|
||||||
if ($link.hasClass('imgDislikeOff')) {
|
if ($link.hasClass('imgDislikeOff')) {
|
||||||
|
|
||||||
|
if (type == "Person" || type == "Studio" || type == "Genre") {
|
||||||
|
ApiClient.updateItemByNameRating(Dashboard.getCurrentUserId(), id, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false);
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false);
|
||||||
|
}
|
||||||
|
|
||||||
link.src = "css/images/userdata/thumbs_down_on.png";
|
link.src = "css/images/userdata/thumbs_down_on.png";
|
||||||
$link.addClass('imgDislike').removeClass('imgDislikeOff');
|
$link.addClass('imgDislike').removeClass('imgDislikeOff');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (type == "Person" || type == "Studio" || type == "Genre") {
|
||||||
|
ApiClient.clearItemByNameRating(Dashboard.getCurrentUserId(), id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
link.src = "css/images/userdata/thumbs_down_off.png";
|
link.src = "css/images/userdata/thumbs_down_off.png";
|
||||||
$link.addClass('imgDislikeOff').removeClass('imgDislike');
|
$link.addClass('imgDislikeOff').removeClass('imgDislike');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.74" targetFramework="net45" />
|
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.76" targetFramework="net45" />
|
||||||
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
|
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
|
||||||
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
|
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue