jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/sync/syncjobeditor.js

1 line
11 KiB
JavaScript
Raw Normal View History

2017-03-01 13:29:42 -07:00
define(["connectionManager","serverNotifications","events","datetime","dom","imageLoader","loading","globalize","apphost","layoutManager","scrollHelper","dialogHelper","shell","listViewStyle","paper-icon-button-light","emby-button","formDialogStyle"],function(connectionManager,serverNotifications,events,datetime,dom,imageLoader,loading,globalize,appHost,layoutManager,scrollHelper,dialogHelper,shell){"use strict";function renderJob(context,job,dialogOptions){require(["syncDialog"],function(syncDialog){syncDialog.renderForm({elem:context.querySelector(".syncJobFormContent"),dialogOptions:dialogOptions,dialogOptionsFn:getTargetDialogOptionsFn(dialogOptions),showName:!0,readOnlySyncTarget:!0}).then(function(){fillJobValues(context,job,dialogOptions)})})}function getTargetDialogOptionsFn(dialogOptions){return function(targetId){return Promise.resolve(dialogOptions)}}function getJobItemHtml(jobItem,apiClient,index){var html="",hasActions=["Queued","Cancelled","Failed","ReadyToTransfer","Transferring","Converting","Synced"].indexOf(jobItem.Status)!==-1,listItemClass="listItem listItem-shaded";layoutManager.tv&&hasActions&&(listItemClass+=" btnJobItemMenu"),layoutManager.tv&&(listItemClass+=" listItem-button");var tagName=layoutManager.tv?"button":"div";html+="<"+tagName+' type="button" class="'+listItemClass+'" data-itemid="'+jobItem.Id+'" data-status="'+jobItem.Status+'" data-remove="'+jobItem.IsMarkedForRemoval+'">';var imgUrl;jobItem.PrimaryImageItemId&&(imgUrl=apiClient.getImageUrl(jobItem.PrimaryImageItemId,{type:"Primary",width:80,tag:jobItem.PrimaryImageTag,minScale:1.5})),html+=imgUrl?'<div class="listItemImage" style="background-image:url(\''+imgUrl+"');background-repeat:no-repeat;background-position:center center;background-size: cover;\"></div>":'<i class="md-icon listItemIcon">sync</i>',html+='<div class="listItemBody three-line">',html+='<h3 class="listItemBodyText">',html+=jobItem.ItemName,html+="</h3>",html+="Failed"===jobItem.Status?'<div class="secondary listItemBodyText" style="color:red;">':'<div class="secondary listItemBodyText">',html+=globalize.translate("sharedcomponents#SyncJobItemStatus"+jobItem.Status),"Synced"===jobItem.Status&&jobItem.IsMarkedForRemoval&&(html+="<br/>",html+=globalize.translate("sharedcomponents#RemovingFromDevice")),html+="</div>",html+='<div class="secondary listItemBodyText" style="padding-top:5px;">',html+='<div style="background:#e0e0e0;height:2px;"><div style="background:#52B54B;width:'+(jobItem.Progress||0)+'%;height:100%;"></div></div>',html+="</div>",html+="</div>";var moreIcon="dots-horiz"===appHost.moreIcon?"&#xE5D3;":"&#xE5D4;";return layoutManager.tv||(html+=hasActions?'<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize"><i class="md-icon">'+moreIcon+"</i></button>":'<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize" disabled><i class="md-icon">'+moreIcon+"</i></button>"),html+="</"+tagName+">"}function renderJobItems(context,items,apiClient){var html="";html+="<h1>"+globalize.translate("sharedcomponents#Items")+"</h1>",html+='<div class="paperList">';var index=0;html+=items.map(function(i){return getJobItemHtml(i,apiClient,index++)}).join(""),html+="</div>";var elem=context.querySelector(".jobItems");elem.innerHTML=html,imageLoader.lazyChildren(elem)}function parentWithClass(elem,className){for(;!elem.classList||!elem.classList.contains(className);)if(elem=elem.parentNode,!elem)return null;return elem}function showJobItemMenu(elem,jobId,apiClient){var context=parentWithClass(elem,"formDialog"),listItem=parentWithClass(elem,"listItem"),jobItemId=listItem.getAttribute("data-itemid"),status=listItem.getAttribute("data-status"),remove="true"===listItem.getAttribute("data-remove").toLowerCase(),menuItems=[];"Failed"===status||"Cancelled"===status?menuItems.push({name:globalize.translate("sharedcomponents#Retry"),id:"retry"}):"Queued"===status||"Transferring"===status||"Converting"===status||"ReadyToTransfer"===status?menuItems.push({name:globalize.translate("sharedcomponents#CancelDownload"),id:"cancel"}):"Sync