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

1 line
10 KiB
JavaScript
Raw Normal View History

2017-07-01 09:12:40 -07:00
define(["jQuery","globalize","scripts/taskbutton","dom","libraryMenu","layoutManager","loading","listViewStyle","flexStyles","emby-itemscontainer","cardStyle","material-icons","emby-linkbutton"],function($,globalize,taskButton,dom,libraryMenu,layoutManager,loading){"use strict";function resetTuner(page,id){var message=globalize.translate("MessageConfirmResetTuner");require(["confirm"],function(confirm){confirm(message,globalize.translate("HeaderResetTuner")).then(function(){loading.show(),ApiClient.resetLiveTvTuner(id).then(function(){loading.hide(),reload(page)})})})}function renderTuners(page,tuners){var html="";if(tuners.length){html+='<div class="paperList">';for(var i=0,length=tuners.length;i<length;i++){var tuner=tuners[i];html+='<div class="listItem">',html+='<i class="listItemIcon md-icon">live_tv</i>',html+='<div class="listItemBody two-line">',html+='<h3 class="listItemBodyText">',html+=tuner.Name,html+="</h3>",html+='<div class="listItemBodyText secondary">',html+=tuner.SourceType,html+="</div>",html+='<div class="listItemBodyText secondary">',html+="RecordingTv"==tuner.Status?tuner.ChannelName?globalize.translate("StatusRecordingProgram").replace("{0}",tuner.ChannelName):globalize.translate("StatusRecording"):"LiveTv"==tuner.Status?tuner.ChannelName?globalize.translate("StatusWatchingProgram").replace("{0}",tuner.ChannelName):globalize.translate("StatusWatching"):tuner.Status,html+="</div>",html+="</div>",tuner.CanReset&&(html+='<button type="button" is="paper-icon-button-light" data-tunerid="'+tuner.Id+'" title="'+globalize.translate("ButtonResetTuner")+'" class="btnResetTuner"><i class="md-icon">refresh</i></button>'),html+="</div>"}html+="</div>"}tuners.length?page.querySelector(".tunerSection").classList.remove("hide"):page.querySelector(".tunerSection").classList.add("hide");var elem=$(".tunerList",page).html(html);$(".btnResetTuner",elem).on("click",function(){var id=this.getAttribute("data-tunerid");resetTuner(page,id)})}function getServiceHtml(service){var html="";html+="<div>";var serviceUrl=service.HomePageUrl||"#";html+='<p><a is="emby-linkbutton" class="button-link" href="'+serviceUrl+'" target="_blank">'+service.Name+"</a></p>";var versionHtml=service.Version||"Unknown";versionHtml+=service.HasUpdateAvailable?' <a style="margin-left: .25em;" is="emby-linkbutton" class="button-link" href="'+serviceUrl+'" target="_blank">'+globalize.translate("LiveTvUpdateAvailable")+"</a>":'<img src="css/images/checkmarkgreen.png" style="height: 17px; margin-left: 10px; margin-right: 0; position: relative; top: 5px; border-radius:3px;" /> '+globalize.translate("LabelVersionUpToDate"),html+="<p>"+versionHtml+"</p>";var status=service.Status;return"Ok"==service.Status?status='<span style="color:green;">'+status+"</span>":(service.StatusMessage&&(status+=" ("+service.StatusMessage+")"),status='<span style="color:red;">'+status+"</span>"),html+="<p>"+globalize.translate("ValueStatus",status)+"</p>",html+="</div>"}function loadPage(page,liveTvInfo){liveTvInfo.IsEnabled?$(".liveTvStatusContent",page).show():$(".liveTvStatusContent",page).hide();var servicesToDisplay=liveTvInfo.Services.filter(function(s){return s.IsVisible});servicesToDisplay.length?$(".servicesSection",page).show():$(".servicesSection",page).hide(),$(".servicesList",page).html(servicesToDisplay.map(getServiceHtml).join(""));for(var tuners=[],i=0,length=liveTvInfo.Services.length;i<length;i++)for(var j=0,numTuners=liveTvInfo.Services[i].Tuners.length;j<numTuners;j++)tuners.push(liveTvInfo.Services[i].Tuners[j]);renderTuners(page,tuners),ApiClient.getNamedConfiguration("livetv").then(function(config){renderDevices(page,config.TunerHosts),renderProviders(page,config.ListingProviders)}),loading.hide()}function getDeviceHtml(device){var padderClass,html="",cssClass="card scalableCard",cardBoxCssClass="cardBox visualCardBox";return cssClass+=" backdropCard backdropCard-scalable",padderClass="cardPadder-backdrop",layoutManager.tv&&(cssClass+=" card-focusscale",cardBoxCssClass+=" cardBox-focustransform"),cardBoxCssClass+=" card-focuscontent",html+='<div type=