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

1 line
6.5 KiB
JavaScript
Raw Normal View History

2017-01-27 20:16:59 -07:00
define(["jQuery","humanedate","paper-icon-button-light","cardStyle"],function($){"use strict";function deleteUser(page,id){var msg=Globalize.translate("DeleteUserConfirmation");require(["confirm"],function(confirm){confirm({title:Globalize.translate("DeleteUser"),text:msg,confirmText:Globalize.translate("ButtonDelete"),primary:"cancel"}).then(function(){Dashboard.showLoadingMsg(),ApiClient.deleteUser(id).then(function(){loadData(page)})})})}function showUserMenu(elem){var card=$(elem).parents(".card")[0],page=$(card).parents(".page")[0],userId=card.getAttribute("data-userid"),menuItems=[];menuItems.push({name:Globalize.translate("ButtonOpen"),id:"open",ironIcon:"mode-edit"}),menuItems.push({name:Globalize.translate("ButtonLibraryAccess"),id:"access",ironIcon:"lock"}),menuItems.push({name:Globalize.translate("ButtonParentalControl"),id:"parentalcontrol",ironIcon:"person"}),menuItems.push({name:Globalize.translate("ButtonDelete"),id:"delete",ironIcon:"delete"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:card,callback:function(id){switch(id){case"open":Dashboard.navigate("useredit.html?userId="+userId);break;case"access":Dashboard.navigate("userlibraryaccess.html?userId="+userId);break;case"parentalcontrol":Dashboard.navigate("userparentalcontrol.html?userId="+userId);break;case"delete":deleteUser(page,userId)}}})})}function getUserHtml(user,addConnectIndicator){var html="",cssClass="card squareCard scalableCard squareCard-scalable";user.Policy.IsDisabled&&(cssClass+=" grayscale"),html+="<div data-userid='"+user.Id+"' class='"+cssClass+"'>",html+='<div class="cardBox visualCardBox">',html+='<div class="cardScalable visualCardBox-cardScalable">',html+='<div class="cardPadder cardPadder-square"></div>';var href="useredit.html?userId="+user.Id;html+='<a class="cardContent" href="'+href+'">';var imgUrl;imgUrl=user.PrimaryImageTag?ApiClient.getUserImageUrl(user.Id,{width:300,tag:user.PrimaryImageTag,type:"Primary"}):"css/images/userflyoutdefault.png";var imageClass="cardImage";user.Policy.IsDisabled&&(imageClass+=" disabledUser"),html+='<div class="'+imageClass+'" style="background-image:url(\''+imgUrl+"');\">",user.ConnectUserId&&addConnectIndicator&&(html+='<div class="cardIndicators">',html+='<div class="playedIndicator" title="'+Globalize.translate("TooltipLinkedToEmbyConnect")+'"><i class="md-icon playedIndicatorIcon indicatorIcon">cloud</i></div>',html+="</div>"),html+="</div>",html+="</a>",html+="</div>",html+='<div class="cardFooter visualCardBox-cardFooter">',html+='<div style="text-align:right; float:right;padding:0;">',html+='<button type="button" is="paper-icon-button-light" class="btnUserMenu autoSize"><i class="md-icon">more_vert</i></button>',html+="</div>",html+='<div class="cardText" style="padding-top:10px;padding-bottom:10px;">',html+=user.Name,html+="</div>",html+='<div class="cardText cardText-secondary">';var lastSeen=getLastSeenText(user.LastActivityDate);return html+=""!=lastSeen?lastSeen:"&nbsp;",html+="</div>",html+="</div>",html+="</div>",html+="</div>"}function getLastSeenText(lastActivityDate){return lastActivityDate?"Last seen "+humane_date(lastActivityDate):""}function getUserSectionHtml(users,addConnectIndicator){var html="";return html+=users.map(function(u){return getUserHtml(u,addConnectIndicator)}).join("")}function renderUsersIntoElement(elem,users,addConnectIndicator){var html=getUserSectionHtml(users,addConnectIndicator);elem.html(html),$(".btnUserMenu",elem).on("click",function(){showUserMenu(this)})}function renderUsers(page,users){renderUsersIntoElement($(".localUsers",page),users.filter(function(u){return"Guest"!=u.ConnectLinkType}),!0),renderUsersIntoElement($(".connectUsers",page),users.filter(function(u){return"Guest"==u.ConnectLinkType}))}function showPendingUserMenu(elem){var menuItems=[];menuItems.push({name:Globalize.translate("ButtonCancel"),id:"delete",ironIcon:"delete"}),require(["actionsheet"],function(actionsheet){var card=$(elem).parents(".card")[0],page=$(elem).parents(".page")[0],id=card.getAttribute("data-id");actionsheet.