diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css b/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css index c0a03baae0..57795e6502 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css @@ -1 +1 @@ -.emby-tab-button,.emby-tabs-slider{position:relative}.emby-tab-button{background:0 0;-webkit-box-shadow:none;box-shadow:none;border:2px solid transparent;border-width:0 0 2px;cursor:pointer;outline:0!important;width:auto;font-family:inherit;font-size:inherit;display:inline-block;vertical-align:middle;-webkit-flex-shrink:0;flex-shrink:0;margin:0;padding:1em .9em;height:auto;min-width:initial;line-height:initial;-webkit-border-radius:0!important;border-radius:0!important;overflow:hidden;color:#999}.emby-tab-button.emby-button-tv{padding-top:.4em;padding-bottom:.4em}.emby-tab-button-active{color:#52B54B;border-color:#52B54B}.emby-tab-button-active.emby-button-tv{border-color:transparent;color:#fff}.emby-tab-button.emby-button-tv:focus{color:#52B54B;border-color:#52B54B}.emby-tabs-selection-bar{position:absolute;left:0;bottom:0;height:2px;z-index:1000;background:#52B54B;width:0}.emby-tab-button-selection-bar{position:absolute;left:0;border:0;bottom:1px;height:2px;right:0;-webkit-border-radius:0;border-radius:0;z-index:1000}.emby-tab-button-selection-bar-active{background:#52B54B}.emby-tab-button-ripple-effect{background:#141414!important}.tabContent:not(.is-active){display:none} \ No newline at end of file +.emby-tab-button,.emby-tabs-slider{position:relative}.emby-tab-button{background:0 0;-webkit-box-shadow:none;box-shadow:none;border:2px solid transparent;border-width:0 0 2px;cursor:pointer;outline:0!important;width:auto;font-family:inherit;font-size:inherit;color:#aaa;display:inline-block;vertical-align:middle;-webkit-flex-shrink:0;flex-shrink:0;margin:0;padding:1em .9em;height:auto;min-width:initial;line-height:initial;-webkit-border-radius:0!important;border-radius:0!important;overflow:hidden}.emby-tab-button-active{color:#52B54B;border-color:#52B54B}.emby-tabs-selection-bar{position:absolute;left:0;bottom:0;height:2px;z-index:1000;background:#52B54B;width:0}.emby-tab-button-selection-bar{position:absolute;left:0;border:0;bottom:1px;height:2px;right:0;-webkit-border-radius:0;border-radius:0;z-index:1000}.emby-tab-button-selection-bar-active{background:#52B54B}.emby-tab-button-ripple-effect{background:#141414!important} \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js b/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js index 0f303fce9b..9e56aa94dc 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js @@ -1 +1 @@ -define(["dom","scroller","browser","layoutManager","focusManager","registerElement","css!./emby-tabs","scrollStyles"],function(dom,scroller,browser,layoutManager,focusManager){"use strict";function getBoundingClientRect(elem){return elem.getBoundingClientRect?elem.getBoundingClientRect():{top:0,left:0}}function animtateSelectionBar(bar,start,pos,duration,onFinish){var endTransform=pos?"translateX("+Math.round(pos)+"px)":"none";if(!duration||!bar.animate||layoutManager.tv)return bar.style.transform=endTransform,void(onFinish&&onFinish());var startTransform=start?"translateX("+Math.round(start)+"px)":"none";bar.style.transform=startTransform;var keyframes=[{transform:"translateX("+start+"px)",offset:0},{transform:endTransform,offset:1}];bar.animate(keyframes,{duration:duration,iterations:1,easing:"linear",fill:"forwards"}),setTimeout(onFinish,duration)}function moveSelectionBar(tabs,newButton,oldButton,animate){var selectionBar=tabs.selectionBar;selectionBar&&(selectionBar.style.width=newButton.offsetWidth+"px",selectionBar.classList.remove("hide"));var tabsOffset=getBoundingClientRect(tabs),startOffset=tabs.currentOffset||0;oldButton&&(startOffset=tabs.scroller?tabs.scroller.getCenterPosition(oldButton):getBoundingClientRect(oldButton).left-tabsOffset.left);var endPosition;if(tabs.scroller)endPosition=tabs.scroller.getCenterPosition(newButton);else{var tabButtonOffset=getBoundingClientRect(newButton);endPosition=tabButtonOffset.left-tabsOffset.left}var delay=animate?100:0;tabs.currentOffset=endPosition;var onAnimationFinish=function(){newButton.classList.add(activeButtonClass),selectionBar&&selectionBar.classList.add("hide")};selectionBar?animtateSelectionBar(selectionBar,startOffset,endPosition,delay,onAnimationFinish):onAnimationFinish()}function getFocusCallback(tabs,e){return function(){onClick.call(tabs,e)}}function onFocus(e){layoutManager.tv&&(this.focusTimeout&&clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(getFocusCallback(this,e),700))}function getTabPanel(tabs,index){var tabsContainer=dom.parentWithClass(tabs,"tabs-container");if(tabsContainer)return tabsContainer.querySelector('.tabContent[data-index="'+index+'"]')}function removeActivePanelClass(tabs,index){var tabPanel=getTabPanel(tabs,index);tabPanel&&tabPanel.classList.remove("is-active")}function fadeInRight(elem){var pct=browser.mobile?"4%":"0.5%",keyframes=[{opacity:"0",transform:"translate3d("+pct+", 0, 0)",offset:0},{opacity:"1",transform:"none",offset:1}];elem.animate(keyframes,{duration:160,iterations:1,easing:"ease-out"})}function triggerBeforeTabChange(tabs,index,previousIndex){tabs.dispatchEvent(new CustomEvent("beforetabchange",{detail:{selectedTabIndex:index,previousIndex:previousIndex}})),null!=previousIndex&&previousIndex!==index&&removeActivePanelClass(tabs,previousIndex);var newPanel=getTabPanel(tabs,index);newPanel&&(newPanel.animate&&fadeInRight(newPanel),newPanel.classList.add("is-active"))}function onClick(e){var tabs=this,current=tabs.querySelector("."+activeButtonClass),tabButton=dom.parentWithClass(e.target,buttonClass);if(tabButton&&tabButton!==current){current&¤t.classList.remove(activeButtonClass);var previousIndex=current?parseInt(current.getAttribute("data-index")):null;moveSelectionBar(tabs,tabButton,current,!0);var index=parseInt(tabButton.getAttribute("data-index"));triggerBeforeTabChange(tabs,index,previousIndex),setTimeout(function(){tabs.selectedTabIndex=index,tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:index,previousIndex:previousIndex}}))},120),tabs.scroller&&tabs.scroller.toCenter(tabButton,!1)}}function initScroller(tabs){if(!tabs.scroller){var contentScrollSlider=tabs.querySelector(".emby-tabs-slider");contentScrollSlider?(tabs.scroller=new scroller(tabs,{horizontal:1,itemNav:0,mouseDragging:1,touchDragging:1,slidee:contentScrollSlider,smart:!0,releaseSwing:!0,scrollBy:200,speed:120,elasticBounds:1,dragHandle:1,dynamicHandle:1,clickBar:1,hiddenScroll:!0,requireAnimation:!browser.safari}),tabs.scroller.init()):tabs.classList.add("hiddenScrollX")}}function initSelectionBar(tabs){if(browser.animate){var contentScrollSlider=tabs.querySelector(".emby-tabs-slider");if(contentScrollSlider&&"false"!==tabs.getAttribute("data-selectionbar")){var elem=document.createElement("div");elem.classList.add("emby-tabs-selection-bar"),contentScrollSlider.appendChild(elem),tabs.selectionBar=elem}}}var EmbyTabs=Object.create(HTMLDivElement.prototype),buttonClass="emby-tab-button",activeButtonClass=buttonClass+"-active";EmbyTabs.createdCallback=function(){this.classList.contains("emby-tabs")||(this.classList.add("emby-tabs"),this.classList.add("focusable"),dom.addEventListener(this,"click",onClick,{passive:!0}),dom.addEventListener(this,"focus",onFocus,{passive:!0,capture:!0}),initSelectionBar(this))},EmbyTabs.focus=function(){var selected=this.querySelector("."+activeButtonClass);selected?focusManager.focus(selected):focusManager.autoFocus(this)},EmbyTabs.refresh=function(){this.scroller&&this.scroller.reload()},EmbyTabs.attachedCallback=function(){initScroller(this);var current=this.querySelector("."+activeButtonClass),currentIndex=current?parseInt(current.getAttribute("data-index")):0,tabButtons=this.querySelectorAll("."+buttonClass),newTabButton=tabButtons[currentIndex];newTabButton&&moveSelectionBar(this,newTabButton,current,!1)},EmbyTabs.detachedCallback=function(){this.scroller&&(this.scroller.destroy(),this.scroller=null),dom.removeEventListener(this,"click",onClick,{passive:!0}),dom.removeEventListener(this,"focus",onFocus,{passive:!0,capture:!0}),this.selectionBar=null},EmbyTabs.selectedIndex=function(selected,triggerEvent){var tabs=this;if(null==selected)return tabs.selectedTabIndex||0;var current=tabs.selectedIndex();tabs.selectedTabIndex=selected;var tabButtons=tabs.querySelectorAll("."+buttonClass);if(current===selected||triggerEvent===!1){triggerBeforeTabChange(tabs,selected,current),tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:selected}}));var currentTabButton=tabButtons[current];moveSelectionBar(tabs,tabButtons[selected],currentTabButton,!1),current!==selected&¤tTabButton&¤tTabButton.classList.remove(activeButtonClass)}else tabButtons[selected].click()},EmbyTabs.triggerBeforeTabChange=function(selected){var tabs=this;triggerBeforeTabChange(tabs,tabs.selectedIndex())},EmbyTabs.triggerTabChange=function(selected){var tabs=this;tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:tabs.selectedIndex()}}))},document.registerElement("emby-tabs",{prototype:EmbyTabs,extends:"div"})}); \ No newline at end of file +define(["dom","scroller","browser","layoutManager","focusManager","registerElement","css!./emby-tabs","scrollStyles"],function(dom,scroller,browser,layoutManager,focusManager){"use strict";function getBoundingClientRect(elem){return elem.getBoundingClientRect?elem.getBoundingClientRect():{top:0,left:0}}function animtateSelectionBar(bar,start,pos,duration,onFinish){var endTransform=pos?"translateX("+Math.round(pos)+"px)":"none",startTransform=start?"translateX("+Math.round(start)+"px)":"none";if(!duration||!bar.animate)return bar.style.transform=endTransform,void(onFinish&&onFinish());bar.style.transform=startTransform;var keyframes=[{transform:"translateX("+start+"px)",offset:0},{transform:endTransform,offset:1}];bar.animate(keyframes,{duration:duration,iterations:1,easing:"linear",fill:"forwards"}),setTimeout(onFinish,duration)}function moveSelectionBar(tabs,newButton,oldButton,animate){var selectionBar=tabs.selectionBar;selectionBar&&(selectionBar.style.width=newButton.offsetWidth+"px",selectionBar.classList.remove("hide"));var tabsOffset=getBoundingClientRect(tabs),startOffset=tabs.currentOffset||0;oldButton&&(startOffset=tabs.scroller?tabs.scroller.getCenterPosition(oldButton):getBoundingClientRect(oldButton).left-tabsOffset.left);var endPosition;if(tabs.scroller)endPosition=tabs.scroller.getCenterPosition(newButton);else{var tabButtonOffset=getBoundingClientRect(newButton);endPosition=tabButtonOffset.left-tabsOffset.left}var delay=animate?100:0;tabs.currentOffset=endPosition;var onAnimationFinish=function(){newButton.classList.add(activeButtonClass),selectionBar&&selectionBar.classList.add("hide")};selectionBar?animtateSelectionBar(selectionBar,startOffset,endPosition,delay,onAnimationFinish):onAnimationFinish()}function getFocusCallback(tabs,e){return function(){onClick.call(tabs,e)}}function onFocus(e){layoutManager.tv&&(this.focusTimeout&&clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(getFocusCallback(this,e),700))}function onClick(e){var tabs=this,current=tabs.querySelector("."+activeButtonClass),tabButton=dom.parentWithClass(e.target,buttonClass);if(tabButton&&tabButton!==current){current&¤t.classList.remove(activeButtonClass);var previousIndex=current?parseInt(current.getAttribute("data-index")):null;moveSelectionBar(tabs,tabButton,current,!0);var index=parseInt(tabButton.getAttribute("data-index"));tabs.dispatchEvent(new CustomEvent("beforetabchange",{detail:{selectedTabIndex:index,previousIndex:previousIndex}})),setTimeout(function(){tabs.selectedTabIndex=index,tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:index,previousIndex:previousIndex}}))},120),tabs.scroller&&tabs.scroller.toCenter(tabButton,!1)}}function initScroller(tabs){if(!tabs.scroller){var contentScrollSlider=tabs.querySelector(".emby-tabs-slider");contentScrollSlider?(tabs.scroller=new scroller(tabs,{horizontal:1,itemNav:0,mouseDragging:1,touchDragging:1,slidee:contentScrollSlider,smart:!0,releaseSwing:!0,scrollBy:200,speed:120,elasticBounds:1,dragHandle:1,dynamicHandle:1,clickBar:1,hiddenScroll:!0,requireAnimation:!browser.safari}),tabs.scroller.init()):tabs.classList.add("hiddenScrollX")}}function initSelectionBar(tabs){if(browser.animate){var contentScrollSlider=tabs.querySelector(".emby-tabs-slider");if(contentScrollSlider&&"false"!==tabs.getAttribute("data-selectionbar")){var elem=document.createElement("div");elem.classList.add("emby-tabs-selection-bar"),contentScrollSlider.appendChild(elem),tabs.selectionBar=elem}}}var EmbyTabs=Object.create(HTMLDivElement.prototype),buttonClass="emby-tab-button",activeButtonClass=buttonClass+"-active";EmbyTabs.createdCallback=function(){this.classList.contains("emby-tabs")||(this.classList.add("emby-tabs"),this.classList.add("focusable"),dom.addEventListener(this,"click",onClick,{passive:!0}),dom.addEventListener(this,"focus",onFocus,{passive:!0,capture:!0}),initSelectionBar(this))},EmbyTabs.focus=function(){var selected=this.querySelector("."+activeButtonClass);selected?focusManager.focus(selected):focusManager.autoFocus(this)},EmbyTabs.refresh=function(){this.scroller&&this.scroller.reload()},EmbyTabs.attachedCallback=function(){initScroller(this);var current=this.querySelector("."+activeButtonClass),currentIndex=current?parseInt(current.getAttribute("data-index")):0,newTabButton=this.querySelectorAll("."+buttonClass)[currentIndex];newTabButton&&moveSelectionBar(this,newTabButton,current,!1)},EmbyTabs.detachedCallback=function(){this.scroller&&(this.scroller.destroy(),this.scroller=null),dom.removeEventListener(this,"click",onClick,{passive:!0}),dom.removeEventListener(this,"focus",onFocus,{passive:!0,capture:!0}),this.selectionBar=null},EmbyTabs.selectedIndex=function(selected,triggerEvent){var tabs=this;if(null==selected)return tabs.selectedTabIndex||0;var current=tabs.selectedIndex();tabs.selectedTabIndex=selected;var tabButtons=tabs.querySelectorAll("."+buttonClass);if(current===selected||triggerEvent===!1){tabs.dispatchEvent(new CustomEvent("beforetabchange",{detail:{selectedTabIndex:selected}})),tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:selected}}));var currentTabButton=tabButtons[current];moveSelectionBar(tabs,tabButtons[selected],currentTabButton,!1),current!==selected&¤tTabButton&¤tTabButton.classList.remove(activeButtonClass)}else tabButtons[selected].click()},EmbyTabs.triggerBeforeTabChange=function(selected){var tabs=this;tabs.dispatchEvent(new CustomEvent("beforetabchange",{detail:{selectedTabIndex:tabs.selectedIndex()}}))},EmbyTabs.triggerTabChange=function(selected){var tabs=this;tabs.dispatchEvent(new CustomEvent("tabchange",{detail:{selectedTabIndex:tabs.selectedIndex()}}))},document.registerElement("emby-tabs",{prototype:EmbyTabs,extends:"div"})}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/registrationservices/registrationservices.js b/dashboard-ui/bower_components/emby-webcomponents/registrationservices/registrationservices.js index 0a2b95b3cc..ae2af57afb 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/registrationservices/registrationservices.js +++ b/dashboard-ui/bower_components/emby-webcomponents/registrationservices/registrationservices.js @@ -1 +1 @@ -define(["appSettings","loading","apphost","iapManager","events","shell","globalize","dialogHelper","connectionManager","layoutManager","emby-button"],function(appSettings,loading,appHost,iapManager,events,shell,globalize,dialogHelper,connectionManager,layoutManager){"use strict";function alertText(options){return new Promise(function(resolve,reject){require(["alert"],function(alert){alert(options).then(resolve,reject)})})}function showInAppPurchaseInfo(subscriptionOptions,unlockableProductInfo,dialogOptions){return new Promise(function(resolve,reject){require(["listViewStyle","formDialogStyle"],function(){showInAppPurchaseElement(subscriptionOptions,unlockableProductInfo,dialogOptions,resolve,reject),currentDisplayingResolve=resolve})})}function showPeriodicMessage(feature,settingsKey){return new Promise(function(resolve,reject){require(["listViewStyle","emby-button","formDialogStyle"],function(){var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

Emby Premiere',html+="

",html+="
",html+='
',html+='
',html+="

"+globalize.translate("sharedcomponents#HeaderDiscoverEmbyPremiere")+"

",html+="

"+globalize.translate("sharedcomponents#MessageDidYouKnowCinemaMode")+"

",html+="

"+globalize.translate("sharedcomponents#MessageDidYouKnowCinemaMode2")+"

",html+='

'+globalize.translate("sharedcomponents#HeaderBenefitsEmbyPremiere")+"

",html+='
',html+=getSubscriptionBenefits().map(getSubscriptionBenefitHtml).join(""),html+="
",html+="
",html+='
',html+='";var seconds=14;html+='
'+globalize.translate("sharedcomponents#ContinueInSecondsValue",seconds)+"
",html+='",html+="
",html+="
",html+="
",dlg.innerHTML=html;var i,length,isRejected=!0,timeTextInterval=setInterval(function(){seconds-=1,seconds<=0?(dlg.querySelector(".continueTimeText").classList.add("hide"),dlg.querySelector(".btnContinue").classList.remove("hide")):dlg.querySelector(".continueTimeText").innerHTML=globalize.translate("sharedcomponents#ContinueInSecondsValue",seconds)},1e3),btnPurchases=dlg.querySelectorAll(".buttonPremiereInfo");for(i=0,length=btnPurchases.length;iintervalMs?connectionManager.currentApiClient().getPluginSecurityInfo().then(function(regInfo){return regInfo.IsMBSupporter?(appSettings.set(settingsKey,(new Date).getTime()),Promise.resolve()):showPeriodicMessage(feature,settingsKey)},function(){return showPeriodicMessage(feature,settingsKey)}):Promise.resolve():(appSettings.set(settingsKey,(new Date).getTime()),Promise.resolve())}function validateFeature(feature,options){return options=options||{},console.log("validateFeature: "+feature),iapManager.isUnlockedByDefault(feature,options).then(function(){return showPeriodicMessageIfNeeded(feature)},function(){var unlockableFeatureCacheKey="featurepurchased-"+feature;if("1"===appSettings.get(unlockableFeatureCacheKey))return showPeriodicMessageIfNeeded(feature);var unlockableProduct=iapManager.getProductInfo(feature);if(unlockableProduct){var unlockableCacheKey="productpurchased-"+unlockableProduct.id;if(unlockableProduct.owned)return appSettings.set(unlockableFeatureCacheKey,"1"),appSettings.set(unlockableCacheKey,"1"),showPeriodicMessageIfNeeded(feature);if("1"===appSettings.get(unlockableCacheKey))return showPeriodicMessageIfNeeded(feature)}var unlockableProductInfo=unlockableProduct?{enableAppUnlock:!0,id:unlockableProduct.id,price:unlockableProduct.price,feature:feature}:null;return iapManager.getSubscriptionOptions().then(function(subscriptionOptions){return subscriptionOptions.filter(function(p){return p.owned}).length>0?Promise.resolve():connectionManager.getRegistrationInfo(iapManager.getAdminFeatureName(feature),connectionManager.currentApiClient()).catch(function(){var dialogOptions={title:globalize.translate("sharedcomponents#HeaderUnlockFeature"),feature:feature};return options.showDialog===!1?Promise.reject():showInAppPurchaseInfo(subscriptionOptions,unlockableProductInfo,dialogOptions)})})})}function cancelInAppPurchase(){var elem=document.querySelector(".inAppPurchaseOverlay");elem&&dialogHelper.close(elem)}function clearCurrentDisplayingInfo(){currentDisplayingProductInfos=[],currentDisplayingResolve=null}function showExternalPremiereInfo(){shell.openUrl("https://emby.media/premiere")}function centerFocus(elem,horiz,on){require(["scrollHelper"],function(scrollHelper){var fn=on?"on":"off";scrollHelper.centerFocus[fn](elem,horiz)})}function showInAppPurchaseElement(subscriptionOptions,unlockableProductInfo,dialogOptions,resolve,reject){function onCloseButtonClick(){rejected=!0,dialogHelper.close(dlg)}cancelInAppPurchase(),currentDisplayingProductInfos=subscriptionOptions.slice(0),unlockableProductInfo&¤tDisplayingProductInfos.push(unlockableProductInfo);var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=dialogOptions.title||"",html+="

",html+="
",html+='
',html+='
',html+='
',html+='

',html+=unlockableProductInfo?globalize.translate("sharedcomponents#MessageUnlockAppWithPurchaseOrSupporter"):globalize.translate("sharedcomponents#MessageUnlockAppWithSupporter"),html+="

",html+='

',html+=globalize.translate("sharedcomponents#MessageToValidateSupporter"),html+="

";var i,length,hasProduct=!1;for(i=0,length=subscriptionOptions.length;i",html+='",html+="

";if(unlockableProductInfo){hasProduct=!0;var unlockText=globalize.translate("sharedcomponents#ButtonUnlockWithPurchase");unlockableProductInfo.price&&(unlockText=globalize.translate("sharedcomponents#ButtonUnlockPrice",unlockableProductInfo.price)),html+="

",html+='",html+="

"}html+="

",html+='",html+="

",subscriptionOptions.length&&(html+='

'+globalize.translate("sharedcomponents#HeaderBenefitsEmbyPremiere")+"

",html+='
',html+=getSubscriptionBenefits().map(getSubscriptionBenefitHtml).join(""),html+="
"),"playback"===dialogOptions.feature&&(html+="

",html+='",html+="

"),html+="",html+="
",html+="
",dlg.innerHTML=html,document.body.appendChild(dlg);var btnPurchases=dlg.querySelectorAll(".btnPurchase");for(i=0,length=btnPurchases.length;i'):html+='
',html+=''+item.icon+"",html+='
',html+='

',html+=item.name,html+="

",html+='
',html+=item.text,html+="
",html+="
",html+=enableLink?"":"
"}function onPurchaseButtonClick(){var featureId=this.getAttribute("data-featureid");"true"===this.getAttribute("data-email")?getUserEmail().then(function(email){iapManager.beginPurchase(featureId,email)}):iapManager.beginPurchase(featureId)}function restorePurchase(unlockableProductInfo){var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=iapManager.getRestoreButtonText(),html+="

",html+="
",html+='
',html+='
',html+='

',html+=globalize.translate("sharedcomponents#HowDidYouPay"),html+="

",html+="

",html+='",html+="

",unlockableProductInfo&&(html+="

",html+='",html+="

"),html+="
",html+="
",dlg.innerHTML=html,document.body.appendChild(dlg),loading.hide(),layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!0),dlg.querySelector(".btnCloseDialog").addEventListener("click",function(){dialogHelper.close(dlg)}),dlg.querySelector(".btnRestoreSub").addEventListener("click",function(){dialogHelper.close(dlg),alertText({text:globalize.translate("sharedcomponents#MessageToValidateSupporter"),title:"Emby Premiere"})});var btnRestoreUnlock=dlg.querySelector(".btnRestoreUnlock");btnRestoreUnlock&&btnRestoreUnlock.addEventListener("click",function(){dialogHelper.close(dlg),iapManager.restorePurchase()}),dialogHelper.open(dlg).then(function(){layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!1)})}function getUserEmail(){if(connectionManager.isLoggedIntoConnect()){var connectUser=connectionManager.connectUser();if(connectUser&&connectUser.Email)return Promise.resolve(connectUser.Email)}return new Promise(function(resolve,reject){require(["prompt"],function(prompt){prompt({label:globalize.translate("sharedcomponents#LabelEmailAddress")}).then(resolve,reject)})})}function onProductUpdated(e,product){if(product.owned){var resolve=currentDisplayingResolve;resolve&¤tDisplayingProductInfos.filter(function(p){return product.id===p.id}).length&&(cancelInAppPurchase(),resolve())}}function showPremiereInfo(){return appHost.supports("externalpremium")?(showExternalPremiereInfo(),Promise.resolve()):iapManager.getSubscriptionOptions().then(function(subscriptionOptions){var dialogOptions={title:"Emby Premiere",feature:"sync"};return showInAppPurchaseInfo(subscriptionOptions,null,dialogOptions)})}var currentDisplayingProductInfos=[],currentDisplayingResolve=null;return events.on(iapManager,"productupdated",onProductUpdated),{validateFeature:validateFeature,showPremiereInfo:showPremiereInfo}}); \ No newline at end of file +define(["appSettings","loading","apphost","iapManager","events","shell","globalize","dialogHelper","connectionManager","layoutManager","emby-button"],function(appSettings,loading,appHost,iapManager,events,shell,globalize,dialogHelper,connectionManager,layoutManager){"use strict";function alertText(options){return new Promise(function(resolve,reject){require(["alert"],function(alert){alert(options).then(resolve,reject)})})}function showInAppPurchaseInfo(subscriptionOptions,unlockableProductInfo,dialogOptions){return new Promise(function(resolve,reject){require(["listViewStyle","formDialogStyle"],function(){showInAppPurchaseElement(subscriptionOptions,unlockableProductInfo,dialogOptions,resolve,reject),currentDisplayingResolve=resolve})})}function showPeriodicMessage(feature,settingsKey){return new Promise(function(resolve,reject){require(["listViewStyle","emby-button","formDialogStyle"],function(){var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

Emby Premiere',html+="

",html+="
",html+='
',html+='
',html+="

"+globalize.translate("sharedcomponents#HeaderDiscoverEmbyPremiere")+"

",html+="

"+globalize.translate("sharedcomponents#MessageDidYouKnowCinemaMode")+"

",html+="

"+globalize.translate("sharedcomponents#MessageDidYouKnowCinemaMode2")+"

",html+='

'+globalize.translate("sharedcomponents#HeaderBenefitsEmbyPremiere")+"

",html+='
',html+=getSubscriptionBenefits().map(getSubscriptionBenefitHtml).join(""),html+="
",html+="
",html+='
',html+='";var seconds=12;html+='
'+globalize.translate("sharedcomponents#ContinueInSecondsValue",seconds)+"
",html+='",html+="
",html+="
",html+="
",dlg.innerHTML=html;var i,length,isRejected=!0,timeTextInterval=setInterval(function(){seconds-=1,seconds<=0?(dlg.querySelector(".continueTimeText").classList.add("hide"),dlg.querySelector(".btnContinue").classList.remove("hide")):dlg.querySelector(".continueTimeText").innerHTML=globalize.translate("sharedcomponents#ContinueInSecondsValue",seconds)},1e3),btnPurchases=dlg.querySelectorAll(".buttonPremiereInfo");for(i=0,length=btnPurchases.length;iintervalMs?connectionManager.currentApiClient().getPluginSecurityInfo().then(function(regInfo){return regInfo.IsMBSupporter?(appSettings.set(settingsKey,(new Date).getTime()),Promise.resolve()):showPeriodicMessage(feature,settingsKey)},function(){return showPeriodicMessage(feature,settingsKey)}):Promise.resolve():(appSettings.set(settingsKey,(new Date).getTime()),Promise.resolve())}function validateFeature(feature,options){return options=options||{},console.log("validateFeature: "+feature),iapManager.isUnlockedByDefault(feature,options).then(function(){return showPeriodicMessageIfNeeded(feature)},function(){var unlockableFeatureCacheKey="featurepurchased-"+feature;if("1"===appSettings.get(unlockableFeatureCacheKey))return showPeriodicMessageIfNeeded(feature);var unlockableProduct=iapManager.getProductInfo(feature);if(unlockableProduct){var unlockableCacheKey="productpurchased-"+unlockableProduct.id;if(unlockableProduct.owned)return appSettings.set(unlockableFeatureCacheKey,"1"),appSettings.set(unlockableCacheKey,"1"),showPeriodicMessageIfNeeded(feature);if("1"===appSettings.get(unlockableCacheKey))return showPeriodicMessageIfNeeded(feature)}var unlockableProductInfo=unlockableProduct?{enableAppUnlock:!0,id:unlockableProduct.id,price:unlockableProduct.price,feature:feature}:null;return iapManager.getSubscriptionOptions().then(function(subscriptionOptions){return subscriptionOptions.filter(function(p){return p.owned}).length>0?Promise.resolve():connectionManager.getRegistrationInfo(iapManager.getAdminFeatureName(feature),connectionManager.currentApiClient()).catch(function(){var dialogOptions={title:globalize.translate("sharedcomponents#HeaderUnlockFeature"),feature:feature};return options.showDialog===!1?Promise.reject():showInAppPurchaseInfo(subscriptionOptions,unlockableProductInfo,dialogOptions)})})})}function cancelInAppPurchase(){var elem=document.querySelector(".inAppPurchaseOverlay");elem&&dialogHelper.close(elem)}function clearCurrentDisplayingInfo(){currentDisplayingProductInfos=[],currentDisplayingResolve=null}function showExternalPremiereInfo(){shell.openUrl("https://emby.media/premiere")}function centerFocus(elem,horiz,on){require(["scrollHelper"],function(scrollHelper){var fn=on?"on":"off";scrollHelper.centerFocus[fn](elem,horiz)})}function showInAppPurchaseElement(subscriptionOptions,unlockableProductInfo,dialogOptions,resolve,reject){function onCloseButtonClick(){rejected=!0,dialogHelper.close(dlg)}cancelInAppPurchase(),currentDisplayingProductInfos=subscriptionOptions.slice(0),unlockableProductInfo&¤tDisplayingProductInfos.push(unlockableProductInfo);var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=dialogOptions.title||"",html+="

",html+="
",html+='
',html+='
',html+='
',html+='

',html+=unlockableProductInfo?globalize.translate("sharedcomponents#MessageUnlockAppWithPurchaseOrSupporter"):globalize.translate("sharedcomponents#MessageUnlockAppWithSupporter"),html+="

",html+='

',html+=globalize.translate("sharedcomponents#MessageToValidateSupporter"),html+="

";var i,length,hasProduct=!1;for(i=0,length=subscriptionOptions.length;i",html+='",html+="

";if(unlockableProductInfo){hasProduct=!0;var unlockText=globalize.translate("sharedcomponents#ButtonUnlockWithPurchase");unlockableProductInfo.price&&(unlockText=globalize.translate("sharedcomponents#ButtonUnlockPrice",unlockableProductInfo.price)),html+="

",html+='",html+="

"}html+="

",html+='",html+="

",subscriptionOptions.length&&(html+='

'+globalize.translate("sharedcomponents#HeaderBenefitsEmbyPremiere")+"

",html+='
',html+=getSubscriptionBenefits().map(getSubscriptionBenefitHtml).join(""),html+="
"),"playback"===dialogOptions.feature&&(html+="

",html+='",html+="

"),html+="",html+="
",html+="
",dlg.innerHTML=html,document.body.appendChild(dlg);var btnPurchases=dlg.querySelectorAll(".btnPurchase");for(i=0,length=btnPurchases.length;i'):html+='
',html+=''+item.icon+"",html+='
',html+='

',html+=item.name,html+="

",html+='
',html+=item.text,html+="
",html+="
",html+=enableLink?"":"
"}function onPurchaseButtonClick(){var featureId=this.getAttribute("data-featureid");"true"===this.getAttribute("data-email")?getUserEmail().then(function(email){iapManager.beginPurchase(featureId,email)}):iapManager.beginPurchase(featureId)}function restorePurchase(unlockableProductInfo){var dlg=dialogHelper.createDialog({size:layoutManager.tv?"fullscreen":"fullscreen-border",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=iapManager.getRestoreButtonText(),html+="

",html+="
",html+='
',html+='
',html+='

',html+=globalize.translate("sharedcomponents#HowDidYouPay"),html+="

",html+="

",html+='",html+="

",unlockableProductInfo&&(html+="

",html+='",html+="

"),html+="
",html+="
",dlg.innerHTML=html,document.body.appendChild(dlg),loading.hide(),layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!0),dlg.querySelector(".btnCloseDialog").addEventListener("click",function(){dialogHelper.close(dlg)}),dlg.querySelector(".btnRestoreSub").addEventListener("click",function(){dialogHelper.close(dlg),alertText({text:globalize.translate("sharedcomponents#MessageToValidateSupporter"),title:"Emby Premiere"})});var btnRestoreUnlock=dlg.querySelector(".btnRestoreUnlock");btnRestoreUnlock&&btnRestoreUnlock.addEventListener("click",function(){dialogHelper.close(dlg),iapManager.restorePurchase()}),dialogHelper.open(dlg).then(function(){layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!1)})}function getUserEmail(){if(connectionManager.isLoggedIntoConnect()){var connectUser=connectionManager.connectUser();if(connectUser&&connectUser.Email)return Promise.resolve(connectUser.Email)}return new Promise(function(resolve,reject){require(["prompt"],function(prompt){prompt({label:globalize.translate("sharedcomponents#LabelEmailAddress")}).then(resolve,reject)})})}function onProductUpdated(e,product){if(product.owned){var resolve=currentDisplayingResolve;resolve&¤tDisplayingProductInfos.filter(function(p){return product.id===p.id}).length&&(cancelInAppPurchase(),resolve())}}function showPremiereInfo(){return appHost.supports("externalpremium")?(showExternalPremiereInfo(),Promise.resolve()):iapManager.getSubscriptionOptions().then(function(subscriptionOptions){var dialogOptions={title:"Emby Premiere",feature:"sync"};return showInAppPurchaseInfo(subscriptionOptions,null,dialogOptions)})}var currentDisplayingProductInfos=[],currentDisplayingResolve=null;return events.on(iapManager,"productupdated",onProductUpdated),{validateFeature:validateFeature,showPremiereInfo:showPremiereInfo}}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/sync/sync.js b/dashboard-ui/bower_components/emby-webcomponents/sync/sync.js index 44ba9b912b..9bd3377179 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/sync/sync.js +++ b/dashboard-ui/bower_components/emby-webcomponents/sync/sync.js @@ -1 +1 @@ -define(["apphost","globalize","connectionManager","layoutManager","shell","focusManager","scrollHelper","appSettings","registrationServices","dialogHelper","paper-icon-button-light","formDialogStyle"],function(appHost,globalize,connectionManager,layoutManager,shell,focusManager,scrollHelper,appSettings,registrationServices,dialogHelper){"use strict";function submitJob(dlg,apiClient,userId,syncOptions,form){if(!userId)throw new Error("userId cannot be null");if(!syncOptions)throw new Error("syncOptions cannot be null");if(!form)throw new Error("form cannot be null");var selectSyncTarget=form.querySelector("#selectSyncTarget"),target=selectSyncTarget?selectSyncTarget.value:null;if(!target)return require(["toast"],function(toast){toast(globalize.translate("sharedcomponents#PleaseSelectDeviceToSyncTo"))}),!1;var options={userId:userId,TargetId:target,ParentId:syncOptions.ParentId,Category:syncOptions.Category};return setJobValues(options,form),syncOptions.items&&syncOptions.items.length&&(options.ItemIds=(syncOptions.items||[]).map(function(i){return i.Id||i}).join(",")),apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/Jobs"),data:JSON.stringify(options),contentType:"application/json",dataType:"json"}).then(function(){dialogHelper.close(dlg),require(["toast"],function(toast){var msg=target===apiClient.deviceId()?globalize.translate("sharedcomponents#DownloadScheduled"):globalize.translate("sharedcomponents#SyncJobCreated");toast(msg)})}),!0}function submitQuickSyncJob(apiClient,userId,targetId,syncOptions){if(!userId)throw new Error("userId cannot be null");if(!syncOptions)throw new Error("syncOptions cannot be null");if(!targetId)throw new Error("targetId cannot be null");var options={userId:userId,TargetId:targetId,ParentId:syncOptions.ParentId,Category:syncOptions.Category,Quality:syncOptions.Quality,Bitrate:syncOptions.Bitrate};return syncOptions.items&&syncOptions.items.length&&(options.ItemIds=(syncOptions.items||[]).map(function(i){return i.Id||i}).join(",")),apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/Jobs"),data:JSON.stringify(options),contentType:"application/json",dataType:"json"}).then(function(){require(["toast"],function(toast){var msg=targetId===apiClient.deviceId()?globalize.translate("sharedcomponents#DownloadScheduled"):globalize.translate("sharedcomponents#SyncJobCreated");toast(msg)})})}function setJobValues(job,form){var txtBitrate=form.querySelector("#txtBitrate"),bitrate=txtBitrate?txtBitrate.value:null;bitrate&&(bitrate=1e6*parseFloat(bitrate)),job.Bitrate=bitrate;var txtSyncJobName=form.querySelector("#txtSyncJobName");txtSyncJobName&&(job.Name=txtSyncJobName.value);var selectQuality=form.querySelector("#selectQuality");selectQuality&&(job.Quality=selectQuality.value,appSettings.set("sync-lastquality",job.Quality||""));var selectProfile=form.querySelector("#selectProfile");selectProfile&&(job.Profile=selectProfile.value);var txtItemLimit=form.querySelector("#txtItemLimit");txtItemLimit&&(job.ItemLimit=txtItemLimit.value||null);var chkSyncNewContent=form.querySelector("#chkSyncNewContent");chkSyncNewContent&&(job.SyncNewContent=chkSyncNewContent.checked);var chkUnwatchedOnly=form.querySelector("#chkUnwatchedOnly");chkUnwatchedOnly&&(job.UnwatchedOnly=chkUnwatchedOnly.checked)}function renderForm(options){return new Promise(function(resolve,reject){require(["emby-checkbox","emby-input","emby-select"],function(){appHost.appInfo().then(function(appInfo){renderFormInternal(options,appInfo,resolve)})})})}function onHelpLinkClick(e){return shell.openUrl(this.href),e.preventDefault(),!1}function renderFormInternal(options,appInfo,resolve){var elem=options.elem,dialogOptions=options.dialogOptions,targets=dialogOptions.Targets,html="",targetContainerClass=options.isLocalSync?" hide":"";(options.showName||dialogOptions.Options.indexOf("Name")!==-1)&&(html+='
',html+='',html+="
"),options.readOnlySyncTarget?(html+='
',html+='',html+="
"):(html+='
',html+='",targets.length||(html+='
'+globalize.translate("sharedcomponents#LabelSyncNoTargetsHelp")+"
",html+='"),html+="
"),html+='
',html+='",html+='
',html+="
",html+='
',html+='",html+='
',html+="
",html+='
',html+='',html+="
",dialogOptions.Options.indexOf("UnwatchedOnly")!==-1&&(html+='
',html+="",html+='
'+globalize.translate("sharedcomponents#SyncUnwatchedVideosOnlyHelp")+"
",html+="
"),dialogOptions.Options.indexOf("SyncNewContent")!==-1&&(html+='
',html+="",html+='
'+globalize.translate("sharedcomponents#AutomaticallySyncNewContentHelp")+"
",html+="
"),dialogOptions.Options.indexOf("ItemLimit")!==-1&&(html+='
',html+='',html+='
'+globalize.translate("sharedcomponents#LabelItemLimitHelp")+"
",html+="
"),elem.innerHTML=html;var selectSyncTarget=elem.querySelector("#selectSyncTarget");selectSyncTarget&&(selectSyncTarget.addEventListener("change",function(){loadQualityOptions(elem,this.value,options.dialogOptionsFn).then(resolve)}),selectSyncTarget.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectProfile=elem.querySelector("#selectProfile");selectProfile&&(selectProfile.addEventListener("change",function(){onProfileChange(elem,this.value)}),selectProfile.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectQuality=elem.querySelector("#selectQuality");selectQuality&&(selectQuality.addEventListener("change",function(){onQualityChange(elem,this.value)}),selectQuality.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var lnkLearnMore=elem.querySelector(".lnkLearnMore");lnkLearnMore&&lnkLearnMore.addEventListener("click",onHelpLinkClick),setTimeout(function(){focusManager.autoFocus(elem)},100)}function showSyncMenu(options){return registrationServices.validateFeature("sync").then(function(){return showSyncMenuInternal(options)})}function enableAutoSync(options){if(!options.isLocalSync)return!1;var firstItem=(options.items||[])[0]||{};return"Audio"===firstItem.Type||("MusicAlbum"===firstItem.Type||("MusicArtist"===firstItem.Type||("MusicGenre"===firstItem.Type||"Playlist"===firstItem.Type&&"Audio"===firstItem.MediaType)))}function showSyncMenuInternal(options){var apiClient=connectionManager.getApiClient(options.serverId),userId=apiClient.getCurrentUserId();if(enableAutoSync(options))return submitQuickSyncJob(apiClient,userId,apiClient.deviceId(),{items:options.items,Quality:"custom",Bitrate:appSettings.maxStaticMusicBitrate()});var dialogOptionsQuery={UserId:userId,ItemIds:(options.items||[]).map(function(i){return i.Id||i}).join(","),ParentId:options.ParentId,Category:options.Category};return apiClient.getJSON(apiClient.getUrl("Sync/Options",dialogOptionsQuery)).then(function(dialogOptions){currentDialogOptions=dialogOptions;var dlgElementOptions={removeOnClose:!0,scrollY:!1,autoFocus:!1};layoutManager.tv?dlgElementOptions.size="fullscreen":dlgElementOptions.size="small";var dlg=dialogHelper.createDialog(dlgElementOptions);dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=globalize.translate("sharedcomponents#Sync"),html+="

",html+='",html+="
",html+='
',html+='
',html+='
',html+='
',html+='
',html+='",html+="
",html+="
",html+="
",html+="
",dlg.innerHTML=html,dlg.querySelector(".lnkHelp").addEventListener("click",onHelpLinkClick);var submitted=!1;dlg.querySelector("form").addEventListener("submit",function(e){return submitted=submitJob(dlg,apiClient,userId,options,this),e.preventDefault(),!1}),dlg.querySelector(".btnCancel").addEventListener("click",function(){dialogHelper.close(dlg)}),layoutManager.tv&&scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"),!1);var promise=dialogHelper.open(dlg);return renderForm({elem:dlg.querySelector(".formFields"),dialogOptions:dialogOptions,dialogOptionsFn:getTargetDialogOptionsFn(apiClient,dialogOptionsQuery),isLocalSync:options.isLocalSync}),promise.then(function(){return layoutManager.tv&&scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"),!1),submitted?Promise.resolve():Promise.reject()})})}function getTargetDialogOptionsFn(apiClient,query){return function(targetId){return query.TargetId=targetId,apiClient.getJSON(apiClient.getUrl("Sync/Options",query))}}function setQualityFieldVisible(form,visible){var fldQuality=form.querySelector(".fldQuality"),selectQuality=form.querySelector("#selectQuality");visible?(fldQuality&&fldQuality.classList.remove("hide"),selectQuality&&selectQuality.removeAttribute("required")):(fldQuality&&fldQuality.classList.add("hide"),selectQuality&&selectQuality.removeAttribute("required"))}function onProfileChange(form,profileId){var options=currentDialogOptions||{},option=(options.ProfileOptions||[]).filter(function(o){return o.Id===profileId})[0],qualityOptions=options.QualityOptions||[];option?(form.querySelector(".profileDescription").innerHTML=option.Description||"",setQualityFieldVisible(form,qualityOptions.length>0&&option.EnableQualityOptions&&options.Options.indexOf("Quality")!==-1)):(form.querySelector(".profileDescription").innerHTML="",setQualityFieldVisible(form,qualityOptions.length>0&&options.Options.indexOf("Quality")!==-1))}function onQualityChange(form,qualityId){var options=currentDialogOptions||{},option=(options.QualityOptions||[]).filter(function(o){return o.Id===qualityId})[0],qualityDescription=form.querySelector(".qualityDescription");option?qualityDescription.innerHTML=option.Description||"":qualityDescription.innerHTML="";var fldBitrate=form.querySelector(".fldBitrate"),txtBitrate=form.querySelector("#txtBitrate");"custom"===qualityId?(fldBitrate&&fldBitrate.classList.remove("hide"),txtBitrate&&txtBitrate.setAttribute("required","required")):(fldBitrate&&fldBitrate.classList.add("hide"),txtBitrate&&txtBitrate.removeAttribute("required"))}function renderTargetDialogOptions(form,options){currentDialogOptions=options;var fldProfile=form.querySelector(".fldProfile"),selectProfile=form.querySelector("#selectProfile");options.ProfileOptions.length&&options.Options.indexOf("Profile")!==-1?(fldProfile&&fldProfile.classList.remove("hide"),selectProfile&&selectProfile.setAttribute("required","required")):(fldProfile&&fldProfile.classList.add("hide"),selectProfile&&selectProfile.removeAttribute("required")),setQualityFieldVisible(form,options.QualityOptions.length>0),selectProfile&&(selectProfile.innerHTML=options.ProfileOptions.map(function(o){var selectedAttribute=o.IsDefault?' selected="selected"':"";return'"}).join(""),selectProfile.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectQuality=form.querySelector("#selectQuality");if(selectQuality){selectQuality.innerHTML=options.QualityOptions.map(function(o){var selectedAttribute=o.IsDefault?' selected="selected"':"";return'"}).join("");var lastQuality=appSettings.get("sync-lastquality");lastQuality&&options.QualityOptions.filter(function(i){return i.Id===lastQuality}).length&&(selectQuality.value=lastQuality),selectQuality.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}}function loadQualityOptions(form,targetId,dialogOptionsFn){return dialogOptionsFn(targetId).then(function(options){return renderTargetDialogOptions(form,options)})}var currentDialogOptions;return{showMenu:showSyncMenu,renderForm:renderForm,setJobValues:setJobValues}}); \ No newline at end of file +define(["apphost","globalize","connectionManager","layoutManager","shell","focusManager","scrollHelper","appSettings","registrationServices","dialogHelper","paper-icon-button-light","formDialogStyle"],function(appHost,globalize,connectionManager,layoutManager,shell,focusManager,scrollHelper,appSettings,registrationServices,dialogHelper){"use strict";function submitJob(dlg,apiClient,userId,syncOptions,form){if(!userId)throw new Error("userId cannot be null");if(!syncOptions)throw new Error("syncOptions cannot be null");if(!form)throw new Error("form cannot be null");var selectSyncTarget=form.querySelector("#selectSyncTarget"),target=selectSyncTarget?selectSyncTarget.value:null;if(!target)return require(["toast"],function(toast){toast(globalize.translate("sharedcomponents#PleaseSelectDeviceToSyncTo"))}),!1;var options={userId:userId,TargetId:target,ParentId:syncOptions.ParentId,Category:syncOptions.Category};return setJobValues(options,form),syncOptions.items&&syncOptions.items.length&&(options.ItemIds=(syncOptions.items||[]).map(function(i){return i.Id||i}).join(",")),apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/Jobs"),data:JSON.stringify(options),contentType:"application/json",dataType:"json"}).then(function(){dialogHelper.close(dlg),require(["toast"],function(toast){var msg=target===apiClient.deviceId()?globalize.translate("sharedcomponents#DownloadScheduled"):globalize.translate("sharedcomponents#SyncJobCreated");toast(msg)})}),!0}function submitQuickSyncJob(apiClient,userId,targetId,syncOptions){if(!userId)throw new Error("userId cannot be null");if(!syncOptions)throw new Error("syncOptions cannot be null");if(!targetId)throw new Error("targetId cannot be null");var options={userId:userId,TargetId:targetId,ParentId:syncOptions.ParentId,Category:syncOptions.Category,Quality:syncOptions.Quality,Bitrate:syncOptions.Bitrate};return syncOptions.items&&syncOptions.items.length&&(options.ItemIds=(syncOptions.items||[]).map(function(i){return i.Id||i}).join(",")),apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/Jobs"),data:JSON.stringify(options),contentType:"application/json",dataType:"json"}).then(function(){require(["toast"],function(toast){var msg=targetId===apiClient.deviceId()?globalize.translate("sharedcomponents#DownloadScheduled"):globalize.translate("sharedcomponents#SyncJobCreated");toast(msg)})})}function setJobValues(job,form){var txtBitrate=form.querySelector("#txtBitrate"),bitrate=txtBitrate?txtBitrate.value:null;bitrate&&(bitrate=1e6*parseFloat(bitrate)),job.Bitrate=bitrate;var selectQuality=form.querySelector("#selectQuality");selectQuality&&(job.Quality=selectQuality.value,appSettings.set("sync-lastquality",job.Quality||""));var selectProfile=form.querySelector("#selectProfile");selectProfile&&(job.Profile=selectProfile.value);var txtItemLimit=form.querySelector("#txtItemLimit");txtItemLimit&&(job.ItemLimit=txtItemLimit.value||null);var chkSyncNewContent=form.querySelector("#chkSyncNewContent");chkSyncNewContent&&(job.SyncNewContent=chkSyncNewContent.checked);var chkUnwatchedOnly=form.querySelector("#chkUnwatchedOnly");chkUnwatchedOnly&&(job.UnwatchedOnly=chkUnwatchedOnly.checked)}function renderForm(options){return new Promise(function(resolve,reject){require(["emby-checkbox","emby-input","emby-select"],function(){appHost.appInfo().then(function(appInfo){renderFormInternal(options,appInfo,resolve)})})})}function onHelpLinkClick(e){return shell.openUrl(this.href),e.preventDefault(),!1}function renderFormInternal(options,appInfo,resolve){var elem=options.elem,dialogOptions=options.dialogOptions,targets=dialogOptions.Targets,html="",targetContainerClass=options.isLocalSync?" hide":"";(options.showName||dialogOptions.Options.indexOf("Name")!==-1)&&(html+='

'),options.readOnlySyncTarget?(html+='
',html+='',html+="
"):(html+='
',html+='",targets.length||(html+='
'+globalize.translate("sharedcomponents#LabelSyncNoTargetsHelp")+"
",html+='"),html+="
"),html+='
',html+='",html+='
',html+="
",html+='
',html+='",html+='
',html+="
",html+='
',html+='',html+="
",dialogOptions.Options.indexOf("UnwatchedOnly")!==-1&&(html+='
',html+="",html+='
'+globalize.translate("sharedcomponents#SyncUnwatchedVideosOnlyHelp")+"
",html+="
"),dialogOptions.Options.indexOf("SyncNewContent")!==-1&&(html+='
',html+="",html+='
'+globalize.translate("sharedcomponents#AutomaticallySyncNewContentHelp")+"
",html+="
"),dialogOptions.Options.indexOf("ItemLimit")!==-1&&(html+='
',html+='',html+='
'+globalize.translate("sharedcomponents#LabelItemLimitHelp")+"
",html+="
"),elem.innerHTML=html;var selectSyncTarget=elem.querySelector("#selectSyncTarget");selectSyncTarget&&(selectSyncTarget.addEventListener("change",function(){loadQualityOptions(elem,this.value,options.dialogOptionsFn).then(resolve)}),selectSyncTarget.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectProfile=elem.querySelector("#selectProfile");selectProfile&&(selectProfile.addEventListener("change",function(){onProfileChange(elem,this.value)}),selectProfile.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectQuality=elem.querySelector("#selectQuality");selectQuality&&(selectQuality.addEventListener("change",function(){onQualityChange(elem,this.value)}),selectQuality.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var lnkLearnMore=elem.querySelector(".lnkLearnMore");lnkLearnMore&&lnkLearnMore.addEventListener("click",onHelpLinkClick),setTimeout(function(){focusManager.autoFocus(elem)},100)}function showSyncMenu(options){return registrationServices.validateFeature("sync").then(function(){return showSyncMenuInternal(options)})}function enableAutoSync(options){if(!options.isLocalSync)return!1;var firstItem=(options.items||[])[0]||{};return"Audio"===firstItem.Type||("MusicAlbum"===firstItem.Type||("MusicArtist"===firstItem.Type||("MusicGenre"===firstItem.Type||"Playlist"===firstItem.Type&&"Audio"===firstItem.MediaType)))}function showSyncMenuInternal(options){var apiClient=connectionManager.getApiClient(options.serverId),userId=apiClient.getCurrentUserId();if(enableAutoSync(options))return submitQuickSyncJob(apiClient,userId,apiClient.deviceId(),{items:options.items,Quality:"custom",Bitrate:appSettings.maxStaticMusicBitrate()});var dialogOptionsQuery={UserId:userId,ItemIds:(options.items||[]).map(function(i){return i.Id||i}).join(","),ParentId:options.ParentId,Category:options.Category};return apiClient.getJSON(apiClient.getUrl("Sync/Options",dialogOptionsQuery)).then(function(dialogOptions){currentDialogOptions=dialogOptions;var dlgElementOptions={removeOnClose:!0,scrollY:!1,autoFocus:!1};layoutManager.tv?dlgElementOptions.size="fullscreen":dlgElementOptions.size="small";var dlg=dialogHelper.createDialog(dlgElementOptions);dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=globalize.translate("sharedcomponents#Sync"),html+="

",html+='",html+="
",html+='
',html+='
',html+='
',html+='
',html+='
',html+='",html+="
",html+="
",html+="
",html+="
",dlg.innerHTML=html,dlg.querySelector(".lnkHelp").addEventListener("click",onHelpLinkClick);var submitted=!1;dlg.querySelector("form").addEventListener("submit",function(e){return submitted=submitJob(dlg,apiClient,userId,options,this),e.preventDefault(),!1}),dlg.querySelector(".btnCancel").addEventListener("click",function(){dialogHelper.close(dlg)}),layoutManager.tv&&scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"),!1);var promise=dialogHelper.open(dlg);return renderForm({elem:dlg.querySelector(".formFields"),dialogOptions:dialogOptions,dialogOptionsFn:getTargetDialogOptionsFn(apiClient,dialogOptionsQuery),isLocalSync:options.isLocalSync}),promise.then(function(){return layoutManager.tv&&scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"),!1),submitted?Promise.resolve():Promise.reject()})})}function getTargetDialogOptionsFn(apiClient,query){return function(targetId){return query.TargetId=targetId,apiClient.getJSON(apiClient.getUrl("Sync/Options",query))}}function setQualityFieldVisible(form,visible){var fldQuality=form.querySelector(".fldQuality"),selectQuality=form.querySelector("#selectQuality");visible?(fldQuality&&fldQuality.classList.remove("hide"),selectQuality&&selectQuality.removeAttribute("required")):(fldQuality&&fldQuality.classList.add("hide"),selectQuality&&selectQuality.removeAttribute("required"))}function onProfileChange(form,profileId){var options=currentDialogOptions||{},option=(options.ProfileOptions||[]).filter(function(o){return o.Id===profileId})[0],qualityOptions=options.QualityOptions||[];option?(form.querySelector(".profileDescription").innerHTML=option.Description||"",setQualityFieldVisible(form,qualityOptions.length>0&&option.EnableQualityOptions&&options.Options.indexOf("Quality")!==-1)):(form.querySelector(".profileDescription").innerHTML="",setQualityFieldVisible(form,qualityOptions.length>0&&options.Options.indexOf("Quality")!==-1))}function onQualityChange(form,qualityId){var options=currentDialogOptions||{},option=(options.QualityOptions||[]).filter(function(o){return o.Id===qualityId})[0],qualityDescription=form.querySelector(".qualityDescription");option?qualityDescription.innerHTML=option.Description||"":qualityDescription.innerHTML="";var fldBitrate=form.querySelector(".fldBitrate"),txtBitrate=form.querySelector("#txtBitrate");"custom"===qualityId?(fldBitrate&&fldBitrate.classList.remove("hide"),txtBitrate&&txtBitrate.setAttribute("required","required")):(fldBitrate&&fldBitrate.classList.add("hide"),txtBitrate&&txtBitrate.removeAttribute("required"))}function renderTargetDialogOptions(form,options){currentDialogOptions=options;var fldProfile=form.querySelector(".fldProfile"),selectProfile=form.querySelector("#selectProfile");options.ProfileOptions.length&&options.Options.indexOf("Profile")!==-1?(fldProfile&&fldProfile.classList.remove("hide"),selectProfile&&selectProfile.setAttribute("required","required")):(fldProfile&&fldProfile.classList.add("hide"),selectProfile&&selectProfile.removeAttribute("required")),setQualityFieldVisible(form,options.QualityOptions.length>0),selectProfile&&(selectProfile.innerHTML=options.ProfileOptions.map(function(o){var selectedAttribute=o.IsDefault?' selected="selected"':"";return'"}).join(""),selectProfile.dispatchEvent(new CustomEvent("change",{bubbles:!0})));var selectQuality=form.querySelector("#selectQuality");if(selectQuality){selectQuality.innerHTML=options.QualityOptions.map(function(o){var selectedAttribute=o.IsDefault?' selected="selected"':"";return'"}).join("");var lastQuality=appSettings.get("sync-lastquality");lastQuality&&options.QualityOptions.filter(function(i){return i.Id===lastQuality}).length&&(selectQuality.value=lastQuality),selectQuality.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}}function loadQualityOptions(form,targetId,dialogOptionsFn){return dialogOptionsFn(targetId).then(function(options){return renderTargetDialogOptions(form,options)})}var currentDialogOptions;return{showMenu:showSyncMenu,renderForm:renderForm,setJobValues:setJobValues}}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/sync/syncjobeditor.js b/dashboard-ui/bower_components/emby-webcomponents/sync/syncjobeditor.js index 0b23975a4b..832df27888 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/sync/syncjobeditor.js +++ b/dashboard-ui/bower_components/emby-webcomponents/sync/syncjobeditor.js @@ -1 +1 @@ -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="";html+='
';var imgUrl,hasActions=["Queued","Cancelled","Failed","ReadyToTransfer","Transferring","Converting","Synced"].indexOf(jobItem.Status)!==-1;jobItem.PrimaryImageItemId&&(imgUrl=apiClient.getImageUrl(jobItem.PrimaryImageItemId,{type:"Primary",width:80,tag:jobItem.PrimaryImageTag,minScale:1.5})),html+=imgUrl?'':'',html+='
',html+='

',html+=jobItem.ItemName,html+="

",html+="Failed"===jobItem.Status?'
':'
',html+=globalize.translate("sharedcomponents#SyncJobItemStatus"+jobItem.Status),"Synced"===jobItem.Status&&jobItem.IsMarkedForRemoval&&(html+="
",html+=globalize.translate("sharedcomponents#RemovingFromDevice")),html+="
",html+='
',html+='
',html+="
",html+="
";var moreIcon="dots-horiz"===appHost.moreIcon?"":"";return html+=hasActions?'":'",html+="
"}function renderJobItems(context,items,apiClient){var html="";html+="

"+globalize.translate("sharedcomponents#Items")+"

",html+='
';var index=0;html+=items.map(function(i){return getJobItemHtml(i,apiClient,index++)}).join(""),html+="
";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,"page"),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"}):"Synced"===status&&remove?menuItems.push({name:globalize.translate("sharedcomponents#KeepOnDevice"),id:"unmarkforremoval"}):"Synced"===status&&menuItems.push({name:globalize.translate("sharedcomponents#RemoveFromDevice"),id:"markforremoval"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"cancel":cancelJobItem(context,jobId,jobItemId,apiClient);break;case"retry":retryJobItem(context,jobId,jobItemId,apiClient);break;case"markforremoval":markForRemoval(context,jobId,jobItemId,apiClient);break;case"unmarkforremoval":unMarkForRemoval(context,jobId,jobItemId,apiClient)}}})})}function cancelJobItem(context,jobId,jobItemId,apiClient){loading.show(),apiClient.ajax({type:"DELETE",url:apiClient.getUrl("Sync/JobItems/"+jobItemId)}).then(function(){loadJob(context,jobId,apiClient)})}function markForRemoval(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/MarkForRemoval")}).then(function(){loadJob(context,jobId,apiClient)})}function unMarkForRemoval(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/UnmarkForRemoval")}).then(function(){loadJob(context,jobId,apiClient)})}function retryJobItem(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/Enable")}).then(function(){loadJob(context,jobId,apiClient)})}function fillJobValues(context,job,editOptions){var txtSyncJobName=context.querySelector("#txtSyncJobName");txtSyncJobName&&(txtSyncJobName.value=job.Name);var selectProfile=context.querySelector("#selectProfile");selectProfile&&(selectProfile.value=job.Profile||"");var selectQuality=context.querySelector("#selectQuality");selectQuality&&(selectQuality.value=job.Quality||"");var chkUnwatchedOnly=context.querySelector("#chkUnwatchedOnly");chkUnwatchedOnly&&(chkUnwatchedOnly.checked=job.UnwatchedOnly);var chkSyncNewContent=context.querySelector("#chkSyncNewContent");chkSyncNewContent&&(chkSyncNewContent.checked=job.SyncNewContent);var txtItemLimit=context.querySelector("#txtItemLimit");txtItemLimit&&(txtItemLimit.value=job.ItemLimit);var txtBitrate=context.querySelector("#txtBitrate");job.Bitrate?txtBitrate.value=job.Bitrate/1e6:txtBitrate.value="";var target=editOptions.Targets.filter(function(t){return t.Id===job.TargetId})[0],targetName=target?target.Name:"",selectSyncTarget=context.querySelector("#selectSyncTarget");selectSyncTarget&&(selectSyncTarget.value=targetName)}function loadJob(context,id,apiClient){loading.show(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs/"+id)).then(function(job){apiClient.getJSON(apiClient.getUrl("Sync/Options",{UserId:job.UserId,ItemIds:job.RequestedItemIds&&job.RequestedItemIds.length?job.RequestedItemIds.join(""):null,ParentId:job.ParentId,Category:job.Category,TargetId:job.TargetId})).then(function(options){_jobOptions=options,renderJob(context,job,options),loading.hide()})}),apiClient.getJSON(apiClient.getUrl("Sync/JobItems",{JobId:id,AddMetadata:!0})).then(function(result){renderJobItems(context,result.Items,apiClient),loading.hide()})}function loadJobInfo(context,job,jobItems,apiClient){renderJobItems(context,jobItems,apiClient),loading.hide()}function saveJob(context,id,apiClient){loading.show(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs/"+id)).then(function(job){require(["syncDialog"],function(syncDialog){syncDialog.setJobValues(job,context),apiClient.ajax({url:apiClient.getUrl("Sync/Jobs/"+id),type:"POST",data:JSON.stringify(job),contentType:"application/json"}).then(function(){loading.hide(),dialogHelper.close(context)})})})}function onHelpLinkClick(e){return shell.openUrl(this.href),e.preventDefault(),!1}function startListening(apiClient,jobId){var startParams="0,1500";startParams+=","+jobId,apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobStart",startParams)}function stopListening(apiClient){apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobStop","")}function bindEvents(context,jobId,apiClient){context.querySelector(".jobItems").addEventListener("click",function(e){var btnJobItemMenu=dom.parentWithClass(e.target,"btnJobItemMenu");btnJobItemMenu&&showJobItemMenu(btnJobItemMenu,jobId,apiClient)})}function showEditor(options){function onSyncJobMessage(e,apiClient,msg){loadJobInfo(dlg,msg.Job,msg.JobItems,apiClient)}var apiClient=connectionManager.getApiClient(options.serverId),id=options.jobId,dlgElementOptions={removeOnClose:!0,scrollY:!1,autoFocus:!1};layoutManager.tv?dlgElementOptions.size="fullscreen":dlgElementOptions.size="medium";var dlg=dialogHelper.createDialog(dlgElementOptions);dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=globalize.translate("sharedcomponents#Sync"),html+="

",html+='",html+="
",html+='
',html+='
',html+='
',html+='
',html+='
',html+='
',html+='",html+="
",html+="
",html+="
",html+="
",dlg.innerHTML=html,dlg.querySelector(".lnkHelp").addEventListener("click",onHelpLinkClick);var submitted=!1;dlg.querySelector("form").addEventListener("submit",function(e){return saveJob(dlg,id,apiClient),e.preventDefault(),!1}),dlg.querySelector(".btnCancel").addEventListener("click",function(){dialogHelper.close(dlg)}),layoutManager.tv&&scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"),!1),loadJob(dlg,id,apiClient),bindEvents(dlg,id,apiClient);var promise=dialogHelper.open(dlg);return startListening(apiClient,id),events.on(serverNotifications,"SyncJob",onSyncJobMessage),promise.then(function(){return stopListening(apiClient),events.off(serverNotifications,"SyncJob",onSyncJobMessage),layoutManager.tv&&scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"),!1),submitted?Promise.resolve():Promise.reject()})}var _jobOptions;return{show:showEditor}}); \ No newline at end of file +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="";html+='
';var imgUrl,hasActions=["Queued","Cancelled","Failed","ReadyToTransfer","Transferring","Converting","Synced"].indexOf(jobItem.Status)!==-1;jobItem.PrimaryImageItemId&&(imgUrl=apiClient.getImageUrl(jobItem.PrimaryImageItemId,{type:"Primary",width:80,tag:jobItem.PrimaryImageTag,minScale:1.5})),html+=imgUrl?'':'',html+='
',html+='

',html+=jobItem.ItemName,html+="

",html+="Failed"===jobItem.Status?'
':'
',html+=globalize.translate("sharedcomponents#SyncJobItemStatus"+jobItem.Status),"Synced"===jobItem.Status&&jobItem.IsMarkedForRemoval&&(html+="
",html+=globalize.translate("sharedcomponents#RemovingFromDevice")),html+="
",html+='
',html+='
',html+="
",html+="
";var moreIcon="dots-horiz"===appHost.moreIcon?"":"";return html+=hasActions?'":'",html+="
"}function renderJobItems(context,items,apiClient){var html="";html+="

"+globalize.translate("sharedcomponents#Items")+"

",html+='
';var index=0;html+=items.map(function(i){return getJobItemHtml(i,apiClient,index++)}).join(""),html+="
";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,"page"),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"}):"Synced"===status&&remove?menuItems.push({name:globalize.translate("sharedcomponents#KeepOnDevice"),id:"unmarkforremoval"}):"Synced"===status&&menuItems.push({name:globalize.translate("sharedcomponents#RemoveFromDevice"),id:"markforremoval"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"cancel":cancelJobItem(context,jobId,jobItemId,apiClient);break;case"retry":retryJobItem(context,jobId,jobItemId,apiClient);break;case"markforremoval":markForRemoval(context,jobId,jobItemId,apiClient);break;case"unmarkforremoval":unMarkForRemoval(context,jobId,jobItemId,apiClient)}}})})}function cancelJobItem(context,jobId,jobItemId,apiClient){loading.show(),apiClient.ajax({type:"DELETE",url:apiClient.getUrl("Sync/JobItems/"+jobItemId)}).then(function(){loadJob(context,jobId,apiClient)})}function markForRemoval(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/MarkForRemoval")}).then(function(){loadJob(context,jobId,apiClient)})}function unMarkForRemoval(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/UnmarkForRemoval")}).then(function(){loadJob(context,jobId,apiClient)})}function retryJobItem(context,jobId,jobItemId,apiClient){apiClient.ajax({type:"POST",url:apiClient.getUrl("Sync/JobItems/"+jobItemId+"/Enable")}).then(function(){loadJob(context,jobId,apiClient)})}function fillJobValues(context,job,editOptions){var txtSyncJobName=context.querySelector(".syncJobName");txtSyncJobName&&(txtSyncJobName.innerHTML=job.Name);var selectProfile=context.querySelector("#selectProfile");selectProfile&&(selectProfile.value=job.Profile||"");var selectQuality=context.querySelector("#selectQuality");selectQuality&&(selectQuality.value=job.Quality||"");var chkUnwatchedOnly=context.querySelector("#chkUnwatchedOnly");chkUnwatchedOnly&&(chkUnwatchedOnly.checked=job.UnwatchedOnly);var chkSyncNewContent=context.querySelector("#chkSyncNewContent");chkSyncNewContent&&(chkSyncNewContent.checked=job.SyncNewContent);var txtItemLimit=context.querySelector("#txtItemLimit");txtItemLimit&&(txtItemLimit.value=job.ItemLimit);var txtBitrate=context.querySelector("#txtBitrate");job.Bitrate?txtBitrate.value=job.Bitrate/1e6:txtBitrate.value="";var target=editOptions.Targets.filter(function(t){return t.Id===job.TargetId})[0],targetName=target?target.Name:"",selectSyncTarget=context.querySelector("#selectSyncTarget");selectSyncTarget&&(selectSyncTarget.value=targetName)}function loadJob(context,id,apiClient){loading.show(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs/"+id)).then(function(job){apiClient.getJSON(apiClient.getUrl("Sync/Options",{UserId:job.UserId,ItemIds:job.RequestedItemIds&&job.RequestedItemIds.length?job.RequestedItemIds.join(""):null,ParentId:job.ParentId,Category:job.Category,TargetId:job.TargetId})).then(function(options){_jobOptions=options,renderJob(context,job,options),loading.hide()})}),apiClient.getJSON(apiClient.getUrl("Sync/JobItems",{JobId:id,AddMetadata:!0})).then(function(result){renderJobItems(context,result.Items,apiClient),loading.hide()})}function loadJobInfo(context,job,jobItems,apiClient){renderJobItems(context,jobItems,apiClient),loading.hide()}function saveJob(context,id,apiClient){loading.show(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs/"+id)).then(function(job){require(["syncDialog"],function(syncDialog){syncDialog.setJobValues(job,context),apiClient.ajax({url:apiClient.getUrl("Sync/Jobs/"+id),type:"POST",data:JSON.stringify(job),contentType:"application/json"}).then(function(){loading.hide(),dialogHelper.close(context)})})})}function onHelpLinkClick(e){return shell.openUrl(this.href),e.preventDefault(),!1}function startListening(apiClient,jobId){var startParams="0,1500";startParams+=","+jobId,apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobStart",startParams)}function stopListening(apiClient){apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobStop","")}function bindEvents(context,jobId,apiClient){context.querySelector(".jobItems").addEventListener("click",function(e){var btnJobItemMenu=dom.parentWithClass(e.target,"btnJobItemMenu");btnJobItemMenu&&showJobItemMenu(btnJobItemMenu,jobId,apiClient)})}function showEditor(options){function onSyncJobMessage(e,apiClient,msg){loadJobInfo(dlg,msg.Job,msg.JobItems,apiClient)}var apiClient=connectionManager.getApiClient(options.serverId),id=options.jobId,dlgElementOptions={removeOnClose:!0,scrollY:!1,autoFocus:!1};layoutManager.tv?dlgElementOptions.size="fullscreen":dlgElementOptions.size="medium";var dlg=dialogHelper.createDialog(dlgElementOptions);dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=globalize.translate("sharedcomponents#Sync"),html+="

",html+='",html+="
",html+='
',html+='
',html+='
',html+='
',html+='
',html+='
',html+='",html+="
",html+="
",html+="
",html+="
",dlg.innerHTML=html,dlg.querySelector(".lnkHelp").addEventListener("click",onHelpLinkClick);var submitted=!1;dlg.querySelector("form").addEventListener("submit",function(e){return saveJob(dlg,id,apiClient),e.preventDefault(),!1}),dlg.querySelector(".btnCancel").addEventListener("click",function(){dialogHelper.close(dlg)}),layoutManager.tv&&scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"),!1),loadJob(dlg,id,apiClient),bindEvents(dlg,id,apiClient);var promise=dialogHelper.open(dlg);return startListening(apiClient,id),events.on(serverNotifications,"SyncJob",onSyncJobMessage),promise.then(function(){return stopListening(apiClient),events.off(serverNotifications,"SyncJob",onSyncJobMessage),layoutManager.tv&&scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"),!1),submitted?Promise.resolve():Promise.reject()})}var _jobOptions;return{show:showEditor}}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/sync/syncjoblist.js b/dashboard-ui/bower_components/emby-webcomponents/sync/syncjoblist.js index 6fef8b5521..e4dc4d72ee 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/sync/syncjoblist.js +++ b/dashboard-ui/bower_components/emby-webcomponents/sync/syncjoblist.js @@ -1 +1 @@ -define(["serverNotifications","events","loading","connectionManager","imageLoader","dom","globalize","registrationServices","layoutManager","listViewStyle"],function(serverNotifications,events,loading,connectionManager,imageLoader,dom,globalize,registrationServices,layoutManager){"use strict";function onSyncJobsUpdated(e,apiClient,data){var listInstance=this;renderList(listInstance,data,apiClient)}function refreshList(listInstance,jobs){for(var i=0,length=jobs.length;i0&&progress<100&&(progress=progress.toFixed(1)),html+=progress+"%"}return html}function getSyncJobHtml(listInstance,job,apiClient){var html="",tagName=layoutManager.tv?"button":"div",typeAttribute="button"===tagName?' type="button"':"",listItemClass="listItem";layoutManager.tv&&(listItemClass+=" listItem-button listItem-focusscale"),html+="<"+tagName+typeAttribute+' class="'+listItemClass+'" data-id="'+job.Id+'" data-status="'+job.Status+'">';var imgUrl;job.PrimaryImageItemId&&(imgUrl=apiClient.getImageUrl(job.PrimaryImageItemId,{type:"Primary",width:80,tag:job.PrimaryImageTag,minScale:1.5})),imgUrl?(html+='
',html+="
"):html+='file_download';var textLines=[];job.ParentName&&textLines.push(job.ParentName),textLines.push(job.Name),1===job.ItemCount?textLines.push(globalize.translate("sharedcomponents#ValueOneItem")):textLines.push(globalize.translate("sharedcomponents#ItemCount",job.ItemCount)),html+='
';for(var i=0,length=textLines.length;i',html+=textLines[i],html+=""):(html+='
',html+=textLines[i],html+="
");return html+='
',html+=getProgressText(job),html+="
",html+="
",layoutManager.tv||(html+=''),html+=""}function renderList(listInstance,jobs,apiClient){if((new Date).getTime()-listInstance.lastDataLoad<6e4)return void refreshList(listInstance,jobs);listInstance.lastDataLoad=(new Date).getTime();for(var html="",lastTargetName="",isLocalSync=listInstance.options.isLocalSync,showTargetName=!isLocalSync,hasOpenSection=!1,i=0,length=jobs.length;i",html+="
",hasOpenSection=!1),lastTargetName=targetName,html+='
',html+="

"+targetName+"

",html+="
",html+='
',hasOpenSection=!0)}html+=getSyncJobHtml(listInstance,job,apiClient)}hasOpenSection&&(html+="
");var elem=listInstance.options.element.querySelector(".syncJobListContent");html||(html=isLocalSync?'
'+globalize.translate("sharedcomponents#MessageNoDownloadsFound")+"
":'
'+globalize.translate("sharedcomponents#MessageNoSyncJobsFound")+"
"),elem.innerHTML=html,imageLoader.lazyChildren(elem)}function fetchData(listInstance){listInstance.lastDataLoad=0,loading.show();var options={},apiClient=getApiClient(listInstance);return listInstance.options.userId&&(options.UserId=listInstance.options.userId),listInstance.options.isLocalSync?options.TargetId=apiClient.deviceId():options.ExcludeTargetIds=apiClient.deviceId(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs",options)).then(function(response){renderList(listInstance,response.Items,apiClient),loading.hide()})}function startListening(listInstance){var startParams="0,1500",apiClient=getApiClient(listInstance);listInstance.options.userId&&(startParams+=","+listInstance.options.userId),listInstance.options.isLocalSync&&(startParams+=","+apiClient.deviceId()),apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobsStart",startParams)}function stopListening(listInstance){var apiClient=getApiClient(listInstance);apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobsStop","")}function getApiClient(listInstance){return connectionManager.getApiClient(listInstance.options.serverId)}function showJobMenu(listInstance,elem){var item=dom.parentWithClass(elem,"listItem"),jobId=item.getAttribute("data-id"),status=item.getAttribute("data-status"),menuItems=[];if("Cancelled"===status)menuItems.push({name:globalize.translate("sharedcomponents#Delete"),id:"delete"});else{var txt=listInstance.options.isLocalSync?globalize.translate("sharedcomponents#RemoveDownload"):globalize.translate("sharedcomponents#ButtonCancelSyncJob");menuItems.push({name:txt,id:"cancel"})}require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"delete":cancelJob(listInstance,jobId);break;case"cancel":cancelJob(listInstance,jobId)}}})})}function onElementClick(e){var listInstance=this,btnJobMenu=dom.parentWithClass(e.target,"btnJobMenu");if(btnJobMenu)return void showJobMenu(this,btnJobMenu);var listItem=dom.parentWithClass(e.target,"listItem");if(listItem){var jobId=listItem.getAttribute("data-id");require(["syncJobEditor"],function(syncJobEditor){syncJobEditor.show({serverId:listInstance.options.serverId,jobId:jobId}).then(function(){fetchData(listInstance)})})}}function syncJobList(options){this.options=options;var onSyncJobsUpdatedHandler=onSyncJobsUpdated.bind(this);this.onSyncJobsUpdatedHandler=onSyncJobsUpdatedHandler,events.on(serverNotifications,"SyncJobs",onSyncJobsUpdatedHandler);var onClickHandler=onElementClick.bind(this);options.element.addEventListener("click",onClickHandler),this.onClickHandler=onClickHandler,options.element.innerHTML='
',fetchData(this),startListening(this),initSupporterInfo(options.element,getApiClient(this))}function showSupporterInfo(context){var html=''),html+=""}function renderList(listInstance,jobs,apiClient){if((new Date).getTime()-listInstance.lastDataLoad<6e4)return void refreshList(listInstance,jobs);listInstance.lastDataLoad=(new Date).getTime();for(var html="",lastTargetName="",isLocalSync=listInstance.options.isLocalSync,showTargetName=!isLocalSync,hasOpenSection=!1,i=0,length=jobs.length;i",html+="
",hasOpenSection=!1),lastTargetName=targetName,html+='
',html+="

"+targetName+"

",html+="
",html+='
',hasOpenSection=!0)}html+=getSyncJobHtml(listInstance,job,apiClient)}hasOpenSection&&(html+="
");var elem=listInstance.options.element.querySelector(".syncJobListContent");html||(html=isLocalSync?'
'+globalize.translate("sharedcomponents#MessageNoDownloadsFound")+"
":'
'+globalize.translate("sharedcomponents#MessageNoSyncJobsFound")+"
"),elem.innerHTML=html,imageLoader.lazyChildren(elem)}function fetchData(listInstance){listInstance.lastDataLoad=0,loading.show();var options={},apiClient=getApiClient(listInstance);return listInstance.options.userId&&(options.UserId=listInstance.options.userId),listInstance.options.isLocalSync?options.TargetId=apiClient.deviceId():options.ExcludeTargetIds=apiClient.deviceId(),apiClient.getJSON(apiClient.getUrl("Sync/Jobs",options)).then(function(response){renderList(listInstance,response.Items,apiClient),loading.hide()})}function startListening(listInstance){var startParams="0,1500",apiClient=getApiClient(listInstance);listInstance.options.userId&&(startParams+=","+listInstance.options.userId),listInstance.options.isLocalSync&&(startParams+=","+apiClient.deviceId()),apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobsStart",startParams)}function stopListening(listInstance){var apiClient=getApiClient(listInstance);apiClient.isWebSocketOpen()&&apiClient.sendWebSocketMessage("SyncJobsStop","")}function getApiClient(listInstance){return connectionManager.getApiClient(listInstance.options.serverId)}function showJobMenu(listInstance,elem){var item=dom.parentWithClass(elem,"listItem"),jobId=item.getAttribute("data-id"),status=item.getAttribute("data-status"),menuItems=[];if("Cancelled"===status)menuItems.push({name:globalize.translate("sharedcomponents#Delete"),id:"delete"});else{var txt=listInstance.options.isLocalSync?globalize.translate("sharedcomponents#RemoveDownload"):globalize.translate("sharedcomponents#ButtonCancelSyncJob");menuItems.push({name:txt,id:"cancel"})}require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"delete":cancelJob(listInstance,jobId);break;case"cancel":cancelJob(listInstance,jobId)}}})})}function onElementClick(e){var listInstance=this,btnJobMenu=dom.parentWithClass(e.target,"btnJobMenu");if(btnJobMenu)return void showJobMenu(this,btnJobMenu);var listItem=dom.parentWithClass(e.target,"listItem");if(listItem){var jobId=listItem.getAttribute("data-id");require(["syncJobEditor"],function(syncJobEditor){syncJobEditor.show({serverId:listInstance.options.serverId,jobId:jobId}).then(function(){fetchData(listInstance)})})}}function syncJobList(options){this.options=options;var onSyncJobsUpdatedHandler=onSyncJobsUpdated.bind(this);this.onSyncJobsUpdatedHandler=onSyncJobsUpdatedHandler,events.on(serverNotifications,"SyncJobs",onSyncJobsUpdatedHandler);var onClickHandler=onElementClick.bind(this);options.element.addEventListener("click",onClickHandler),this.onClickHandler=onClickHandler,options.element.innerHTML='
',fetchData(this),startListening(this),initSupporterInfo(options.element,getApiClient(this))}function showSupporterInfo(context){var html='