jellyfin-web/dashboard-ui/scripts/userprofilespage.js

145 lines
4.1 KiB
JavaScript
Raw Normal View History

2014-09-13 07:10:30 -07:00
(function (document, window, $) {
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
function deleteUser(page, id, name) {
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
var msg = Globalize.translate('DeleteUserConfirmation').replace('{0}', name);
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
Dashboard.confirm(msg, Globalize.translate('DeleteUser'), function (result) {
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
if (result) {
Dashboard.showLoadingMsg();
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
ApiClient.deleteUser(id).done(function () {
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
loadUsers(page);
});
}
});
}
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
function getUserHtml(user) {
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
var html = '';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += "<div class='card homePageSquareCard alternateHover bottomPaddedCard'>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<div class="cardBox visualCardBox">';
html += '<div class="cardScalable">';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<div class="cardPadder"></div>';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
var href = "useredit.html?userId=" + user.Id + "";
html += '<a class="cardContent" href="' + href + '">';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
var imgUrl;
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
if (user.PrimaryImageTag) {
2014-09-13 07:10:30 -07:00
imgUrl = ApiClient.getUserImageUrl(user.Id, {
width: 200,
tag: user.PrimaryImageTag,
type: "Primary"
});
2014-09-13 07:10:30 -07:00
} else {
imgUrl = 'css/images/userflyoutdefault.png';
}
2014-09-13 07:10:30 -07:00
html += '<div class="cardImage" style="background-image:url(\'' + imgUrl + '\');">';
2014-09-13 07:10:30 -07:00
//if (plugin.isPremium) {
// if (plugin.price > 0) {
// html += "<div class='premiumBanner'><img src='css/images/supporter/premiumflag.png' /></div>";
// } else {
// html += "<div class='premiumBanner'><img src='css/images/supporter/supporterflag.png' /></div>";
// }
//}
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
// cardContent
html += "</a>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
// cardScalable
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<div class="cardFooter">';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<div class="cardText" style="text-align:right; float:right;">';
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<button type="button" data-inline="true" data-iconpos="notext" data-icon="ellipsis-v" style="margin: 2px 0 0;"></button>';
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
html += '<div class="cardText" style="margin-right: 30px; padding: 11px 0 10px;">';
html += user.Name;
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
// cardFooter
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
// cardBox
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
// card
html += "</div>";
2013-02-20 18:33:05 -07:00
2014-09-13 07:10:30 -07:00
//html += "<li>";
//html += "<a href='useredit.html?userId=" + user.Id + "'>";
//if (user.PrimaryImageTag) {
// var url = ApiClient.getUserImageUrl(user.Id, {
// width: 80,
// tag: user.PrimaryImageTag,
// type: "Primary"
// });
// html += "<img src='" + url + "' />";
//} else {
// html += "<img src='css/images/userflyoutdefault.png' />";
//}
//html += "<h3>" + user.Name;
//html += "</h3>";
//html += "<p class='ui-li-aside'>";
//if (user.HasConfiguredPassword) html += '<img src="css/images/userdata/password.png" alt="' + Globalize.translate('Password') + '" title="' + Globalize.translate('Password') + '" class="userProfileIcon" />';
//if (user.Configuration.IsAdministrator) html += '<img src="css/images/userdata/administrator.png" alt="' + Globalize.translate('Administrator') + '" title="' + Globalize.translate('Administrator') + '" class="userProfileIcon" />';
//html += "</p>";
//html += "</a>";
//html += "<a onclick='UserProfilesPage.deleteUser(this);' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#'>" + Globalize.translate('Delete') + "</a>";
//html += "</li>";
return html;
}
function loadUsers(page) {
Dashboard.showLoadingMsg();
ApiClient.getUsers().done(function (users) {
var html = users.map(getUserHtml).join('');
$('.users', page).html(html).trigger('create');
Dashboard.hideLoadingMsg();
2013-02-20 18:33:05 -07:00
});
}
2014-09-13 07:10:30 -07:00
$(document).on('pagebeforeshow', "#userProfilesPage", function () {
var page = this;
loadUsers(page);
});
})(document, window, jQuery);