2017-06-18 00:09:29 -07:00
|
|
|
define(["connectionManager","serverNotifications","events","datetime","dom","imageLoader","loading","globalize","apphost","layoutManager","scrollHelper","dialogHelper","listViewStyle","paper-icon-button-light","emby-button","formDialogStyle","emby-linkbutton"],function(connectionManager,serverNotifications,events,datetime,dom,imageLoader,loading,globalize,appHost,layoutManager,scrollHelper,dialogHelper){"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 nextAction,html="",status=jobItem.Status;"Failed"===status||"Cancelled"===status?nextAction="retry":"Queued"===status||"Transferring"===status||"Converting"===status||"ReadyToTransfer"===status?nextAction="cancel":"Synced"!==status||jobItem.IsMarkedForRemoval||(nextAction="remove");var listItemClass="listItem listItem-shaded";layoutManager.tv&&nextAction&&(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-action="'+nextAction+'">';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>";"dots-horiz"===appHost.moreIcon?"":"";return layoutManager.tv||("retry"===nextAction?html+='<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="'+nextAction+'"><i class="md-icon"></i></button>':"cancel"===nextAction?html+='<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="'+nextAction+'"><i class="md-icon"></i></button>':"remove"===nextAction&&(html+='<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="'+nextAction+'"><i class="md-icon"></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 action=elem.getAttribute("data-action"),context=parentWithClass(elem,"formDialog"),listItem=parentWithClass(elem,"listItem"),jobItemId=listItem.getAttribute("data-itemid");"retry"===action?retryJobIte
|